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 |
|---|---|---|---|---|---|---|
538,541 | <pre><code>public interface IBar {}
public interface IFoo : IBar {}
typeof(IFoo).BaseType == null
</code></pre>
<p>How can I get IBar?</p>
| [
{
"answer_id": 538557,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 7,
"selected": true,
"text": "<pre><code>Type[] types = typeof(IFoo).GetInterfaces();\n</code></pre>\n\n<p>Edit: If you specifically want IBar, you can do:... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9587/"
] | ```
public interface IBar {}
public interface IFoo : IBar {}
typeof(IFoo).BaseType == null
```
How can I get IBar? | ```
Type[] types = typeof(IFoo).GetInterfaces();
```
Edit: If you specifically want IBar, you can do:
```
Type type = typeof(IFoo).GetInterface("IBar");
``` |
538,551 | <p>I've been considering fast poker hand evaluation in Python. It occurred to me that one way to speed the process up would be to represent all the card faces and suits as prime numbers and multiply them together to represent the hands. To whit:</p>
<pre><code>class PokerCard:
faces = '23456789TJQKA'
suits = '... | [
{
"answer_id": 538571,
"author": "Autoplectic",
"author_id": 49994,
"author_profile": "https://Stackoverflow.com/users/49994",
"pm_score": 5,
"selected": false,
"text": "<p>python supports arbitrarily large integers naturally:</p>\n\n<pre><code>In [1]: 59**3*61**4*2*3*5*7*3*5*7\nOut[1]: ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | I've been considering fast poker hand evaluation in Python. It occurred to me that one way to speed the process up would be to represent all the card faces and suits as prime numbers and multiply them together to represent the hands. To whit:
```
class PokerCard:
faces = '23456789TJQKA'
suits = 'cdhs'
face... | Python supports a "bignum" integer type which can work with arbitrarily large numbers. In Python 2.5+, this type is called `long` and is separate from the `int` type, but the interpreter will automatically use whichever is more appropriate. In Python 3.0+, the `int` type has been dropped completely.
That's just an imp... |
538,560 | <p>I have a char* buffer and I am interested in looking at the first byte in the char* buffer, what is the most optimal way to go about this. </p>
<p>EDIT: Based on the negative votes I might want to explain why this question, I am aware of methods but in the code base that I have been looking for getting first byte p... | [
{
"answer_id": 538566,
"author": "Johannes Weiss",
"author_id": 55925,
"author_profile": "https://Stackoverflow.com/users/55925",
"pm_score": 5,
"selected": true,
"text": "<p>Just use</p>\n\n<pre><code>char firstByte = buffer[0];\n</code></pre>\n"
},
{
"answer_id": 538567,
"a... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | I have a char\* buffer and I am interested in looking at the first byte in the char\* buffer, what is the most optimal way to go about this.
EDIT: Based on the negative votes I might want to explain why this question, I am aware of methods but in the code base that I have been looking for getting first byte people do... | Just use
```
char firstByte = buffer[0];
``` |
538,603 | <p>Is there some way to use default parameters values with closures in Groovy?</p>
<p>This is what I tried so far:</p>
<pre><code>class Persona {
String name
Persona( String name ) {
this.name = name
}
String salute( String salute = "Hola" ) {
salute + ' ' + this.name
}
}
Perso... | [
{
"answer_id": 538698,
"author": "David M. Karr",
"author_id": 10508,
"author_profile": "https://Stackoverflow.com/users/10508",
"pm_score": -1,
"selected": false,
"text": "<p>I don't believe Groovy has a direct way to do what you're asking.</p>\n\n<p>The way to simulate this is for \"sa... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47633/"
] | Is there some way to use default parameters values with closures in Groovy?
This is what I tried so far:
```
class Persona {
String name
Persona( String name ) {
this.name = name
}
String salute( String salute = "Hola" ) {
salute + ' ' + this.name
}
}
Persona.metaClass.salute2 ... | Your code is working fine as you expected with Groovy 1.6-RC2. |
538,623 | <p>Is the following code portable?</p>
<pre><code>template<typename In>
struct input_sequence_range : public pair<In,In> {
input_sequence_range(In first, In last) : pair<In,In>(first, last) { }
};
template<typename Arr>
input_sequence_range<Arr*> iseq(Arr* a,
... | [
{
"answer_id": 538644,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 0,
"selected": false,
"text": "<p>According to Josuttis, you <em>should</em> use the typedefs in order to be more flexible and properly generic. Al... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456/"
] | Is the following code portable?
```
template<typename In>
struct input_sequence_range : public pair<In,In> {
input_sequence_range(In first, In last) : pair<In,In>(first, last) { }
};
template<typename Arr>
input_sequence_range<Arr*> iseq(Arr* a,
typename iterator_traits<Arr*>::diff... | `difference_type` must be an integral type so `int*` is out. |
538,640 | <p>My question is simple: how bad is the following snippet of code? How would <em>you</em> do it?</p>
<pre><code>CancelEventHandler _windowClosing;
private CancelEventHandler WindowClosing
{
set
{
clearEventHandlerList();
this.Closing += value;
_windowClosing = value;
/*
* if calling the me... | [
{
"answer_id": 538737,
"author": "LDomagala",
"author_id": 45719,
"author_profile": "https://Stackoverflow.com/users/45719",
"pm_score": 1,
"selected": false,
"text": "<p>somehow your code makes me want to cry, i´m sorry. i read it twice and all i know about it is that it \"doesStuff\" w... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My question is simple: how bad is the following snippet of code? How would *you* do it?
```
CancelEventHandler _windowClosing;
private CancelEventHandler WindowClosing
{
set
{
clearEventHandlerList();
this.Closing += value;
_windowClosing = value;
/*
* if calling the method with null paramet... | I think it might be theoretically possible to make that code more delightfully diverting, perilously puckish, jovially jeopardous, cheerily chancy and unwarily whimsical but it would require some serious thought. |
538,664 | <p>Using <code>sed</code> what is an one liner to print the first <em>n characters</em>? I am doing the following:</p>
<pre><code>grep -G 'defn -test.*' OctaneFullTest.clj | sed ....
</code></pre>
| [
{
"answer_id": 538676,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 9,
"selected": true,
"text": "<p>Don't use <code>sed</code>, use <code>cut</code>:</p>\n\n<pre><code>grep .... | cut -c 1-N\n</code></pre>\n\n<p>If yo... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10522/"
] | Using `sed` what is an one liner to print the first *n characters*? I am doing the following:
```
grep -G 'defn -test.*' OctaneFullTest.clj | sed ....
``` | Don't use `sed`, use `cut`:
```
grep .... | cut -c 1-N
```
If you MUST use `sed`:
```
grep ... | sed -e 's/^\(.\{12\}\).*/\1/'
``` |
538,666 | <p>I'm having trouble formatting a <code>datetime.timedelta</code> object.</p>
<p>Here's what I'm trying to do:
I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event. I would like to display that duration in the format of hours:minutes.... | [
{
"answer_id": 538687,
"author": "joeforker",
"author_id": 36330,
"author_profile": "https://Stackoverflow.com/users/36330",
"pm_score": 6,
"selected": false,
"text": "<pre><code>>>> str(datetime.timedelta(hours=10.56))\n10:33:36\n\n>>> td = datetime.timedelta(hours=10.... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65279/"
] | I'm having trouble formatting a `datetime.timedelta` object.
Here's what I'm trying to do:
I have a list of objects and one of the members of the class of the object is a timedelta object that shows the duration of an event. I would like to display that duration in the format of hours:minutes.
I have tried a variet... | Thanks everyone for your help. I took many of your ideas and put them together, let me know what you think.
I added two methods to the class like this:
```
def hours(self):
retval = ""
if self.totalTime:
hoursfloat = self.totalTime.seconds / 3600
retval = round(hoursfloat)
return retval
d... |
538,668 | <p>I need to test a method belonging to a service class. This service class has several dependencies in the constructor, some used by this method, some not. If we should not be using a DI container for our unit tests what is the best way to instantiate the service class?</p>
<pre><code>var service = new ServiceClass... | [
{
"answer_id": 538696,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.myjavatools.com/cuecards/refactoring.html\" rel=\"nofollow noreferrer\">http://www.myjavatools.com/cue... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9604/"
] | I need to test a method belonging to a service class. This service class has several dependencies in the constructor, some used by this method, some not. If we should not be using a DI container for our unit tests what is the best way to instantiate the service class?
```
var service = new ServiceClass(new Repository1... | You should really look at using a mocking framework to isolate your test from the actual dependent objects. I'm assuming you use C# (from the `var` keyword), so I'll give an example from RhinoMock.
```
var respository1 = MockRepository.GenerateMock<Repository1>();
repository1.Expect( r => r.SomeMethod() ).Return( some... |
538,669 | <p>I seem to be suffering from some fundamental misunderstanding of the way that GWT async calls work and/or how widgets are updated upon receipt of a callback.</p>
<p>I've created the two interfaces as well as the implementation and they seem to be communicating with one another. I make this claim based on reasonabl... | [
{
"answer_id": 538696,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.myjavatools.com/cuecards/refactoring.html\" rel=\"nofollow noreferrer\">http://www.myjavatools.com/cue... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2170994/"
] | I seem to be suffering from some fundamental misunderstanding of the way that GWT async calls work and/or how widgets are updated upon receipt of a callback.
I've created the two interfaces as well as the implementation and they seem to be communicating with one another. I make this claim based on reasonable looking d... | You should really look at using a mocking framework to isolate your test from the actual dependent objects. I'm assuming you use C# (from the `var` keyword), so I'll give an example from RhinoMock.
```
var respository1 = MockRepository.GenerateMock<Repository1>();
repository1.Expect( r => r.SomeMethod() ).Return( some... |
538,673 | <p>I am trying to create a SWT Link with the text so it looks like the following</p>
<p><this is the link></p>
<p>where the text <strong>this is the link</strong> is the actual link and the angle brackets are not part of the link.</p>
<p>I can get close with the following code:</p>
<pre><code>link.setText("<a... | [
{
"answer_id": 538696,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://www.myjavatools.com/cuecards/refactoring.html\" rel=\"nofollow noreferrer\">http://www.myjavatools.com/cue... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create a SWT Link with the text so it looks like the following
<this is the link>
where the text **this is the link** is the actual link and the angle brackets are not part of the link.
I can get close with the following code:
```
link.setText("<a><this is the link></a>");
```
However, I want just ... | You should really look at using a mocking framework to isolate your test from the actual dependent objects. I'm assuming you use C# (from the `var` keyword), so I'll give an example from RhinoMock.
```
var respository1 = MockRepository.GenerateMock<Repository1>();
repository1.Expect( r => r.SomeMethod() ).Return( some... |
538,674 | <p>Do anyone know how to put Google adsense ads inside a GWT web application?</p>
| [
{
"answer_id": 538832,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 2,
"selected": false,
"text": "<p>According to <a href=\"http://groups.google.com/group/adsense-help-troubleshooting/browse_thread/thread/632a7d4cf3d2e06/... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52924/"
] | Do anyone know how to put Google adsense ads inside a GWT web application? | You can put the javascript-code from Adsense in the single HTML page that GWT starts with. This way the advertising will not be displayed in the same area as GTW but above/below the GWT code. For advertising that could be ok.
This example places a baner above the application:
```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD ... |
538,678 | <p>I am using my iPhone as a development device. Whenever I run an application on the iPhone with Instruments (Instruments->Launch Executable->my app), the app is launched but I get the error mentioned in the subject in Instruments.</p>
<p>I have tried removing the device from xcode and adding it again as a developmen... | [
{
"answer_id": 542221,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 1,
"selected": false,
"text": "<p>Does it crash normally? or only using Instruments?</p>\n\n<p>I've had lots of oddness with instruments and app insta... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46297/"
] | I am using my iPhone as a development device. Whenever I run an application on the iPhone with Instruments (Instruments->Launch Executable->my app), the app is launched but I get the error mentioned in the subject in Instruments.
I have tried removing the device from xcode and adding it again as a development device b... | Did a fresh certificate-provisioning profile routine and changed the bundle identifier to read myAppId.somethingForTheStar.${PRODUCT\_NAME:identifier}
Also, if you open the mobileprovision in TextEdit and search for
```
<key>get-task-allow</key>
```
if the value for the key is **true**, make sure the option is ch... |
538,694 | <p>The statement is:</p>
<pre><code>//Pass the copy onto the child controller
self.childController.theFoodFacilityCopy = [self.theFoodFacility copy];
</code></pre>
<p>My property is set to:</p>
<pre><code>@property (nonatomic, retain) FoodFacility *theFoodFacilityCopy;
</code></pre>
<p>The reason I think I have a l... | [
{
"answer_id": 538725,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 4,
"selected": true,
"text": "<p>yes, you do have a leak there.</p>\n\n<pre><code>SomeClass *someObj = [self.theFoodFacility copy];\nself.childControl... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51420/"
] | The statement is:
```
//Pass the copy onto the child controller
self.childController.theFoodFacilityCopy = [self.theFoodFacility copy];
```
My property is set to:
```
@property (nonatomic, retain) FoodFacility *theFoodFacilityCopy;
```
The reason I think I have a leak is because `copy` retains the value and then ... | yes, you do have a leak there.
```
SomeClass *someObj = [self.theFoodFacility copy];
self.childController.theFoodFacilityCopy = someObj;
[someObj release];
```
This mirrors the recommended approach for initializing an object too:
```
SomeClass *someObj = [[SomeClass alloc] init];
self.someProperty = someObj;
[someO... |
538,695 | <p>I have a c# DateTime object and I need to increment it by one month.</p>
<p>example:</p>
<pre><code>input output
-------------------------------
Jan 12, 2005 Feb 12, 2005
Feb 28, 2009 Mar 28, 2009
Dec 31, 2009 Jan 31, 2010
Jan 29, 2000 Feb 29, 2000
Jan 29, 2100 Error: no Feb 29, 2100
</cod... | [
{
"answer_id": 538714,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>Here's a complete program showing the examples given in the question. You'd probably want to use an exception in OneMo... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] | I have a c# DateTime object and I need to increment it by one month.
example:
```
input output
-------------------------------
Jan 12, 2005 Feb 12, 2005
Feb 28, 2009 Mar 28, 2009
Dec 31, 2009 Jan 31, 2010
Jan 29, 2000 Feb 29, 2000
Jan 29, 2100 Error: no Feb 29, 2100
```
What is the best way... | Here's a complete program showing the examples given in the question. You'd probably want to use an exception in OneMonthAfter if it really shouldn't be called that way.
```
using System;
using System.Net;
public class Test
{
static void Main(string[] args)
{
Check(new DateTime(2005, 1, 12));
... |
538,711 | <p>I have a point class like:</p>
<pre><code>class Point {
public:
int x, y;
Point(int x1, int y1)
{
x = x1;
y = y1;
}
};
</code></pre>
<p>and a list of points:</p>
<pre><code>std::list <Point> pointList;
std::list <Point>::iterator iter;
</code></pre>
<p>I'm pushing poin... | [
{
"answer_id": 538758,
"author": "Coincoin",
"author_id": 42,
"author_profile": "https://Stackoverflow.com/users/42",
"pm_score": 2,
"selected": false,
"text": "<p>You are right on how it should be made. Just iterate through all items in the list and keep track of the smallest distance a... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64878/"
] | I have a point class like:
```
class Point {
public:
int x, y;
Point(int x1, int y1)
{
x = x1;
y = y1;
}
};
```
and a list of points:
```
std::list <Point> pointList;
std::list <Point>::iterator iter;
```
I'm pushing points on to my pointList (although the list might contain no Poi... | Use a std::list::iterator variable to keep track of the closest point as you loop through the list. When you get to the end of the list it will contain the closest point and can be used to erase the item.
```
void erase_closest_point(const list<Point>& pointList, const Point& point)
{
if (!pointList.empty())
{... |
538,719 | <p>Short story.
This site was created by a friend of mine, who did not know that much C# or asp. And was firstly created in VS 2k3. When i converted it to VS 2k8 these errors started to crop up, there was also other issues with compiling that i managed to sort out ( Seemed to be released to VS 2k8 wanted design files )... | [
{
"answer_id": 538815,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 8,
"selected": true,
"text": "<p>In <code>Default.aspx</code> change <code>CodeFile</code> to <code>CodeBehind</code>. You'll probably have to do the same... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62999/"
] | Short story.
This site was created by a friend of mine, who did not know that much C# or asp. And was firstly created in VS 2k3. When i converted it to VS 2k8 these errors started to crop up, there was also other issues with compiling that i managed to sort out ( Seemed to be released to VS 2k8 wanted design files )
E... | In `Default.aspx` change `CodeFile` to `CodeBehind`. You'll probably have to do the same for the `Site.master`.
See: [CodeFile and Code-Behind](http://www.ddj.com/windows/187202007) |
538,729 | <p>The indexer into <code>Dictionary</code> throws an exception if the key is missing. Is there an implementation of <code>IDictionary</code> that instead will return <code>default(T)</code>?</p>
<p>I know about the <code>TryGetValue()</code> method, but that's impossible to use with LINQ.</p>
<p>Would this efficientl... | [
{
"answer_id": 538749,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "<p>No, because otherwise how would you know the difference when the key exists but stored a null value? That could b... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18941/"
] | The indexer into `Dictionary` throws an exception if the key is missing. Is there an implementation of `IDictionary` that instead will return `default(T)`?
I know about the `TryGetValue()` method, but that's impossible to use with LINQ.
Would this efficiently do what I need?:
```
myDict.FirstOrDefault(a => a.Key == ... | Indeed, that won't be efficient at all.
As per comments, in .Net Core 2+ / NetStandard 2.1+ / Net 5, [MS added the extension method `GetValueOrDefault()`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.collectionextensions.getvalueordefault?view=netstandard-2.1)
For earlier versions you can w... |
538,738 | <p>I am looking for constant time algorithm can change an ordered integer index value into a random hash index. It would nice if it is reversible. I need that hash key is unique for each index. I know that this could be done with a table look up in a large file. I.E. create an ordered set of all ints and then shuffle t... | [
{
"answer_id": 538854,
"author": "AShelly",
"author_id": 10396,
"author_profile": "https://Stackoverflow.com/users/10396",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming your goal is to spread out grouped values across the whole range, <br>\nit seems like shuffling the bits in so... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27417/"
] | I am looking for constant time algorithm can change an ordered integer index value into a random hash index. It would nice if it is reversible. I need that hash key is unique for each index. I know that this could be done with a table look up in a large file. I.E. create an ordered set of all ints and then shuffle them... | The question is now if you need a really random mapping, or just a "weak" permutation. Assuming the latter, if you operate with unsigned 32-bit integers (say) on 2's complement arithmetics, multiplication by any odd number is a bijective and reversible mapping. Of course the same goes for XOR, so a simple pattern which... |
538,739 | <p>I want to store times in a database table but only need to store the hours and minutes.
I know I could just use DATETIME and ignore the other components of the date, but what's the best way to do this without storing more info than I actually need?</p>
| [
{
"answer_id": 538754,
"author": "BigJump",
"author_id": 8542,
"author_profile": "https://Stackoverflow.com/users/8542",
"pm_score": 8,
"selected": true,
"text": "<p>You could store it as an integer of the number of minutes past midnight:</p>\n\n<p>eg. </p>\n\n<pre><code>0 = 00:00 \n60 =... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15613/"
] | I want to store times in a database table but only need to store the hours and minutes.
I know I could just use DATETIME and ignore the other components of the date, but what's the best way to do this without storing more info than I actually need? | You could store it as an integer of the number of minutes past midnight:
eg.
```
0 = 00:00
60 = 01:00
252 = 04:12
```
You would however need to write some code to reconstitute the time, but that shouldn't be tricky. |
538,745 | <p>I'm dynamically adding <code><script></code> tags to a page's <code><head></code>, and I'd like to be able to tell whether the loading failed in some way -- a 404, a script error in the loaded script, whatever.</p>
<p>In Firefox, this works:</p>
<pre><code>var script_tag = document.createElement('scrip... | [
{
"answer_id": 538823,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 5,
"selected": false,
"text": "<p>There is no error event for the script tag. You can tell when it is successful, and assume that it h... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53192/"
] | I'm dynamically adding `<script>` tags to a page's `<head>`, and I'd like to be able to tell whether the loading failed in some way -- a 404, a script error in the loaded script, whatever.
In Firefox, this works:
```
var script_tag = document.createElement('script');
script_tag.setAttribute('type', 'text/javascript')... | There is no error event for the script tag. You can tell when it is successful, and assume that it has not loaded after a timeout:
```
<script type="text/javascript" onload="loaded=1" src="....js"></script>
``` |
538,750 | <p>If I have the following code:</p>
<pre><code>Style defaultStyle = (Style)FindResource("MyTestStyle");
</code></pre>
<p>Is there a way to get the name of the style (i.e. reverse-lookup)? Something like:</p>
<pre><code>string name = defaultStyle.SomeMagicLookUpFunction()
</code></pre>
<p>Where name would evaluate ... | [
{
"answer_id": 539084,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 1,
"selected": false,
"text": "<p>Without searching resource dictionaries, I don't think this is possible as x:Key is part of the XAML markup grammar... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47645/"
] | If I have the following code:
```
Style defaultStyle = (Style)FindResource("MyTestStyle");
```
Is there a way to get the name of the style (i.e. reverse-lookup)? Something like:
```
string name = defaultStyle.SomeMagicLookUpFunction()
```
Where name would evaluate to "MyTestStyle."
Is this possible? | I've created a small helper class with a single method to do the reverse lookup that you require.
```
public static class ResourceHelper
{
static public string FindNameFromResource(ResourceDictionary dictionary, object resourceItem)
{
foreach (object key in dictionary.Keys)
{
if (di... |
538,752 | <p>In C, I can allocate a register for a variable, for example:</p>
<pre><code>register int i = 0;
</code></pre>
<p>I am aware that Java is an interpreted language, and is many many abstractions away from the CPU.</p>
<p>Is there any mechanism available to even request (and if the architecture doesn't allow it, so w... | [
{
"answer_id": 538764,
"author": "Johannes Weiss",
"author_id": 55925,
"author_profile": "https://Stackoverflow.com/users/55925",
"pm_score": 4,
"selected": false,
"text": "<p><code>register</code> in C does not put a variable to register. It simply gives the compiler the hint, that it w... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43263/"
] | In C, I can allocate a register for a variable, for example:
```
register int i = 0;
```
I am aware that Java is an interpreted language, and is many many abstractions away from the CPU.
Is there any mechanism available to even request (and if the architecture doesn't allow it, so what) that my variable remains in ... | No, there's no way to request this in Java. However, there are some things that you can do that will prevent a register from being used, such as applying the `volatile` modifier to a member variable. |
538,788 | <p>I would need a suggestion or even a solution, how to get only the second,third... row of a query result with high performance. I know there is the possibility of row_number(SQL Server 2005 or higher) but not for SQL Server 2000 :-( <br></p>
<p>My first try to get the fifth row was:<br>
SELECT TOP 1 col<br>
FROM... | [
{
"answer_id": 538799,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>Probably the best and fastest way to do this is just select the top 5 in a datareader, and just read the next into ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would need a suggestion or even a solution, how to get only the second,third... row of a query result with high performance. I know there is the possibility of row\_number(SQL Server 2005 or higher) but not for SQL Server 2000 :-(
My first try to get the fifth row was:
SELECT TOP 1 col
FROM (SELECT TOP 5 co... | This should do it...
```
CREATE PROCEDURE [dbo].[sp_UpdateSkills]
AS
BEGIN
set nocount on
declare @UserID int
declare @Skill varchar(1)
declare @SkillCount int
declare @Skill1 varchar(1)
declare @Skill2 varchar(1)
declare @Skill3 varchar(1)
declare @Skill4 varchar(1)
declare @Skil... |
538,793 | <p>I'm trying to put a rails face on a legacy database. It is an old Sybase
11 database installation. I've gotten an ODBC connection working that
uses unixODBC and FreeTDS to work. I'm also using the
activerecord-odbc-adapter gem.</p>
<p>I've had to use set_table_name and set_primary_key to make it work so
far. Howeve... | [
{
"answer_id": 538965,
"author": "wesgarrison",
"author_id": 62140,
"author_profile": "https://Stackoverflow.com/users/62140",
"pm_score": 1,
"selected": false,
"text": "<p>Does this work:</p>\n\n<pre><code>User.find(:all, :conditions => ['name = ?', \"bob\"])\n</code></pre>\n\n<p>...... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25129/"
] | I'm trying to put a rails face on a legacy database. It is an old Sybase
11 database installation. I've gotten an ODBC connection working that
uses unixODBC and FreeTDS to work. I'm also using the
activerecord-odbc-adapter gem.
I've had to use set\_table\_name and set\_primary\_key to make it work so
far. However, non... | Your issue is that the finders are case sensitive. I have the same exact issue with my legacy database.
Try this to watch it work:
```
Person.find_by_Last_Name("Smith")
```
That should do the trick.
I have code that I have written to fix issues like this. It's a little monkey-patch for ActiveRecord that you can in... |
538,803 | <p>When I add this to my where clause:</p>
<pre><code>DueDate <= getDate() AND DueDate IS NOT null
</code></pre>
<p>I get a nice little failure that says:
Could not create child: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.EvaluateExceptio... | [
{
"answer_id": 538824,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 0,
"selected": false,
"text": "<p>Is that supposed to be T-SQL? try this</p>\n\n<pre><code>DueDate <= getDate() \nAND DueDate IS NOT null\n</code></pre... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | When I add this to my where clause:
```
DueDate <= getDate() AND DueDate IS NOT null
```
I get a nice little failure that says:
Could not create child: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.EvaluateException: The expression contains un... | The exception is pretty clear on what is wrong here. You are specifying a method, getdate, which can't be used in a filter expression. See the documentation on the Expression property on the DataColumn class for what is valid and what is not:
<http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.a... |
538,826 | <p>I have some tabular data with some functionality to "view details" that fires off an ajax call to append a few new elements to the DOM (usually I insert another TR just after the selected row and innerHTML or append inside a TD with a colspan.</p>
<p>My question is this, in IE6/7 my columns flex. Currently I don't... | [
{
"answer_id": 538841,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 1,
"selected": false,
"text": "<p>Tables resize dynamically based on content. That's their nature. You could always read the \"natural... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | I have some tabular data with some functionality to "view details" that fires off an ajax call to append a few new elements to the DOM (usually I insert another TR just after the selected row and innerHTML or append inside a TD with a colspan.
My question is this, in IE6/7 my columns flex. Currently I don't have a "st... | This trick here is using the somewhat esoteric `table-layout:fixed` rule
Use it like this:
```
table {table-layout:fixed}
```
You also ought to specify explicit column widths for the `<td>`s.
The `table-layout:fixed` rule says "The cell widths of this table depend on what I say, not on the actual content in the ce... |
538,842 | <p>I've been playing around with emacs lisp, and I wanted to write a little function to do a regular expression search and replace. I had a heck of a time getting the regular expression to work correctly because I didn't realize that all the special characters need to be double escaped when writing lisp code (but not ... | [
{
"answer_id": 538874,
"author": "scottfrazer",
"author_id": 17637,
"author_profile": "https://Stackoverflow.com/users/17637",
"pm_score": 6,
"selected": true,
"text": "<p>It's because you need to escape backslashes in strings. If you don't escape the backslash of <code>\\(</code> in th... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39461/"
] | I've been playing around with emacs lisp, and I wanted to write a little function to do a regular expression search and replace. I had a heck of a time getting the regular expression to work correctly because I didn't realize that all the special characters need to be double escaped when writing lisp code (but not when... | It's because you need to escape backslashes in strings. If you don't escape the backslash of `\(` in the string, it turns out to be just `(` |
538,859 | <p>I have an iPhone application that comes in differently skinned flavors, with different art assets and sounds, but all the same code.</p>
<p>I've got things set up with multiple targets, but the problem I'm having is I have to have a different set of UIBuilder nib files, one per view per target, set up to point to t... | [
{
"answer_id": 539210,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming that each app only needed one skin at a time, and that you are creating multiple apps with different themes... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/444955/"
] | I have an iPhone application that comes in differently skinned flavors, with different art assets and sounds, but all the same code.
I've got things set up with multiple targets, but the problem I'm having is I have to have a different set of UIBuilder nib files, one per view per target, set up to point to the correct... | One way to do this is to move all your artwork into a separate bundle and dynamically load it at runtime (sort of like a "media plug-in").
* Create a separate project and choose "Mac OS X / Framework & Library / Bundle." Call it, say, `media.bundle`.
* Move all your artwork into this project.
* To make life easy, add ... |
538,863 | <p>Lets say I'm building a base class which will be extended upon by the children class. So a base class is called <code>Base</code> and children can be <code>Child1</code>, <code>Child2</code>, etc.</p>
<p>In the base class's constructor, how can i get the value of Child1/Child2?</p>
<p>This is all using PHP</p>
| [
{
"answer_id": 538868,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "<p>Edit: Didn't know about <code>get_class</code>, disregard this one ;)</p>\n\n<p>You could try <code>__CLASS__</code> but it ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | Lets say I'm building a base class which will be extended upon by the children class. So a base class is called `Base` and children can be `Child1`, `Child2`, etc.
In the base class's constructor, how can i get the value of Child1/Child2?
This is all using PHP | A base class should really never depend on information about child classes---
To answer your question:
```
class base {
public function __construct() {
print "Class:" . get_class($this) . "\n";
}
}
class child extends base{
public function __construct() {
parent::__construct();
}
}
$c... |
538,870 | <p>Let's say I have a class designed to be instantiated. I have several private "helper" methods inside the class that do not require access to any of the class members, and operate solely on their arguments, returning a result.</p>
<pre><code>public class Example {
private Something member;
public double compu... | [
{
"answer_id": 538903,
"author": "Steve B.",
"author_id": 19479,
"author_profile": "https://Stackoverflow.com/users/19479",
"pm_score": 4,
"selected": false,
"text": "<p>My personal preference would be to declare them static, as it's a clear flag that they're stateless. </p>\n"
},
{
... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53905/"
] | Let's say I have a class designed to be instantiated. I have several private "helper" methods inside the class that do not require access to any of the class members, and operate solely on their arguments, returning a result.
```
public class Example {
private Something member;
public double compute() {
... | I prefer such helper methods to be `private static`; which will make it clear to the reader that they will not modify the state of the object. My IDE will also show calls to static methods in italics, so I will know the method is static without looking the signature. |
538,872 | <p>I have a GWT application that displays some charts rendered by JFreeChart. Every few minutes, the page refreshes, which causes the app to generate new charts. (In other words, the entire chart generation process is bootstrapped by a client request.) The problem with this is that multiple clients hitting the same ser... | [
{
"answer_id": 539533,
"author": "rustyshelf",
"author_id": 6044,
"author_profile": "https://Stackoverflow.com/users/6044",
"pm_score": 4,
"selected": true,
"text": "<p>To answer your question: No. GWT is a front end technology, and the only bit of GWT that crosses this line is the RPC m... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4287/"
] | I have a GWT application that displays some charts rendered by JFreeChart. Every few minutes, the page refreshes, which causes the app to generate new charts. (In other words, the entire chart generation process is bootstrapped by a client request.) The problem with this is that multiple clients hitting the same server... | To answer your question: No. GWT is a front end technology, and the only bit of GWT that crosses this line is the RPC mechanism. The only 'GWT' type way that you could do it would be to check if the chart files exist the first time a user requests them, and generate them if they don't. This would mean using the file sy... |
538,886 | <p>I've managed to get into a linux machine to try the HotKey library suggested in <a href="https://stackoverflow.com/questions/79658/react-on-global-hotkey-in-a-java-program-on-windows-linux-mac/202272#202272">this answer.</a></p>
<p>I've compiled the sample code and now I run the program and I've got the following m... | [
{
"answer_id": 538900,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 4,
"selected": true,
"text": "<p>Did you try <code>-Djava.library.path=/path/to/library</code>?</p>\n\n<p><strong>EDIT:</strong> Re-reading the err... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20654/"
] | I've managed to get into a linux machine to try the HotKey library suggested in [this answer.](https://stackoverflow.com/questions/79658/react-on-global-hotkey-in-a-java-program-on-windows-linux-mac/202272#202272)
I've compiled the sample code and now I run the program and I've got the following message:
```
[oracle... | Did you try `-Djava.library.path=/path/to/library`?
**EDIT:** Re-reading the error message, it looks to me that the native library you're loading is trying to link to glibc version 3.4.9, which apparently is not installed. Can you check what version of glibc you have? What Linux distro are you running?
**EDIT2:** The... |
538,898 | <p>Is it possible to play a sound notification using Google Web Toolkit which will be translated to Javascript? Thanks.</p>
| [
{
"answer_id": 539416,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": -1,
"selected": false,
"text": "<p>Yes it's possible, <a href=\"http://wiki.github.com/madrobby/scriptaculous/sound\" rel=\"nofollow noreferrer\">scripta... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | Is it possible to play a sound notification using Google Web Toolkit which will be translated to Javascript? Thanks. | Since GWT 2.2 you can play audio with: `com.google.gwt.media.client.Audio` class.
API:
<http://google-web-toolkit.googlecode.com/svn/javadoc/2.2/com/google/gwt/media/client/Audio.html>
Sample:
```
private Audio mistakeAudio;
{
mistakeAudio = Audio.createIfSupported();
mistakeAudio.setSrc("style/failure.wav"... |
538,906 | <p>Can somebody tell me how to get the header height of a ListView.</p>
| [
{
"answer_id": 538961,
"author": "Coincoin",
"author_id": 42,
"author_profile": "https://Stackoverflow.com/users/42",
"pm_score": 5,
"selected": true,
"text": "<p>This might be a little bit hacky but you can do:</p>\n\n<pre><code>listView.Items[0].Bounds.Top\n</code></pre>\n\n<p>This wil... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54009/"
] | Can somebody tell me how to get the header height of a ListView. | This might be a little bit hacky but you can do:
```
listView.Items[0].Bounds.Top
```
This will only work if there is only one item in the list. So you might want to temporarily add one when you first create the list and keep the height value.
Else, you can always use:
```
listView.TopItem.Bounds.Top
```
To make... |
538,925 | <p>I made a Window service and let it work automatically and under localsystem account, when the service starts it fires this message for me and then stops</p>
<blockquote>
<p>The [service name] service on local computer started and then stopped. Some Services stop automatically if they are not in use by another ser... | [
{
"answer_id": 538935,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 6,
"selected": true,
"text": "<p>Either you are not starting any threads on the OnStart method to do work, or there is an exception raised within y... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32718/"
] | I made a Window service and let it work automatically and under localsystem account, when the service starts it fires this message for me and then stops
>
> The [service name] service on local computer started and then stopped. Some Services stop automatically if they are not in use by another services or programs.
>... | Either you are not starting any threads on the OnStart method to do work, or there is an exception raised within your OnStart method.
If an exception is thrown, it will appear in the Windows Event log. The Windows Event log is a good place to start in any case.
Generally an OnStart method looks like this:
```
Threa... |
538,946 | <p>I am currently developing an app targeted for the HP IPAQ 210. Part of this app requires the WLAN radio to be enabled/powered on to connect to a pre-configured access point. I'm currently using the IPAQ SDK (via P/Invoke) to enable the WLAN radio, but I'm having trouble reliably determining when the radio has esta... | [
{
"answer_id": 565889,
"author": "Sam",
"author_id": 7021,
"author_profile": "https://Stackoverflow.com/users/7021",
"pm_score": 2,
"selected": true,
"text": "<p>It is ugly, and it is no event, but if all else fails, you could try and check the Wifi hardware state by reading it's registr... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7163/"
] | I am currently developing an app targeted for the HP IPAQ 210. Part of this app requires the WLAN radio to be enabled/powered on to connect to a pre-configured access point. I'm currently using the IPAQ SDK (via P/Invoke) to enable the WLAN radio, but I'm having trouble reliably determining when the radio has establish... | It is ugly, and it is no event, but if all else fails, you could try and check the Wifi hardware state by reading it's registry key:
```
int key = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\State\\Hardware", "WiFi", -1);
``` |
538,979 | <p>I have a "copy" stored procedure for a database. During the copy, I backup the database with something like:</p>
<pre><code>exec('backup database [' + @source + '] ' +
'to disk = N''' + @backupdir + '\copybackup'' ' +
'with noformat, noinit, name=N''copybackup-full'', ' +
'SKIP, NOREWIND, NOUNL... | [
{
"answer_id": 565889,
"author": "Sam",
"author_id": 7021,
"author_profile": "https://Stackoverflow.com/users/7021",
"pm_score": 2,
"selected": true,
"text": "<p>It is ugly, and it is no event, but if all else fails, you could try and check the Wifi hardware state by reading it's registr... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8173/"
] | I have a "copy" stored procedure for a database. During the copy, I backup the database with something like:
```
exec('backup database [' + @source + '] ' +
'to disk = N''' + @backupdir + '\copybackup'' ' +
'with noformat, noinit, name=N''copybackup-full'', ' +
'SKIP, NOREWIND, NOUNLOAD, STATS = 1... | It is ugly, and it is no event, but if all else fails, you could try and check the Wifi hardware state by reading it's registry key:
```
int key = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\State\\Hardware", "WiFi", -1);
``` |
538,989 | <p>If I have an element with one or more subelements, should the min/maxoccurs attributes be on the xsd:sequence element, the xsd:element, both, or neither?</p>
<pre><code><xsd:element name="books">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded"> <!-- here? -->
... | [
{
"answer_id": 539033,
"author": "baretta",
"author_id": 30052,
"author_profile": "https://Stackoverflow.com/users/30052",
"pm_score": 1,
"selected": false,
"text": "<p>Put the maxOccurs attribute on the <xsd:element> element.</p>\n\n<pre><code><xsd:sequence>\n <xsd:element ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16399/"
] | If I have an element with one or more subelements, should the min/maxoccurs attributes be on the xsd:sequence element, the xsd:element, both, or neither?
```
<xsd:element name="books">
<xsd:complexType>
<xsd:sequence minOccurs="1" maxOccurs="unbounded"> <!-- here? -->
<xsd:element ref="book" minOccurs="1" ... | In almost all circumstances, you want to put the min/max Occurs on the element within a sequence and not on the sequence. Using your example:
```
<xsd:element name="books">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="book" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType... |
538,996 | <p>I'm developing a <a href="http://en.wikipedia.org/wiki/Cocoa_%28API%29" rel="noreferrer">Cocoa</a> application, and I'm using constant <code>NSString</code>s as ways to store key names for my preferences.</p>
<p>I understand this is a good idea because it allows easy changing of keys if necessary.<br>
Plus, it's th... | [
{
"answer_id": 539012,
"author": "Abizern",
"author_id": 41116,
"author_profile": "https://Stackoverflow.com/users/41116",
"pm_score": 4,
"selected": false,
"text": "<p>If you want something like global constants; a quick an dirty way is to put the constant declarations into the <code>pc... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57414/"
] | I'm developing a [Cocoa](http://en.wikipedia.org/wiki/Cocoa_%28API%29) application, and I'm using constant `NSString`s as ways to store key names for my preferences.
I understand this is a good idea because it allows easy changing of keys if necessary.
Plus, it's the whole 'separate your data from your logic' notio... | You should create a header file like:
```
// Constants.h
FOUNDATION_EXPORT NSString *const MyFirstConstant;
FOUNDATION_EXPORT NSString *const MySecondConstant;
//etc.
```
(You can use `extern` instead of `FOUNDATION_EXPORT` if your code will not be used in mixed C/C++ environments or on other platforms.)
You can in... |
538,999 | <p>I'm trying to use java.util.Scanner to take Wikipedia contents and use it for word based searches.
The fact is that it's all fine but when reading some words it give me errors.
Looking at code and making some check it turned out that with some words it seems
not to recognize the encoding, or so, and the content is... | [
{
"answer_id": 539023,
"author": "parkerfath",
"author_id": 6027,
"author_profile": "https://Stackoverflow.com/users/6027",
"pm_score": 2,
"selected": false,
"text": "<p>Try using the Scanner with a specified character set:</p>\n\n<pre><code>public Scanner(InputStream source, String char... | 2009/02/11 | [
"https://Stackoverflow.com/questions/538999",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22963/"
] | I'm trying to use java.util.Scanner to take Wikipedia contents and use it for word based searches.
The fact is that it's all fine but when reading some words it give me errors.
Looking at code and making some check it turned out that with some words it seems
not to recognize the encoding, or so, and the content is no... | Try using a `Reader` instead of an `InputStream` - I think it works something like this:
```
connection = new URL("http://it.wikipedia.org/wiki/"+word).openConnection();
String ctype = connection.getContentType();
int csi = ctype.indexOf("charset=");
Scanner scanner;
if (csi > 0)
scanner = new Scanner(new InputSt... |
539,003 | <p>I want to prevent the user from editing or deleting the first three rows of a datagridview.</p>
<p>How can I do this?</p>
| [
{
"answer_id": 539032,
"author": "WebMatrix",
"author_id": 63121,
"author_profile": "https://Stackoverflow.com/users/63121",
"pm_score": 1,
"selected": false,
"text": "<p>One way to do it is to capture _CellBeginEdit event, check if any edits on the targeted row are allowed, and cancel e... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12243/"
] | I want to prevent the user from editing or deleting the first three rows of a datagridview.
How can I do this? | Solution:
```
private void dataGridView3_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) {
if (e.RowIndex < 3) {
e.Cancel = true;
}
}
private void dataGridView3_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) {
if (e.Row.Index < 3) {
e.Cancel = true;
}
... |
539,011 | <p>I have a page that highly depends on a IList (in ActionResult "MyEvents") that I pass in ViewData. Something like that: <strong>ViewData["events"] = listOfEvents;</strong> and in the end, I just <strong>return View();</strong></p>
<p>And in my View, I take this ViewData["events"] and do a foreach in it so I can ite... | [
{
"answer_id": 539038,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 1,
"selected": false,
"text": "<p>You could use partial rendering or you could have jquery select the element from the return value.</p>\n\n<pre><code>$... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60286/"
] | I have a page that highly depends on a IList (in ActionResult "MyEvents") that I pass in ViewData. Something like that: **ViewData["events"] = listOfEvents;** and in the end, I just **return View();**
And in my View, I take this ViewData["events"] and do a foreach in it so I can iterate through its contents.
But, thi... | Look to the load function in jQuery(<http://docs.jquery.com/Ajax/load>). Call your controller with load and then inject the result into your html document.
```
$("myDiv").load("/Controller/Action");
```
Your ViewData will be parsed on the server side. Instead of returning View(), return a PartialView() pointing to a... |
539,029 | <p>Thanks for the response. Here's the problem....the Oildatasetstatusid's (5-11) are mapped to labid=4. Labid=4 has input data for multiple customers, so the update cannot be performed based on oildatasetstatusid. The updates have to be based on samplepointid. That's why 3 tables are being used.</p>
<p>I am among the... | [
{
"answer_id": 539074,
"author": "notnot",
"author_id": 65184,
"author_profile": "https://Stackoverflow.com/users/65184",
"pm_score": 0,
"selected": false,
"text": "<pre><code>update Oildatasetstatus\nset Oildatasetstatusid = 16\nwhere Oildatasetstatusid = 5\n</code></pre>\n\n<p>-- and ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59097/"
] | Thanks for the response. Here's the problem....the Oildatasetstatusid's (5-11) are mapped to labid=4. Labid=4 has input data for multiple customers, so the update cannot be performed based on oildatasetstatusid. The updates have to be based on samplepointid. That's why 3 tables are being used.
I am among the SQL ignor... | >
> I want to generate one list using information from three different tables
>
>
>
The schema you've posted has no actual information in the samplepoint table, so it'd actually just be information from two tables. Essentially I'm guessing you simply want to join the ‘oillabid’ and ‘samplepointid’ values from ‘oil... |
539,066 | <p>Currently, I'm trying to get a method in Python to return a list of zero, one, or two strings to plug into a string formatter, and then pass them to the string method. My code looks something like this:</p>
<pre><code>class PairEvaluator(HandEvaluator):
def returnArbitrary(self):
return ('ace', 'king')
pe = ... | [
{
"answer_id": 539102,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 1,
"selected": false,
"text": "<p>This attempts to use \"cards\" as single format input to print, not the contents of cards.</p>\n\n<p>Try something l... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | Currently, I'm trying to get a method in Python to return a list of zero, one, or two strings to plug into a string formatter, and then pass them to the string method. My code looks something like this:
```
class PairEvaluator(HandEvaluator):
def returnArbitrary(self):
return ('ace', 'king')
pe = PairEvaluator(... | ```
print('Two pair, {0}s and {1}s'.format(*cards))
```
You are missing only the star :D |
539,075 | <p>How do I limit the loop below to 50 so it stops when it reaches the 51st item?</p>
<pre><code>foreach (ListViewItem lvi in listView.Items)
{
}
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 539085,
"author": "Chuck Conway",
"author_id": 17360,
"author_profile": "https://Stackoverflow.com/users/17360",
"pm_score": 3,
"selected": false,
"text": "<p>Use a for loop.</p>\n\n<pre><code>for(int index = 0; index < collection.Count && index < 50; index++... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I limit the loop below to 50 so it stops when it reaches the 51st item?
```
foreach (ListViewItem lvi in listView.Items)
{
}
```
Thanks | ```
foreach (ListViewItem lvi in listView.Items) {
// do code here
if (listView.Items.IndexOf(lvi) == 49)
break;
}
```
OR since it is a list view item
```
foreach (ListViewItem lvi in listView.Items) {
// do code here
if (lvi.Index == 49) break;
}
```
Using Linq as Per [LukeDuff](https://stackoverflow.... |
539,116 | <p>My application is running on App Engine and is implemented using <a href="http://werkzeug.pocoo.org/" rel="nofollow noreferrer">Werkzeug</a> and <a href="http://jinja.pocoo.org/2/" rel="nofollow noreferrer">Jinja2</a>. I'd like to have something functionally equivalent of Django's own context processor: a callable t... | [
{
"answer_id": 539427,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 3,
"selected": true,
"text": "<p>One way of achieving this is through late-bound <a href=\"http://jinja.pocoo.org/2/documentation/api#jinja2.Environme... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12138/"
] | My application is running on App Engine and is implemented using [Werkzeug](http://werkzeug.pocoo.org/) and [Jinja2](http://jinja.pocoo.org/2/). I'd like to have something functionally equivalent of Django's own context processor: a callable that takes a request and adds something to the template context. I already hav... | One way of achieving this is through late-bound [template globals](http://jinja.pocoo.org/2/documentation/api#jinja2.Environment.globals) using the [thread-local proxy](http://werkzeug.pocoo.org/documentation/local) in Werkzeug.
A simple example that puts the request into the the template globals:
```
from werkzeug i... |
539,132 | <p>I've been assigned to make a custom grid control in C# with windows forms. One thing I'm unsure of is how to handle showing a blinking cursor (caret) to indicate where cell editing is taking place and the next character will be shown. </p>
<p>Does anyone know how this is done with the standard textbox? Is there a s... | [
{
"answer_id": 539166,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 0,
"selected": false,
"text": "<p>The MSDN reference about <a href=\"http://msdn.microsoft.com/en-us/library/ms646968(VS.85).aspx\" rel=\"nofollow norefer... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33724/"
] | I've been assigned to make a custom grid control in C# with windows forms. One thing I'm unsure of is how to handle showing a blinking cursor (caret) to indicate where cell editing is taking place and the next character will be shown.
Does anyone know how this is done with the standard textbox? Is there a standard fr... | Here you go:
```
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class MyWidget : Control {
public MyWidget() {
this.BackColor = Color.Yellow;
}
protected override void OnGotFocus(EventArgs e) {
CreateCaret(this.Handle, IntPtr.Zero, 2, this.He... |
539,133 | <p>In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at <code>os.access</code> but it gives false results.</p>
<pre><code>>>> os.access('C:\haveaccess', os.R_OK)
False
>>> os.access(r'C:\haveaccess', os.R_OK)
True
>>> os.acce... | [
{
"answer_id": 539159,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 4,
"selected": true,
"text": "<p>It can be complicated to check for permissions in Windows (beware of issues in Vista with UAC, for example! -- see this <a hre... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44133/"
] | In Python on Windows, is there a way to determine if a user has permission to access a directory? I've taken a look at `os.access` but it gives false results.
```
>>> os.access('C:\haveaccess', os.R_OK)
False
>>> os.access(r'C:\haveaccess', os.R_OK)
True
>>> os.access('C:\donthaveaccess', os.R_OK)
False
>>> os.access(... | It can be complicated to check for permissions in Windows (beware of issues in Vista with UAC, for example! -- see this [related question](https://stackoverflow.com/questions/450210/how-to-check-if-a-file-can-be-created-inside-given-directory-on-ms-xp-vista)).
Are you talking about simple read access, i.e. reading the... |
539,143 | <p>So I'm writing some XML generating code, and found that the following attribute value was screwing up the XML formatting:</p>
<pre><code>"Jim/Bob"
</code></pre>
<p>So I looked into the XML Entities used as escape sequences and every list I saw did not include one for the forward slash. Am I missing something obvi... | [
{
"answer_id": 539158,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 7,
"selected": true,
"text": "<p>The forward slash is valid as is and does not need further encoding.</p>\n\n<p>The only reserved characters are:</p>... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48923/"
] | So I'm writing some XML generating code, and found that the following attribute value was screwing up the XML formatting:
```
"Jim/Bob"
```
So I looked into the XML Entities used as escape sequences and every list I saw did not include one for the forward slash. Am I missing something obvious here? Seems like the so... | The forward slash is valid as is and does not need further encoding.
The only reserved characters are:
```
>
<
&
%
```
For even more XML entities - <http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references> |
539,145 | <p>I have two tables, one an import table, the other a FK constraint on the table the import table will eventually be put into. In the import table a user can provide a list of semicolon separated values that correspond to values in the 2nd table. </p>
<p>So we're looking at something like this:</p>
<pre><code>TABLE ... | [
{
"answer_id": 539380,
"author": "Adam Ralph",
"author_id": 49241,
"author_profile": "https://Stackoverflow.com/users/49241",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps inserting those composite values into 'TABLE 1' may have seemed like the most convenient solution at one tim... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34133/"
] | I have two tables, one an import table, the other a FK constraint on the table the import table will eventually be put into. In the import table a user can provide a list of semicolon separated values that correspond to values in the 2nd table.
So we're looking at something like this:
```
TABLE 1
ID | Column1
1 | A... | Seems to me you could pass ID & Column1 values from Table1 to a Table-Valued function (or a temp table in-line) which would parse the ;-delimited list, returning individual values per record.
Here are a couple options:
* [T-SQL: Parse a delimited string](http://pietschsoft.com/post/2006/02/T-SQL-Parse-a-delimited-st... |
539,153 | <p>I'm not very experienced in ASP.Net, as I work mostly with PHP.
I'm trying this, but it doesn't work:</p>
<pre><code><asp:TextBox runat="server" ID="txtAnswer"
TextMode='<%# IIf(DataBinder.Eval(Container.DataItem, "DoLargeInput"), "MultiLine", "SingleLine" )%>' Text=''></asp:TextBox>
</code></p... | [
{
"answer_id": 539194,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 2,
"selected": true,
"text": "<p>Try:-</p>\n\n<pre><code>IIf(DataBinder.Eval(Container.DataItem, \"DoLargeInput\"), TextBoxMode.MultiLine, TextBoxM... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539153",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26192/"
] | I'm not very experienced in ASP.Net, as I work mostly with PHP.
I'm trying this, but it doesn't work:
```
<asp:TextBox runat="server" ID="txtAnswer"
TextMode='<%# IIf(DataBinder.Eval(Container.DataItem, "DoLargeInput"), "MultiLine", "SingleLine" )%>' Text=''></asp:TextBox>
```
DoLargeInput is a boolean.
Why doe... | Try:-
```
IIf(DataBinder.Eval(Container.DataItem, "DoLargeInput"), TextBoxMode.MultiLine, TextBoxMode.SingleLine
```
It the parse that will convert TextMode="MultiLine" approriately for you. At the point this binding code happens the parseing is over, you need to specify the value as you would in code. |
539,155 | <p>I've got a 'Task' table with the following columns (the TaskOrder is for ordering the children within the scope of the parent, not the entire table):</p>
<pre>
TaskId
ParentTaskId
TaskName
TaskOrder
</pre>
<p>I've got this CTE query to return all the rows:</p>
<pre><code>with tasks (TaskId, ParentTaskId, [Name]) ... | [
{
"answer_id": 539211,
"author": "Mark Westley",
"author_id": 65325,
"author_profile": "https://Stackoverflow.com/users/65325",
"pm_score": 2,
"selected": false,
"text": "<p>One way you could do this is to add a hierarchy column that has all previous IDs in a list:</p>\n\n<pre><code>with... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14072/"
] | I've got a 'Task' table with the following columns (the TaskOrder is for ordering the children within the scope of the parent, not the entire table):
```
TaskId
ParentTaskId
TaskName
TaskOrder
```
I've got this CTE query to return all the rows:
```
with tasks (TaskId, ParentTaskId, [Name]) as
(
select parentTa... | Solved the problem using a variation of [Mark's method](https://stackoverflow.com/questions/539155/ordering-recursive-query-results-in-sql-2005/539211#539211), but I'm not retaining the node path in every node, so I can more easily move them around the tree. Instead I changed my 'OrderBy' column from an int to varchar(... |
539,157 | <p>Trying to implement asp.net passwordrecovery control.</p>
<p>I want to catch newly generated password before sending to user and add some custom logic to it and then send the mail. there is only one event sendingmail event.</p>
<p>How can I catch it ?</p>
| [
{
"answer_id": 539176,
"author": "alex",
"author_id": 19268,
"author_profile": "https://Stackoverflow.com/users/19268",
"pm_score": 1,
"selected": false,
"text": "<p>The ValidatingPassword event is raised when the CreateUser method, the ChangePassword method, or the ResetPassword method ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51151/"
] | Trying to implement asp.net passwordrecovery control.
I want to catch newly generated password before sending to user and add some custom logic to it and then send the mail. there is only one event sendingmail event.
How can I catch it ? | You could handle the SendingMail event, generate a new password using ResetPassword, and then update the body of the email with your new password and whatever else you wanted to put in there.
```
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
// grab the user.
MembershipU... |
539,171 | <p>Does anyone know a clean way of adding events to Session's OnStart and OnEnd events using an HttpModule (without touching the Global.asax file)?</p>
| [
{
"answer_id": 539252,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 3,
"selected": true,
"text": "<pre><code>public void Init(HttpApplication app)\n{\n var ssm = app.Modules[\"Session\"] as SessionStateModule;\n ssm.St... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21966/"
] | Does anyone know a clean way of adding events to Session's OnStart and OnEnd events using an HttpModule (without touching the Global.asax file)? | ```
public void Init(HttpApplication app)
{
var ssm = app.Modules["Session"] as SessionStateModule;
ssm.Start += Foo;
ssm.End += Bar;
}
``` |
539,174 | <p>This problem stems from not being able to get my TextBlock to wrap. Basically as a last-ditch attempt I am setting MaxWidth on my container grid's columns. I was surprised to find that my child label and textbox still do whatever they want (bad children, BAD) and are not limited by my grid column's MaxWidth="200".... | [
{
"answer_id": 539892,
"author": "Nidonocu",
"author_id": 483,
"author_profile": "https://Stackoverflow.com/users/483",
"pm_score": 3,
"selected": true,
"text": "<p>I've tried to replicate your problem by pasting everything between your Grid elements in to Kaxaml but everything wraps as ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65311/"
] | This problem stems from not being able to get my TextBlock to wrap. Basically as a last-ditch attempt I am setting MaxWidth on my container grid's columns. I was surprised to find that my child label and textbox still do whatever they want (bad children, BAD) and are not limited by my grid column's MaxWidth="200".
Wha... | I've tried to replicate your problem by pasting everything between your Grid elements in to Kaxaml but everything wraps as you would expect it to. (I inserted regular strings where you were doing bindings and removed the Label style).
It could be that the problem is higher up the tree.
I'd suggest pasting chunks in t... |
539,198 | <p>I need to insert UIElements into a Grid that does not get generated until runtime. More specifically, I need to add UIElements to the RowDefinitions I create after I determine how many elements need to be displayed. Is there a way to contorl the Grid.Row and Grid.Column and Grid.RowSpan like in XAML for objects in C... | [
{
"answer_id": 539215,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 0,
"selected": false,
"text": "<p>I have never used this stuff, but shouldn't you be adding the Button to the RowDefinitions, instead of the Children? (j... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41138/"
] | I need to insert UIElements into a Grid that does not get generated until runtime. More specifically, I need to add UIElements to the RowDefinitions I create after I determine how many elements need to be displayed. Is there a way to contorl the Grid.Row and Grid.Column and Grid.RowSpan like in XAML for objects in C#? ... | Apart from the Grid not really being the right tool for the job (a ListView would be) you need to tell the Button which row it belongs to.
```
public void BuildGrid()
{
LayoutRoot.ShowGridLines = true;
int rowIndex = 0;
foreach (string s in _names)
{
LayoutRoot.RowDefinitions.Add(new RowDefinit... |
539,199 | <p>I'm needing to get a list with all the revisions and files modified in each one, and by who.</p>
<p>Is that possible?</p>
<p>I need to know who user did the most changes to the repo and what changes.</p>
| [
{
"answer_id": 539201,
"author": "MiniQuark",
"author_id": 38626,
"author_profile": "https://Stackoverflow.com/users/38626",
"pm_score": 2,
"selected": false,
"text": "<p>Take a look at svn log and svn blame.</p>\n"
},
{
"answer_id": 539206,
"author": "M4N",
"author_id": ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42565/"
] | I'm needing to get a list with all the revisions and files modified in each one, and by who.
Is that possible?
I need to know who user did the most changes to the repo and what changes. | In the root of the working copy, type
```
svn log -v
```
This will give you everything. If this is too much then use `--limit`:
```
svn log -v --limit 100
```
See the [log command](http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.log.html) in the [SVN Book](http://svnbook.red-bean.com/). |
539,200 | <p>I'm trying to write part of a J2ME application and I'm responsible for reading NMEA data from a GPS device attached via bluetooth (to a Dell Axim X51 PDA).</p>
<p>I've paired the gps device with the PDA and I can run the sample program that comes with the gps device and it succesfully streams NMEA strings. </p>
<p... | [
{
"answer_id": 539201,
"author": "MiniQuark",
"author_id": 38626,
"author_profile": "https://Stackoverflow.com/users/38626",
"pm_score": 2,
"selected": false,
"text": "<p>Take a look at svn log and svn blame.</p>\n"
},
{
"answer_id": 539206,
"author": "M4N",
"author_id": ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52116/"
] | I'm trying to write part of a J2ME application and I'm responsible for reading NMEA data from a GPS device attached via bluetooth (to a Dell Axim X51 PDA).
I've paired the gps device with the PDA and I can run the sample program that comes with the gps device and it succesfully streams NMEA strings.
In system settin... | In the root of the working copy, type
```
svn log -v
```
This will give you everything. If this is too much then use `--limit`:
```
svn log -v --limit 100
```
See the [log command](http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.log.html) in the [SVN Book](http://svnbook.red-bean.com/). |
539,224 | <p>Basically, i want my object back...</p>
<p>I have an Email object.</p>
<pre><code>public class Email{
public string emailAddress;
public bool primary;
public int contactPoint;
public int databasePrimaryKey;
public Email(){}
}
</code></pre>
<p>In my usercontrol, i a list of Email objects.</p>
... | [
{
"answer_id": 539253,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 3,
"selected": false,
"text": "<p>ASP.NET Databinding is a one-way operation in terms of object manipulation. However, the DataSource property will contain a... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45194/"
] | Basically, i want my object back...
I have an Email object.
```
public class Email{
public string emailAddress;
public bool primary;
public int contactPoint;
public int databasePrimaryKey;
public Email(){}
}
```
In my usercontrol, i a list of Email objects.
```
public List<Email> EmailCollecti... | Well I ended up looping through my List EmailCollection, which was saved into the ViewState.
So in the page, a Save button is clicked, when the event is caught, I loop through my List Collection and grab the row from the GridView by index.
On the GridViewRow I have to use a GridView1.Rows[i].Cells[j].FindControl("my... |
539,227 | <p>This is probably a stupid question, but my brain is just cooked enough I think I'm going to use one of my "lifelines" to see if I can get some help from my stack overflow friends. ;)</p>
<p>I need to delete all occurrences of a particular component type on my main form (some of them are inside panels or tabsheets, ... | [
{
"answer_id": 539265,
"author": "jrodenhi",
"author_id": 25315,
"author_profile": "https://Stackoverflow.com/users/25315",
"pm_score": 3,
"selected": false,
"text": "<p>Start at the top and work backwards.</p>\n\n<p>viz:</p>\n\n<pre><code>for i := frmMain.ComponentCount - 1 downto 0 do\... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32303/"
] | This is probably a stupid question, but my brain is just cooked enough I think I'm going to use one of my "lifelines" to see if I can get some help from my stack overflow friends. ;)
I need to delete all occurrences of a particular component type on my main form (some of them are inside panels or tabsheets, but all on... | You're nearly right. Your loop should look like
```
for i := frmMain.ComponentCount - 1 downto 0 do
begin
if frmMain.Components[i] is TMyClass then
frmMain.Components[i].Free;
end;
```
This way the call to the function "frmMain.ComponentCount" gets done at the beginning and not again.
You should also call Fre... |
539,231 | <p>I use ctags with my Vim and I rely heavily on C-] and C-T to tag back and froth between various functions in my project.</p>
<p>But if the function is in a different file, I'd like Vim to automatically open it in a new tab instead of the current tab. If I pop my tag stack using the C-T, I'd like it go back to the o... | [
{
"answer_id": 539268,
"author": "mikelikespie",
"author_id": 64941,
"author_profile": "https://Stackoverflow.com/users/64941",
"pm_score": 0,
"selected": false,
"text": "<p>So, this is a feature I would like to see as well.</p>\n\n<p>I'm not sure if it's possible.</p>\n\n<p>What I usual... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8825/"
] | I use ctags with my Vim and I rely heavily on C-] and C-T to tag back and froth between various functions in my project.
But if the function is in a different file, I'd like Vim to automatically open it in a new tab instead of the current tab. If I pop my tag stack using the C-T, I'd like it go back to the original ta... | ```
nmap <C-Enter> <C-w><C-]><C-w>T
```
Does this help ? You could probably figure out something similar for the way back.
---
Well, we need to decide what would be the wanted behaviour. We can go back to the original tab (not sure how, still investigating) but then the above given mapping is gonna open a new tab n... |
539,248 | <p>Any suggestions on how one could go about setting up a build system that would compile one or two libraries against a couple of different platforms/targets.</p>
<p>The main project is in Visual Studio.</p>
<p>For example, I have a library: </p>
<pre><code>nav.lib
</code></pre>
<p>It compiles on Windows and Linux... | [
{
"answer_id": 539915,
"author": "galuvian",
"author_id": 39755,
"author_profile": "https://Stackoverflow.com/users/39755",
"pm_score": 3,
"selected": true,
"text": "<p>This is what \"Solution Configurations\" are for. By default Visual Studio creates Release and Debug configurations, b... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29505/"
] | Any suggestions on how one could go about setting up a build system that would compile one or two libraries against a couple of different platforms/targets.
The main project is in Visual Studio.
For example, I have a library:
```
nav.lib
```
It compiles on Windows and Linux with a few tweaks.
The executable tha... | This is what "Solution Configurations" are for. By default Visual Studio creates Release and Debug configurations, but you can add your own custom configurations too. The Project options are different for each configuration, so just set your #define in the configuration that needs it.
When you are running your automat... |
539,251 | <p>The short version is: How do I learn the size (in bits) of an individual field of a c++ field?</p>
<p>To clarify, an example of the field I am talking about:</p>
<pre><code>struct Test {
unsigned field1 : 4; // takes up 4 bits
unsigned field2 : 8; // 8 bits
unsigned field3 : 1; // 1 bit
unsigned... | [
{
"answer_id": 539279,
"author": "Matt Davison",
"author_id": 1995476,
"author_profile": "https://Stackoverflow.com/users/1995476",
"pm_score": 1,
"selected": false,
"text": "<p>This is not possible</p>\n\n<p>Answer to comment:\nBecause the type is just an int, there is no 'bit' type. Th... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29703/"
] | The short version is: How do I learn the size (in bits) of an individual field of a c++ field?
To clarify, an example of the field I am talking about:
```
struct Test {
unsigned field1 : 4; // takes up 4 bits
unsigned field2 : 8; // 8 bits
unsigned field3 : 1; // 1 bit
unsigned field4 : 3; // 3 bi... | You can calculate the size at run time, fwiw, e.g.:
```
//instantiate
Test t;
//fill all bits in the field
t.field1 = ~0;
//extract to unsigned integer
unsigned int i = t.field1;
... TODO use contents of i to calculate the bit-width of the field ...
``` |
539,257 | <p>Does anybody have a known reliable way to create a video from a series of image files? Before you mod me down for not searching for the answer before posting the question, and before you fire off a simple message like "use FFMPEG," read the rest of this message.</p>
<p>I'm trying to create a video, it doesn't matt... | [
{
"answer_id": 539572,
"author": "U62",
"author_id": 47612,
"author_profile": "https://Stackoverflow.com/users/47612",
"pm_score": 1,
"selected": false,
"text": "<p>The handling of video on Windows (encoding and playback) is a real quagmire. And .NET isn't going to help you at all - you'... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56778/"
] | Does anybody have a known reliable way to create a video from a series of image files? Before you mod me down for not searching for the answer before posting the question, and before you fire off a simple message like "use FFMPEG," read the rest of this message.
I'm trying to create a video, it doesn't matter too much... | After working with it a while and taking a look at x264 and VideoLan, I went back to Splicer. It turns out that the cryptic error message was due to an error in my code.
It looks like Splicer will do what I want: programmatically create videos from a series of images.
Thanks to all who responded. |
539,284 | <p>I am trying to access 61616 in my iPhone app and the SCReachability code indicates that I have a valid network, but I time out trying to write to 61616. Does anyone know:</p>
<p>A. If the iPhone EDGE/3G network has a limited port range or isn't allowed to connect to this port?</p>
<p>B. How I can check explicitly ... | [
{
"answer_id": 540608,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>If your iPhone is connected over EDGE/Mobile, it might be behind a NAT gateway thus you being unable to contact it. At leas... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39932/"
] | I am trying to access 61616 in my iPhone app and the SCReachability code indicates that I have a valid network, but I time out trying to write to 61616. Does anyone know:
A. If the iPhone EDGE/3G network has a limited port range or isn't allowed to connect to this port?
B. How I can check explicitly for access to thi... | The SCNetworkReachability API only checks whether the address can be routed to. Quoting the documentation:
>
> "Reachability" reflects whether a data
> packet, sent by an application into
> the network stack, can leave the local
> computer. Note that reachability does
> not guarantee that the data packet
> will ... |
539,287 | <p>I've got an <code>IList<DerivedClass></code> that I want to cast to <code>ICollection<BaseClass></code> but when I attempt an explicit cast, I get <code>null</code>. Is it possible to do this without creating and populating a new collection?</p>
<p><strong>Edit:</strong>
Since I only want to read from ... | [
{
"answer_id": 539326,
"author": "Doug",
"author_id": 10031,
"author_profile": "https://Stackoverflow.com/users/10031",
"pm_score": 4,
"selected": true,
"text": "<p>The short answer is \"No.\" You would need to create a new collection with the new BaseClass type and populate it.</p>\n\n... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1807/"
] | I've got an `IList<DerivedClass>` that I want to cast to `ICollection<BaseClass>` but when I attempt an explicit cast, I get `null`. Is it possible to do this without creating and populating a new collection?
**Edit:**
Since I only want to read from the collection, I switched to using a generic method:
```
public voi... | The short answer is "No." You would need to create a new collection with the new BaseClass type and populate it.
If you think about it, it makes sense. If you could simply "cast" your collection to BaseClass, you could then stick something that was of type "BaseClass" into it, thereby forcing a simple BaseClass object... |
539,294 | <p>I'm trying to enter some UTF-8 characters into a LaTeX file in <a href="http://en.wikipedia.org/wiki/TextMate" rel="noreferrer">TextMate</a> (which says its default encoding is UTF-8), but LaTeX doesn't seem to understand them.</p>
<p>Running <code>cat my_file.tex</code> shows the characters properly in Terminal. R... | [
{
"answer_id": 539323,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 6,
"selected": true,
"text": "<p>The <code>@</code> means that the file has extended file attributes associated with it. You can query them using the <... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I'm trying to enter some UTF-8 characters into a LaTeX file in [TextMate](http://en.wikipedia.org/wiki/TextMate) (which says its default encoding is UTF-8), but LaTeX doesn't seem to understand them.
Running `cat my_file.tex` shows the characters properly in Terminal. Running `ls -al` shows something I've never seen b... | The `@` means that the file has extended file attributes associated with it. You can query them using the `getxattr()` function.
There's no definite way to detect the encoding of a file. Read [this](https://stackoverflow.com/questions/90838/how-can-i-detect-the-encodingcodepage-of-a-text-file) answer, it explains why.... |
539,298 | <p>Here's what I'm trying to do:</p>
<pre><code>public void init(ServletConfig config) {
// ...
URL url = new URL("http://myhost:port/path/to/otherservlet");
// ... do stuff with contents of url
}
</code></pre>
<p>This works fine, but myhost and port are hardcoded and I want to avoid that. I want</p>
<pr... | [
{
"answer_id": 539322,
"author": "airportyh",
"author_id": 5304,
"author_profile": "https://Stackoverflow.com/users/5304",
"pm_score": 2,
"selected": false,
"text": "<p>If possible, I think the better approach is to refactor the code for the other servlet into a class somewhere that can ... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28604/"
] | Here's what I'm trying to do:
```
public void init(ServletConfig config) {
// ...
URL url = new URL("http://myhost:port/path/to/otherservlet");
// ... do stuff with contents of url
}
```
This works fine, but myhost and port are hardcoded and I want to avoid that. I want
```
URL url = new URL("/path/to/o... | I wouldn't be surprised to find that it can't be done. I think toby's answer (split the code out into a common class) is the best approach, but if that's really not possible, try encoding the host and port to be used for local requests as context parameters in the server's `web.xml` file:
```
<context-param>
<para... |
539,309 | <p>Consider:</p>
<pre><code><table border="1" width="100%" ID="Table2">
<tr>
<td>100</td>
</tr>
</table>
</code></pre>
<p>This code still leaves an "inch" of space on both sides of the table. I am trying to get the table to span... | [
{
"answer_id": 539316,
"author": "Tom Anderson",
"author_id": 13502,
"author_profile": "https://Stackoverflow.com/users/13502",
"pm_score": 3,
"selected": false,
"text": "<p>You need to set the margin of the body to 0 for the table to stretch the full width. Alternatively, you can set th... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52256/"
] | Consider:
```
<table border="1" width="100%" ID="Table2">
<tr>
<td>100</td>
</tr>
</table>
```
This code still leaves an "inch" of space on both sides of the table. I am trying to get the table to span the entire width of the page. | Try (in your <head> section, or existing CSS definitions)...
```
<style>
body {
margin: 0;
padding: 0;
}
</style>
``` |
539,311 | <p>I am facing the problem of having several integers, and I have to generate one using them. For example.</p>
<pre><code>Int 1: 14
Int 2: 4
Int 3: 8
Int 4: 4
Hash Sum: 43
</code></pre>
<p>I have some restriction in the values, the maximum value that and attribute can have is 30, the addition of all of them is alway... | [
{
"answer_id": 539325,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 0,
"selected": false,
"text": "<p>You would need to define what you mean by \"similar\". Hashes are generally designed to create unique results from u... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I am facing the problem of having several integers, and I have to generate one using them. For example.
```
Int 1: 14
Int 2: 4
Int 3: 8
Int 4: 4
Hash Sum: 43
```
I have some restriction in the values, the maximum value that and attribute can have is 30, the addition of all of them is always 30. And the attributes a... | Given the inputs a, b, c, and d, each ranging in value from 0 to 30 (5 bits), the following will produce an number in the range of 0 to 255 (8 bits).
```
bucket = ((a & 0x18) << 3) | ((b & 0x18) << 1) | ((c & 0x18) >> 1) | ((d & 0x18) >> 3)
```
Whether the general approach is appropriate depends on how the question ... |
539,328 | <p>I'm creating a SharePoint feature which will be used to deploy some content types (and their custom columns/ fields) into a a new SharePoint site.</p>
<p>I've used an external tool to generate the CAML for the content types (<a href="http://www.andrewconnell.com/blog/articles/MossStsadmWcmCommands.aspx" rel="nofoll... | [
{
"answer_id": 539543,
"author": "Jason",
"author_id": 10639,
"author_profile": "https://Stackoverflow.com/users/10639",
"pm_score": 0,
"selected": false,
"text": "<p>By custom columns do you meant custom fields? Which Content Type page are you trying to view? The list of all site cont... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11388/"
] | I'm creating a SharePoint feature which will be used to deploy some content types (and their custom columns/ fields) into a a new SharePoint site.
I've used an external tool to generate the CAML for the content types ([Andrew Connell's custom STSADM commands](http://www.andrewconnell.com/blog/articles/MossStsadmWcmCom... | I've seen this before, the XML generated does not contain the XML Namespace:
Also note that this tool doesn't create XML that is 100% correct for use in a Feature.
Bad-XML:
```
<XmlDocument>
<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">
<Display>ListForm</Display>
<Edit>ListForm... |
539,348 | <p>I have an ASP.Net Web Forms application in which I'm using forms-based authentication with Membership and Role providers, which is fine for authenticating and controlling access to directories and/or files. Now I find myself needing to control read, write and delete access on individual entity instances, for example... | [
{
"answer_id": 539383,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 4,
"selected": true,
"text": "<p>The easiest way is to demand that the user is a member of the role(s) required for the method in question with <a href=\"htt... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4296/"
] | I have an ASP.Net Web Forms application in which I'm using forms-based authentication with Membership and Role providers, which is fine for authenticating and controlling access to directories and/or files. Now I find myself needing to control read, write and delete access on individual entity instances, for example be... | The easiest way is to demand that the user is a member of the role(s) required for the method in question with [`PrincipalPermissionAttribute`](http://msdn.microsoft.com/en-us/library/system.security.permissions.principalpermissionattribute.aspx).
```
[PrincipalPermission(SecurityAction.Demand, Role="Supervisor")]
[Pr... |
539,358 | <p>I have a solution in VS 2008 with 2 projects in it. One is a DLL written in C++ and the other is a simple C++ console application created from a blank project. I would like know how to call the functions in the DLL from the application.</p>
<p>Assume I am starting with a blank C++ project and that I want to call a ... | [
{
"answer_id": 539367,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 0,
"selected": false,
"text": "<p>Presuming you're talking about dynamic runtime loading of DLLs, you're looking for LoadLibrary and GetProAddress.... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46810/"
] | I have a solution in VS 2008 with 2 projects in it. One is a DLL written in C++ and the other is a simple C++ console application created from a blank project. I would like know how to call the functions in the DLL from the application.
Assume I am starting with a blank C++ project and that I want to call a function c... | There are many ways to do this but I think one of the easiest options is to link the application to the DLL at link time and then use a *definition file* to define the symbols to be exported from the DLL.
**CAVEAT:** The definition file approach works bests for *undecorated* symbol names. If you want to export decorat... |
539,374 | <p>I have this HTML</p>
<pre><code> <div id="navContainer">
<ul>
<li class="selected"><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
</ul>
</div>
</code></pre>
<p>And I want to change the top border of the li n... | [
{
"answer_id": 539377,
"author": "TomHastjarjanto",
"author_id": 53170,
"author_profile": "https://Stackoverflow.com/users/53170",
"pm_score": 3,
"selected": true,
"text": "<p>Why don't you just store it in the session? The session can have multiple backends like memcache or even a datab... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36036/"
] | I have this HTML
```
<div id="navContainer">
<ul>
<li class="selected"><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
</ul>
</div>
```
And I want to change the top border of the li next to the selected one (in this case 'Services'). I have this jQuery but it does not work.
```
$... | Why don't you just store it in the session? The session can have multiple backends like memcache or even a database. I think it is possible to deploy memcache locally so It wouldn't matter that much.
Another posibility is to use a file backend and store it on a RAM drive. But maybe there are some memory libs for ruby ... |
539,430 | <p>Is there any way to connect to an MS SQL Server database with python on linux using Windows Domain Credentials?</p>
<p>I can connect perfectly fine from my windows machine using Windows Credentials, but attempting to do the same from a linux python with pyodbs + freetds + unixodbc </p>
<pre><code>>>import py... | [
{
"answer_id": 539550,
"author": "Timbo",
"author_id": 20992,
"author_profile": "https://Stackoverflow.com/users/20992",
"pm_score": 0,
"selected": false,
"text": "<p>I don't believe you'll be able to log in to a windows domain account in this way. You need to set up a user in sql direct... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65348/"
] | Is there any way to connect to an MS SQL Server database with python on linux using Windows Domain Credentials?
I can connect perfectly fine from my windows machine using Windows Credentials, but attempting to do the same from a linux python with pyodbs + freetds + unixodbc
```
>>import pyodbc
>>conn = pyodbc.connec... | **As pointed out in one of the comments, this answer is quite stale by now. I regularly and routinely use GSSAPI to authenticate from Linux to SQL Server 2008 R2 but mostly with the EasySoft ODBC manager and the (commercial) EasySoft ODBC SQL Server driver.**
In early 2009, a colleague and I managed to connect to a SQ... |
539,431 | <p>I am using SQL Server 2005 and I have a XML Data Type column that stores xml fragments like so in one big table:</p>
<pre><code>row 1 ..... <Order date='2009-02-11' customerID='4' />
row 2...... <OrderItem OrderID='6' ItemID='477' quantity='1' />
</code></pre>
<p>I would like to create an XML using T-S... | [
{
"answer_id": 539435,
"author": "tsilb",
"author_id": 11112,
"author_profile": "https://Stackoverflow.com/users/11112",
"pm_score": 0,
"selected": false,
"text": "<p>Create a UDF that will call XmlDocument.LoadXml(). The DocumentElement (root) is just any other XmlNodeList.</p>\n"
},
... | 2009/02/11 | [
"https://Stackoverflow.com/questions/539431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100768/"
] | I am using SQL Server 2005 and I have a XML Data Type column that stores xml fragments like so in one big table:
```
row 1 ..... <Order date='2009-02-11' customerID='4' />
row 2...... <OrderItem OrderID='6' ItemID='477' quantity='1' />
```
I would like to create an XML using T-SQL that looks like this from these nod... | This is a more straight-forward method using XML DML in SQL Server 2005/2008 although there is a little kludginess to it. Since you can't insert sql:variable directly into XML using the .modify(insert) method of the XML data type, the trick is you have to cast the XML fragments as character strings, concatenate them, t... |
539,436 | <p>In C#, when I have an interface and several concrete implementations, can I cast the interface to a concrete type or is concrete type cast to interface?</p>
<p>What are the rules in this case?</p>
| [
{
"answer_id": 539449,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 1,
"selected": false,
"text": "<p>Both are valid, considering it's a logical cast. Many times, your interface consumers don't have access to the concrete cla... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | In C#, when I have an interface and several concrete implementations, can I cast the interface to a concrete type or is concrete type cast to interface?
What are the rules in this case? | Both directions are allowed in Java and C#. Downcasting needs an explicit cast and may throw an Exception if the object is not of the correct type. Upcasting, however, needs no explicit cast and is always safe to do.
That is, assuming you have `public interface Animal` and two implementations of this `interface`, `Cat... |
539,459 | <p>I'm looking to add functionality to all the simple types in C++. </p>
<p>I want to write a single templated class that takes as a template parameter the type to be encapsulated and then has all the operators defined so that the encapsulated class works exactly as the simple type it encapsulates.</p>
<p>Something l... | [
{
"answer_id": 539469,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 2,
"selected": false,
"text": "<p>It's pretty simple, if tedious, - you just have to implement all the operators supported by the standard types and w... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking to add functionality to all the simple types in C++.
I want to write a single templated class that takes as a template parameter the type to be encapsulated and then has all the operators defined so that the encapsulated class works exactly as the simple type it encapsulates.
Something like this:
```
te... | It's pretty simple, if tedious, - you just have to implement all the operators supported by the standard types and where the cast operator is not sufficient.
I have to ask though, why on earth are you trying to do this? |
539,463 | <p>I'm looking at some code that converts user names to lower case, before storing them. I'm 90% sure this is ok, but are there systems out there that actually require case sensitivity on the user names (specifically in the health industry)?</p>
<p><strong>Note:</strong> my particular code is not at the point of entry... | [
{
"answer_id": 539472,
"author": "BC.",
"author_id": 54838,
"author_profile": "https://Stackoverflow.com/users/54838",
"pm_score": 0,
"selected": false,
"text": "<p>If your only goal is differentiating one user from another, it seems logical that you would want more than case to be a fac... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37193/"
] | I'm looking at some code that converts user names to lower case, before storing them. I'm 90% sure this is ok, but are there systems out there that actually require case sensitivity on the user names (specifically in the health industry)?
**Note:** my particular code is not at the point of entry. We are taking user na... | unix logins are case sensitive...
Are there any other systems that do this? |
539,500 | <p>I find that randomly I get a EXC_BAD_ACCESS error on the iPhone when updating the status. This occurs pretty randomly.</p>
<p>Anyone have any idea to how this make be fixed?</p>
<pre><code>#import "TwitterViewController.h"
NSString *_testUID = nil;
NSString *sImageName;
@implementation TwitterViewController
//T... | [
{
"answer_id": 539569,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 0,
"selected": false,
"text": "<p>Anytime you have an EXC_BAD_ACCESS error, it's always a retain/release problem. Your code also has at least one leak (lo... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53677/"
] | I find that randomly I get a EXC\_BAD\_ACCESS error on the iPhone when updating the status. This occurs pretty randomly.
Anyone have any idea to how this make be fixed?
```
#import "TwitterViewController.h"
NSString *_testUID = nil;
NSString *sImageName;
@implementation TwitterViewController
//Turns NSLogs into co... | You have a few leaks (twitterEngine (you are retaining it when alloc/init does the job fine) and arrayEmotes (never gets released) to name the two I spotted right away), and you could have another issue related to sImageName when you send the update (notice how it isn't defined on a scope other than inside the switch s... |
539,503 | <p>My company is developing an application that receives data from another company via TCP sockets and xml messages. This is delivered to a single gateway application which then broadcasts it to multiple copies of the same internal application on various machines in our organisation.</p>
<p>WCF was chosen as the tec... | [
{
"answer_id": 539872,
"author": "Andy White",
"author_id": 60096,
"author_profile": "https://Stackoverflow.com/users/60096",
"pm_score": 0,
"selected": false,
"text": "<p>I hope I understood this right. I think it might make sense to have your gateway app handle all the deserialization... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5691/"
] | My company is developing an application that receives data from another company via TCP sockets and xml messages. This is delivered to a single gateway application which then broadcasts it to multiple copies of the same internal application on various machines in our organisation.
WCF was chosen as the technology to h... | I recently asked a couple of questions around this area: [XML vs Objects](https://stackoverflow.com/questions/368521/api-design-expose-xml-or-objects) and [XML vs Objects #2](https://stackoverflow.com/questions/375548/api-design-expose-xml-or-objects-2). You'll find the answers to those questions interesting.
For our ... |
539,504 | <p>The client I am working with has a frameset like so...</p>
<pre><code><frameset rows="100,*, 0">
<frame name="theFrame" id="theFrame" src="blah.html" >
<frame name="theSecondFrame" id="theSecondFrame" src="foo.html" >
<frame name="importantFrame" id="importantFrame" src="myFrame.html" >... | [
{
"answer_id": 548259,
"author": "Andrew M",
"author_id": 66293,
"author_profile": "https://Stackoverflow.com/users/66293",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not certain about the block plugin, but can't you get hold of the relevant frame and manipulate it using the \"fra... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40825/"
] | The client I am working with has a frameset like so...
```
<frameset rows="100,*, 0">
<frame name="theFrame" id="theFrame" src="blah.html" >
<frame name="theSecondFrame" id="theSecondFrame" src="foo.html" >
<frame name="importantFrame" id="importantFrame" src="myFrame.html" >
</frameset>
```
When a certain act... | The `jQuery` function, which you more commonly call with `$`, takes a second argument called context, which is "which DOM element of jQuery object should I do the search in". Most of the time you omit this argument, so the context defaults to the current HTML document. When your code is executing in the iframe, the doc... |
539,508 | <p>Is there any Perl module available for download throttling? I would like to download a certain file but limit the download rate to a specific number of KB/sec .</p>
| [
{
"answer_id": 539675,
"author": "Emil Sit",
"author_id": 55284,
"author_profile": "https://Stackoverflow.com/users/55284",
"pm_score": 2,
"selected": false,
"text": "<p>A technique not limited to Perl and not limited to a particular protocol is to use <a href=\"http://monkey.org/~marius... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | Is there any Perl module available for download throttling? I would like to download a certain file but limit the download rate to a specific number of KB/sec . | Looks like WWW::Curl and the CURLOPT\_MAX\_RECV\_SPEED\_LARGE option is
what you want:
```
#!/usr/bin/env perl
use strict;
use warnings;
use feature ':5.10';
use WWW::Curl::Easy;
# Setting the options
my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_HEADER,1);
$curl->setopt(CURLOPT_URL, 'http://www.google.com... |
539,511 | <p>I have this code:</p>
<blockquote>
<pre><code> if(!mysql_connect($host,$user,$passwd)){
die("Hoops, error! ".mysql_error());
}
</code></pre>
</blockquote>
<p>...no error from here.</p>
<pre><code> if(!mysql_select_db($db,$connect)){
... | [
{
"answer_id": 539518,
"author": "Zak",
"author_id": 2112692,
"author_profile": "https://Stackoverflow.com/users/2112692",
"pm_score": 1,
"selected": false,
"text": "<p>You might need database create permissions for the user attempting to create the database.\nThen you need to operate on... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46866/"
] | I have this code:
>
>
> ```
> if(!mysql_connect($host,$user,$passwd)){
> die("Hoops, error! ".mysql_error());
> }
>
> ```
>
>
...no error from here.
```
if(!mysql_select_db($db,$connect)){
$create_db = "CREATE DATABASE {$db}"... | Where are you saving the value returned by mysql\_connect()? Don't see it here. I assume $host, $user, $password and $db are properly set ahead of time. But you're passing a param to mysql\_select\_db that may not be properly set.
```
$connect = mysql_connect($host,$user,$passwd);
if (!$connect) {
die('Could not c... |
539,525 | <p>My software went in production some days ago and now I want to argue a bit about the database structure.</p>
<p>The software collects data about ships, currently 174 details for each ship, each detail can be a text value, a long text value, a number (of a specified length, with or without a specified number of deci... | [
{
"answer_id": 539559,
"author": "Joe Soul-bringer",
"author_id": 56279,
"author_profile": "https://Stackoverflow.com/users/56279",
"pm_score": 3,
"selected": true,
"text": "<p>I would <a href=\"http://www.refactoring.com/\" rel=\"nofollow noreferrer\">refactor</a> your code if:</p>\n\n<... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26754/"
] | My software went in production some days ago and now I want to argue a bit about the database structure.
The software collects data about ships, currently 174 details for each ship, each detail can be a text value, a long text value, a number (of a specified length, with or without a specified number of decimals), a d... | I would [refactor](http://www.refactoring.com/) your code if:
* Your customer complained
* You found something that didn't work
* You found a way that the code couldn't handle a
change you knew was going to happen
in the future.
You remembered to write unit tests that will allow you to refactor, right?
\*As far as ... |
539,536 | <p>I'm trying to compile code from an open source project, and I'm running into a problem where gcc claims that a particular line of code has an ambiguous interpretation. The problem involves a templated class and these two methods:</p>
<pre><code>template <class X>
class A {
public:
X& operator[] (int i... | [
{
"answer_id": 539560,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 2,
"selected": false,
"text": "<p>You could use braces:</p>\n\n<pre><code>A<B*> a;\nB* b = (a[i]); // Now it must evaluate the sub-expression a... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34101/"
] | I'm trying to compile code from an open source project, and I'm running into a problem where gcc claims that a particular line of code has an ambiguous interpretation. The problem involves a templated class and these two methods:
```
template <class X>
class A {
public:
X& operator[] (int i) { ... }
operator c... | The following code compiles for me with g++ 3.x. I don't think your analysis of the problem is correct, but in any case could you post the error message you are getting.
```
template <class X>
struct A {
X& operator[] (int i) { static X x; return x; }
operator const X* () { return 0; }
};
class B {};
int mai... |
539,548 | <p>I am downloading a file from another server. I wish to push this file to my users rather than saving it to my server. </p>
<p>In other words, pass them the file handle so it just passes through my server and saves to their machine. How can I do this? I have this so far:</p>
<pre><code>$handle = fopen($_GET['fileUR... | [
{
"answer_id": 539555,
"author": "Ólafur Waage",
"author_id": 22459,
"author_profile": "https://Stackoverflow.com/users/22459",
"pm_score": 3,
"selected": true,
"text": "<p>You can try this</p>\n\n<pre><code>$filetype = mime_content_type($filename);\nheader('Content-type: '.$filetype);\n... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51649/"
] | I am downloading a file from another server. I wish to push this file to my users rather than saving it to my server.
In other words, pass them the file handle so it just passes through my server and saves to their machine. How can I do this? I have this so far:
```
$handle = fopen($_GET['fileURL'], 'r');
$filename ... | You can try this
```
$filetype = mime_content_type($filename);
header('Content-type: '.$filetype);
header('Content-Disposition: attachment; filename="'.$filename.'"');
```
UPDATE for your EDIT:
Do you have errors disabled, since this sounds like the headers already sent error?
```
error_reporting(E_ALL | E_STRICT)... |
539,549 | <p>Quick question; do I always need to check for a null value after performing a safe cast? I do it this way now, but in a situation like this:</p>
<pre><code>void button1_Click(object sender, EventArgs e)
{
Button = sender as Button;
if (button != null) // <-- necessary?
{
// do stuff with 'b... | [
{
"answer_id": 539554,
"author": "Leonidas",
"author_id": 57510,
"author_profile": "https://Stackoverflow.com/users/57510",
"pm_score": 2,
"selected": false,
"text": "<p>Yes. Except you want to cause an exception if you call something at this button :)</p>\n"
},
{
"answer_id": 53... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1053/"
] | Quick question; do I always need to check for a null value after performing a safe cast? I do it this way now, but in a situation like this:
```
void button1_Click(object sender, EventArgs e)
{
Button = sender as Button;
if (button != null) // <-- necessary?
{
// do stuff with 'button'
}
}
``... | I agree - maybe you're better off having the app crash if a non-Button is hooked up, since this handler only makes sense for Buttons. Going with a normal cast might even be better than an "as" cast, because you'll end up with an InvalidCastException rather than a NullReferenceException, which make the problem very obvi... |
539,567 | <p>Bit of oddness, seen if I do the following:</p>
<pre><code>import javax.swing.*;
public class FunkyButtonLayout {
public static void main(String[] args) {
JFrame frame = new JFrame("");
JPanel j0 = new JPanel(); // j0 gets added to the root pane
j0.setLayout(null);
JPanel j1 ... | [
{
"answer_id": 539612,
"author": "Dan Dyer",
"author_id": 5171,
"author_profile": "https://Stackoverflow.com/users/5171",
"pm_score": 3,
"selected": true,
"text": "<p>If you set the layout manager to null, you have to explicitly set the container's preferred size (that's why it's showing... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64696/"
] | Bit of oddness, seen if I do the following:
```
import javax.swing.*;
public class FunkyButtonLayout {
public static void main(String[] args) {
JFrame frame = new JFrame("");
JPanel j0 = new JPanel(); // j0 gets added to the root pane
j0.setLayout(null);
JPanel j1 = new JPanel()... | If you set the layout manager to null, you have to explicitly set the container's preferred size (that's why it's showing up so small).
If you are using setBounds on a component, you are over-riding the work that the layout manager for the parent container does.
I would remove all calls to setBounds and all calls to ... |
539,568 | <p>I'm binding IList to a GridView. IMyInterface looks like</p>
<pre><code>public interface IMyInterface: IHasTotalHours, IHasLines
{
DateTime GoalStartDate { get; set; }
DateTime GoalEndDate { get; set; }
}
</code></pre>
<p>I bind an instance to a Grid like this:</p>
<pre><code>IList<IMyInterface> ins... | [
{
"answer_id": 540059,
"author": "Chris Holmes",
"author_id": 62186,
"author_profile": "https://Stackoverflow.com/users/62186",
"pm_score": -1,
"selected": false,
"text": "<p>It's because an interface is a contract, and that's the only way to interact with an object is through that speci... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16426/"
] | I'm binding IList to a GridView. IMyInterface looks like
```
public interface IMyInterface: IHasTotalHours, IHasLines
{
DateTime GoalStartDate { get; set; }
DateTime GoalEndDate { get; set; }
}
```
I bind an instance to a Grid like this:
```
IList<IMyInterface> instance= GetMyData();
myGrid.DataSource = in... | Data bound controls do not use reflection but a TypeDescriptor to get the properties from a data source. In the [TypeDescriptor.GetProperties](http://msdn.microsoft.com/en-us/library/ybh0y4fd.aspx) method, you can read the following:
>
> The properties for a component can
> differ from the properties of a class,
> ... |
539,575 | <p>I have a movie that loads an flv using the VideoPlayer class. It does it with the load function.</p>
<p>Here is a code sample of what I'm doing:</p>
<pre><code>_root.createEmptyMovieClip("SlideA", 1);
...
SlideA.loadMovie(urlContainingFunctionForLoadVideo);
... // SlideA has completely loaded
SlideA.loadVideo... | [
{
"answer_id": 540059,
"author": "Chris Holmes",
"author_id": 62186,
"author_profile": "https://Stackoverflow.com/users/62186",
"pm_score": -1,
"selected": false,
"text": "<p>It's because an interface is a contract, and that's the only way to interact with an object is through that speci... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12261/"
] | I have a movie that loads an flv using the VideoPlayer class. It does it with the load function.
Here is a code sample of what I'm doing:
```
_root.createEmptyMovieClip("SlideA", 1);
...
SlideA.loadMovie(urlContainingFunctionForLoadVideo);
... // SlideA has completely loaded
SlideA.loadVideo(urlToFLV);
function... | Data bound controls do not use reflection but a TypeDescriptor to get the properties from a data source. In the [TypeDescriptor.GetProperties](http://msdn.microsoft.com/en-us/library/ybh0y4fd.aspx) method, you can read the following:
>
> The properties for a component can
> differ from the properties of a class,
> ... |
539,578 | <p>Why do some languages, like C++ and Python, require the namespace of an object be specified even when no ambiguity exists? I understand that there are backdoors to this, like <code>using namespace x</code> in C++, or <code>from x import *</code> in Python. However, I can't understand the rationale behind not wanti... | [
{
"answer_id": 539585,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 0,
"selected": false,
"text": "<p>This all depends on your definition of \"right thing\". Is it the right thing for the compiler to guess your intenti... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] | Why do some languages, like C++ and Python, require the namespace of an object be specified even when no ambiguity exists? I understand that there are backdoors to this, like `using namespace x` in C++, or `from x import *` in Python. However, I can't understand the rationale behind not wanting the language to just "do... | One reason is to protect against accidentally introducing a conflict when you change the code (or for an external module/library, when someone else changes it) later on. For example, in Python you can write
```
from foo import *
from bar import *
```
without conflicts if you know that modules `foo` and `bar` don't h... |
539,583 | <p>Breadth-first list is important, here. Also, limiting the depth searched would be nice.</p>
<pre><code>$ find . -type d
/foo
/foo/subfoo
/foo/subfoo/subsub
/foo/subfoo/subsub/subsubsub
/bar
/bar/subbar
$ find . -type d -depth
/foo/subfoo/subsub/subsubsub
/foo/subfoo/subsub
/foo/subfoo
/foo
/bar/subbar
/bar
$ <... | [
{
"answer_id": 539614,
"author": "ypnos",
"author_id": 21974,
"author_profile": "https://Stackoverflow.com/users/21974",
"pm_score": 2,
"selected": false,
"text": "<p>Without the deserved ordering:\n find -maxdepth -type d</p>\n\n<p>To get the deserved ordering, you have to do the re... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10728/"
] | Breadth-first list is important, here. Also, limiting the depth searched would be nice.
```
$ find . -type d
/foo
/foo/subfoo
/foo/subfoo/subsub
/foo/subfoo/subsub/subsubsub
/bar
/bar/subbar
$ find . -type d -depth
/foo/subfoo/subsub/subsubsub
/foo/subfoo/subsub
/foo/subfoo
/foo
/bar/subbar
/bar
$ < what goes here? ... | The `find` command supports `-printf` option which recognizes a lot of placeholders.
One such placeholder is `%d` which renders the depth of given path, relative to where `find` started.
Therefore you can use following simple one-liner:
```
find -type d -printf '%d\t%P\n' | sort -r -nk1 | cut -f2-
```
It is quite ... |
539,598 | <p>I'm working on a project at the moment where I've come up against a rather frustrating problem in Internet Explorer. I have a series of pop ups on a particular page that are opened with JavaScript when help links are clicked. The JavaScript for them is:</p>
<pre><code>function openHelpPopUp(url) {
newwindow=win... | [
{
"answer_id": 539639,
"author": "Rog",
"author_id": 65338,
"author_profile": "https://Stackoverflow.com/users/65338",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like a browser bug.</p>\n\n<p>What happens if you open the URL directly? Perhaps it's not popup related?</p>\n"
}... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17020/"
] | I'm working on a project at the moment where I've come up against a rather frustrating problem in Internet Explorer. I have a series of pop ups on a particular page that are opened with JavaScript when help links are clicked. The JavaScript for them is:
```
function openHelpPopUp(url) {
newwindow=window.open(url,'... | By adding a z-index of 100 to every P tag for IE, I seem to have gotten it visible now. Weird. I haven't used any z-index's elsewhere and the structure of the HTML should put the P's on the top anyway. |
539,628 | <p>I'm trying to write a custom STL allocator that is derived from <code>std::allocator</code>, but somehow all calls to <code>allocate()</code> go to the base class. I have narrowed it down to this code:</p>
<pre><code>template <typename T> class a : public std::allocator<T> {
public:
T* allocate(size... | [
{
"answer_id": 539651,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>The following code prints \"yo\" as expected - what you were seeing was our old friend \"undefined behaviour\".</p>\n\n<pre... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13562/"
] | I'm trying to write a custom STL allocator that is derived from `std::allocator`, but somehow all calls to `allocate()` go to the base class. I have narrowed it down to this code:
```
template <typename T> class a : public std::allocator<T> {
public:
T* allocate(size_t n, const void* hint = 0) const {
cout... | You will need to provide a rebind member template and the other stuff that is listed in the allocator requirements in the C++ Standard. For example, you need a template copy constructor which accepts not only `allocator<T>` but also `allocator<U>`. For example, one code might do, which a std::list for example is likely... |
539,640 | <p>CoInitialize(NULL) creates an STA by creating a hidden window. How to get an HWND handle for this window?</p>
<p>Function EnumThreadWindows does not work, in an example I tried:</p>
<pre><code>...
CoInitialize(NULL);
EnumThreadWindows(GetCurrentThreadId(), EnumThreadWndProc, 0);
...
BOOL CALLBACK EnumThreadWnd... | [
{
"answer_id": 539789,
"author": "Bahaa Zaid",
"author_id": 61127,
"author_profile": "https://Stackoverflow.com/users/61127",
"pm_score": 2,
"selected": false,
"text": "<p>This hidden window is Message-Only Window, It is not visible, has no z-order, cannot be enumerated, and does not re... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539640",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | CoInitialize(NULL) creates an STA by creating a hidden window. How to get an HWND handle for this window?
Function EnumThreadWindows does not work, in an example I tried:
```
...
CoInitialize(NULL);
EnumThreadWindows(GetCurrentThreadId(), EnumThreadWndProc, 0);
...
BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARA... | This hidden window is Message-Only Window, It is not visible, has no z-order, cannot be enumerated, and does not receive broadcast messages. The window simply dispatches messages.
To find message-only windows, specify HWND\_MESSAGE in the hwndParent parameter of the FindWindowEx function. In addition, FindWindowEx sea... |
539,641 | <p>I'm getting an error when creating a MOSS publishing page (this is a completely clean MOSS install, no site built into it yet). I'm using code which I've found on plenty of blogs, eg:</p>
<pre><code>var pubWeb = PublishingWeb.GetPublishingWeb(Site.RootWeb);
SPContentTypeId ctId = new SPContentTypeId(contentTypeId);... | [
{
"answer_id": 539704,
"author": "Ric Tokyo",
"author_id": 42019,
"author_profile": "https://Stackoverflow.com/users/42019",
"pm_score": 0,
"selected": false,
"text": "<p>try adding a site to the farm and then, use <a href=\"http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelop... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11388/"
] | I'm getting an error when creating a MOSS publishing page (this is a completely clean MOSS install, no site built into it yet). I'm using code which I've found on plenty of blogs, eg:
```
var pubWeb = PublishingWeb.GetPublishingWeb(Site.RootWeb);
SPContentTypeId ctId = new SPContentTypeId(contentTypeId);
var layouts =... | I found out what the problem was, the ContentType I was using was corrupt. Because of another problem I'm having deploying ContentTypes ([see this question](https://stackoverflow.com/questions/539328/high-cpu-usage-when-deploying-content-types-via-a-sharepoint-feature)) I'm programatically creating the ContentType, but... |
539,642 | <p>I'm using a RTF file as a template for an ASP.NET web application. My VB.NET code reads the file using a StreamReader, replaces some strings, and creates a new Word document with data from the database. My code closes and disposes of the StreamReader. However, when I attempt to upload a revised RTF file to the web s... | [
{
"answer_id": 539664,
"author": "AJ.",
"author_id": 27457,
"author_profile": "https://Stackoverflow.com/users/27457",
"pm_score": 1,
"selected": false,
"text": "<p>It seems odd if it's hanging on even after a close/dispose. Are you using a FileStream along with the StreamReader? Gener... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4320/"
] | I'm using a RTF file as a template for an ASP.NET web application. My VB.NET code reads the file using a StreamReader, replaces some strings, and creates a new Word document with data from the database. My code closes and disposes of the StreamReader. However, when I attempt to upload a revised RTF file to the web serv... | consider using the "using" idiom, also available in VB.net
```
using(StreamReader reader = new StreamReader(...)) {
}
```
the stream will get closed, even if exception is thrown
Consider closing all IDisposable implementations like this |
539,661 | <p>I created a <a href="http://chaletsdesbouleaux.com/" rel="nofollow noreferrer">static website</a> in which each page has the following structure:</p>
<ol>
<li>Common stuff like header, menu, etc.</li>
<li>Page specific stuff in main content div</li>
<li>Footer</li>
</ol>
<p>In this website, all the common content ... | [
{
"answer_id": 539679,
"author": "John Rasch",
"author_id": 44765,
"author_profile": "https://Stackoverflow.com/users/44765",
"pm_score": 0,
"selected": false,
"text": "<p>Your HTML document is using UTF-8 encoding, try these character codes for your accented letters: <a href=\"http://ww... | 2009/02/12 | [
"https://Stackoverflow.com/questions/539661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I created a [static website](http://chaletsdesbouleaux.com/) in which each page has the following structure:
1. Common stuff like header, menu, etc.
2. Page specific stuff in main content div
3. Footer
In this website, all the common content is duplicated in each page. In order to improve the maintainability I refact... | You are serving your pages as UTF-8, which is good, but at least some of the page is being dragged in from files which are not actually saved as UTF-8. SSI just throws the raw bytes in, it doesn't attempt to recode the includes so that their charsets match the file they're being included into.
You need to go through a... |