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 |
|---|---|---|---|---|---|---|
225,394 | <p>I have a List of strings that is regenerated every 5 seconds. I want to create a Context Menu and set its items dynamically using this list.
The problem is that I don't have even a clue how to do that and manage the Click action for every item generated (which should use the same method with different parameter DoSo... | [
{
"answer_id": 225514,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 5,
"selected": true,
"text": "<p>So, you can clear the items from the context menu with:</p>\n\n<pre><code>myContextMenuStrip.Items.Clear();\n</code></pre>... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] | I have a List of strings that is regenerated every 5 seconds. I want to create a Context Menu and set its items dynamically using this list.
The problem is that I don't have even a clue how to do that and manage the Click action for every item generated (which should use the same method with different parameter DoSomet... | So, you can clear the items from the context menu with:
```
myContextMenuStrip.Items.Clear();
```
You can add an item by calling:
```
myContextMenuStrip.Items.Add(myString);
```
The context menu has an ItemClicked event. Your handler could look like so:
```
private void myContextMenuStrip_ItemClicked(object send... |
225,432 | <p>With VS2005, I want to create a DLL and automatically export all symbols without adding <code>__declspec(dllexport)</code> everywhere, and without hand-creating <code>.def</code> files. Is there a way to do this?</p>
| [
{
"answer_id": 225457,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": -1,
"selected": false,
"text": "<p>No, you will need a macro that resolves to <code>__declspec(dllexport)</code> when it's included by the .cpp file that... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14443/"
] | With VS2005, I want to create a DLL and automatically export all symbols without adding `__declspec(dllexport)` everywhere, and without hand-creating `.def` files. Is there a way to do this? | Short answer
------------
You can do it with help of the new version of the CMake (any version cmake-3.3.20150721-g9cd2f-win32-x86.exe or higher).
Currently it's in the dev branch.
Later, the feature will be added in the release version of the cmake-3.4.
Link to the cmake dev:
[cmake\_dev](http://www.cmake.org/fil... |
225,471 | <p>I have an <code>ActiveRecord</code> model, <code>Foo</code>, which has a <code>name</code> field. I'd like users to be able to search by name, but I'd like the search to ignore case and any accents. Thus, I'm also storing a <code>canonical_name</code> field against which to search:</p>
<pre><code>class Foo
vali... | [
{
"answer_id": 225508,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 2,
"selected": false,
"text": "<p>You probably want Unicode decomposition (\"NFD\"). After decomposing the string, just filter out anything not in [A-Za... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I have an `ActiveRecord` model, `Foo`, which has a `name` field. I'd like users to be able to search by name, but I'd like the search to ignore case and any accents. Thus, I'm also storing a `canonical_name` field against which to search:
```
class Foo
validates_presence_of :name
before_validate :set_canonical_na... | Rails has already a builtin for normalizing, you just have to use this to normalize your string to form KD and then remove the other chars (i.e. accent marks) like this:
```
>> "àáâãäå".mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n,'').downcase.to_s
=> "aaaaaa"
``` |
225,481 | <p>I'm using T4 for generating repositories for LINQ to Entities entities. </p>
<p>The repository contains (amongst other things) a List method suitable for paging. The documentation for <a href="http://msdn.microsoft.com/en-us/library/bb738474.aspx" rel="nofollow noreferrer">Supported and Unsupported Methods</a> does... | [
{
"answer_id": 225660,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 1,
"selected": false,
"text": "<p>I'm afraid it's a bit harder than that. You see, the Entity Framework will, in certain circumstances, <a href=\"htt... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11098/"
] | I'm using T4 for generating repositories for LINQ to Entities entities.
The repository contains (amongst other things) a List method suitable for paging. The documentation for [Supported and Unsupported Methods](http://msdn.microsoft.com/en-us/library/bb738474.aspx) does not mention it, but you can't "call" `Skip` on... | You can address this in the return type of ProvideDefaultSorting. This code does not build:
```
public IOrderedQueryable<int> GetOrderedQueryable()
{
IQueryable<int> myInts = new List<int>() { 3, 4, 1, 2 }.AsQueryable<int>();
return myInts.Where(i => i == 2);
}
```
This code builds, but i... |
225,496 | <p>Today I changed the application pool identity of our ASP.NET application from "Network Service" to a domain user.</p>
<p>I added the user to the local group "IIS_WPG", done a iisreset just in case, and
everything works fine with IE6 and Firefox 3.0</p>
<p>But when I go to the website with IE7, an authentication p... | [
{
"answer_id": 228254,
"author": "Christopher G. Lewis",
"author_id": 13532,
"author_profile": "https://Stackoverflow.com/users/13532",
"pm_score": 3,
"selected": true,
"text": "<p>Typically, if you see an issue with authentication where it works in IE 6 but not IE 7, I'd check to make s... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/971/"
] | Today I changed the application pool identity of our ASP.NET application from "Network Service" to a domain user.
I added the user to the local group "IIS\_WPG", done a iisreset just in case, and
everything works fine with IE6 and Firefox 3.0
But when I go to the website with IE7, an authentication popup appears, I ... | Typically, if you see an issue with authentication where it works in IE 6 but not IE 7, I'd check to make sure Kerberos is configured correctly.
Running as Network Service, your Kerberos SPNs should attached to the machine account. As a domain account, the SPN's need to be on that account.
As to why IE 6 is different... |
225,513 | <p>Is there any way to display scrollabletext in loose xaml? The equivalent in HTML would be </p>
<pre><code><div style="overflow:scroll">some long bit of text here</div>
</code></pre>
<p>Can you do this in loose xaml? </p>
<p>From my experiments so far it seems that in loose xaml:</p>
<ol>
<li>You ca... | [
{
"answer_id": 228254,
"author": "Christopher G. Lewis",
"author_id": 13532,
"author_profile": "https://Stackoverflow.com/users/13532",
"pm_score": 3,
"selected": true,
"text": "<p>Typically, if you see an issue with authentication where it works in IE 6 but not IE 7, I'd check to make s... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there any way to display scrollabletext in loose xaml? The equivalent in HTML would be
```
<div style="overflow:scroll">some long bit of text here</div>
```
Can you do this in loose xaml?
From my experiments so far it seems that in loose xaml:
1. You cannot use TextBox -- it must be TextBlock.
2. TextBlock do... | Typically, if you see an issue with authentication where it works in IE 6 but not IE 7, I'd check to make sure Kerberos is configured correctly.
Running as Network Service, your Kerberos SPNs should attached to the machine account. As a domain account, the SPN's need to be on that account.
As to why IE 6 is different... |
225,542 | <p>I have a Makefile that starts by running a tool before applying the build rules (which this tool writes for me). If this tool, which is a python script, exits with a non-null status code, I want GNU Make to stop right there and not go on with building the program.</p>
<p>Currently, I do something like this (top lev... | [
{
"answer_id": 225626,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 3,
"selected": false,
"text": "<p>There might be a better way, but I tried the following and it works:</p>\n\n<pre><code>$(if $(shell if your_command; the... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2095/"
] | I have a Makefile that starts by running a tool before applying the build rules (which this tool writes for me). If this tool, which is a python script, exits with a non-null status code, I want GNU Make to stop right there and not go on with building the program.
Currently, I do something like this (top level, i.e. c... | Ok, here's my own solution, which is unfortunately not based on the status code of the collect\_sources.py script, but which Works For Me (TM) and lets me see any output that the script produces:
```
SHELL_OUTPUT := $(shell python collect_sources.py 2>&1)
ifeq ($(filter error: [Errno %],$(SHELL_OUTPUT)),)
$(info $(S... |
225,545 | <p>I'm creating a C# dll, which is going to be used by others developers in WinForms. For some reasons, I want to detect, if methods from this library, are called from Main (GUI) Thread and warn developer he has done such a thing (ie. in log file). Is there any reasonable way to detect calling method from main thread?
... | [
{
"answer_id": 225556,
"author": "ageektrapped",
"author_id": 631,
"author_profile": "https://Stackoverflow.com/users/631",
"pm_score": 5,
"selected": true,
"text": "<p>An easy solution in this case is to declare a static control in the library assembly that is created on the Main UI thr... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30343/"
] | I'm creating a C# dll, which is going to be used by others developers in WinForms. For some reasons, I want to detect, if methods from this library, are called from Main (GUI) Thread and warn developer he has done such a thing (ie. in log file). Is there any reasonable way to detect calling method from main thread?
Rem... | An easy solution in this case is to declare a static control in the library assembly that is created on the Main UI thread. If you want to detect if the library is called from the main thread, then use the following
```
if (MyLibraryControl.InvokeRequired)
//do your thing here
``` |
225,548 | <p>Where can I find algorithms for image distortions? There are so much info of Blur and other classic algorithms but so little of more complex ones. In particular, I am interested in swirl effect image distortion algorithm.</p>
| [
{
"answer_id": 225575,
"author": "Chris Johnson",
"author_id": 23732,
"author_profile": "https://Stackoverflow.com/users/23732",
"pm_score": 6,
"selected": true,
"text": "<p>I can't find any references, but I can give a basic idea of how distortion effects work.</p>\n\n<p>The key to the ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25194/"
] | Where can I find algorithms for image distortions? There are so much info of Blur and other classic algorithms but so little of more complex ones. In particular, I am interested in swirl effect image distortion algorithm. | I can't find any references, but I can give a basic idea of how distortion effects work.
The key to the distortion is a function which takes two coordinates (x,y) in the distorted image, and transforms them to coordinates (u,v) in the original image. This specifies the inverse function of the distortion, since it take... |
225,550 | <p>I'm filtering the messages that come to a form with PreFilterMessage like this:</p>
<p><code>print("code sample");</code></p>
<pre><code> public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_KEYDOWN && (int)m.WParam == VK_ESCAPE)
{
this.Close();
return true;
}
... | [
{
"answer_id": 225584,
"author": "Hallgrim",
"author_id": 15454,
"author_profile": "https://Stackoverflow.com/users/15454",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know if this fits with what you are doing. I usually set Form.CancelButton to the close or cancel button on my... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm filtering the messages that come to a form with PreFilterMessage like this:
`print("code sample");`
```
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_KEYDOWN && (int)m.WParam == VK_ESCAPE)
{
this.Close();
return true;
}
return false;
}
```
`print("code s... | I don't know if this fits with what you are doing. I usually set Form.CancelButton to the close or cancel button on my form, and it will automatically call the button OnClick when the user hits Esc on the keyboard. |
225,560 | <p>I think questions like this are the reason why I don't like working with PHP. The manual is good, if you can find what you are looking for. After reading through the <a href="http://us3.php.net/array" rel="nofollow noreferrer">Array Functions</a>, I didn't see one that provides the functionality I need.</p>
<p>I ha... | [
{
"answer_id": 225566,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://de.php.net/array_diff\" rel=\"nofollow noreferrer\"><code>array_diff</code></a> is what you want.<... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] | I think questions like this are the reason why I don't like working with PHP. The manual is good, if you can find what you are looking for. After reading through the [Array Functions](http://us3.php.net/array), I didn't see one that provides the functionality I need.
I have an array (in my case, numerically indexed) t... | [`array_diff`](http://de.php.net/array_diff) is what you want.
```
$array1 = array("a" => "green", "red", "blue", "red");
$array2 = array("b" => "green", "yellow", "red");
$result = array_diff($array1, $array2);
```
Result: `"blue"`. |
225,563 | <p>I've implemented a set of draggable elements that can be dropped into some containers using jQuery. What I need is an animation that moves an element to a specific container without user interaction. The problem is that the elements and the drop containers are in completely <strong>different parts of the DOM</strong... | [
{
"answer_id": 225596,
"author": "Sergey Ilinsky",
"author_id": 23815,
"author_profile": "https://Stackoverflow.com/users/23815",
"pm_score": 6,
"selected": true,
"text": "<p>I never used jQuery, just looked up API, so I can assume you can do the following:</p>\n\n<pre>\nvar o1 = $(eleme... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22592/"
] | I've implemented a set of draggable elements that can be dropped into some containers using jQuery. What I need is an animation that moves an element to a specific container without user interaction. The problem is that the elements and the drop containers are in completely **different parts of the DOM** and mostly pos... | I never used jQuery, just looked up API, so I can assume you can do the following:
```
var o1 = $(element1).offset();
var o2 = $(element2).offset();
var dx = o1.left - o2.left;
var dy = o1.top - o2.top;
var distance = Math.sqrt(dx * dx + dy * dy);
``` |
225,598 | <p>This is a slightly.. vain question, but BuildBot's output isn't particularly nice to look at..</p>
<p>For example, compared to..</p>
<ul>
<li><a href="http://phpundercontrol.org/about.html" rel="noreferrer">phpUnderControl</a></li>
<li><a href="http://jenkins-ci.org/content/about-jenkins-ci" rel="noreferrer">Jenki... | [
{
"answer_id": 225788,
"author": "edomaur",
"author_id": 14262,
"author_profile": "https://Stackoverflow.com/users/14262",
"pm_score": 3,
"selected": false,
"text": "<p>Don't know if it would do : <a href=\"http://bitten.edgewall.org/\" rel=\"noreferrer\">Bitten</a> is made by the guys w... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] | This is a slightly.. vain question, but BuildBot's output isn't particularly nice to look at..
For example, compared to..
* [phpUnderControl](http://phpundercontrol.org/about.html)
* [Jenkins](http://jenkins-ci.org/content/about-jenkins-ci)
+ [Hudson](http://blogs.oracle.com/arungupta/entry/top_10_features_of_hudson... | You might want to check out [Nose](http://somethingaboutorange.com/mrl/projects/nose/) and [the Xunit output plugin](http://nose.readthedocs.org/en/latest/plugins/xunit.html). You can have it run your unit tests, and coverage checks with this command:
```
nosetests --with-xunit --enable-cover
```
That'll be helpful ... |
225,617 | <p>I'm trying to get this piece of code working a little better. I suspect it's the loop reading one byte at a time. I couldn't find another way of doing this with gzip decompression. Implementing a <code>StreamReader</code> is fine, but it returns a string which I can't pass to the decompression stream.</p>
<p>Is the... | [
{
"answer_id": 225620,
"author": "jmcd",
"author_id": 2285,
"author_profile": "https://Stackoverflow.com/users/2285",
"pm_score": 1,
"selected": false,
"text": "<p>Is the <a href=\"http://msdn.microsoft.com/en-us/library/system.net.webclient(VS.80).aspx\" rel=\"nofollow noreferrer\">WebC... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] | I'm trying to get this piece of code working a little better. I suspect it's the loop reading one byte at a time. I couldn't find another way of doing this with gzip decompression. Implementing a `StreamReader` is fine, but it returns a string which I can't pass to the decompression stream.
Is there a better way?
```... | I'd agree with jmcd that WebClient would be far simpler, in particular WebClient.DownloadData.
re the actual question, the problem is that you are reading single bytes, when you should probably have a fixed buffer, and loop - i.e.
```
int bytesRead;
byte[] buffer = new byte[1024];
while((bytesRead = webStream.Read(bu... |
225,637 | <p>I recently installed RailRoad gem to generate an .svg diagram of my app's models and controllers.</p>
<p>The rake task keeps breaking with a similar error:</p>
<pre><code>1.8/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant
</c... | [
{
"answer_id": 225837,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 2,
"selected": false,
"text": "<p>I'm running it without any problems (though I did have to make a quick edit as it was representing the crows feet the... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/449483/"
] | I recently installed RailRoad gem to generate an .svg diagram of my app's models and controllers.
The rake task keeps breaking with a similar error:
```
1.8/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:263:in `load_missing_constant': uninitialized constant
```
I tried the rake t... | Ivan, and others, try using Bryan Larsen's version from Github: <http://github.com/bryanlarsen/railroad> |
225,666 | <p>I have a CompositeControl that contains a DropDownList.</p>
<p>I have set the AutoPostBack property of the DropDownList to true.</p>
<p>On the page, I have:</p>
<pre><code><asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<MyControl:Control ID="CustomControl" runat="se... | [
{
"answer_id": 225926,
"author": "Programmin Tool",
"author_id": 21691,
"author_profile": "https://Stackoverflow.com/users/21691",
"pm_score": 3,
"selected": true,
"text": "<p>Ok so this may not be the best answer, but I think the problem you're having it that the UpdatePanel just can't ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8797/"
] | I have a CompositeControl that contains a DropDownList.
I have set the AutoPostBack property of the DropDownList to true.
On the page, I have:
```
<asp:UpdatePanel ID="UpdatePanel" runat="server">
<ContentTemplate>
<MyControl:Control ID="CustomControl" runat="server" />
</ContentTemplate>
</asp:Updat... | Ok so this may not be the best answer, but I think the problem you're having it that the UpdatePanel just can't see the child control's event. Good news is, it's easy to fix. Say you have a control (CatchMyEvent, which by the way is a crazy clever name) and it has a DropDownList on it. Now you want the parent page to s... |
225,675 | <p>I believe I'm getting bitten by some combination of nested scoping rules and list comprehensions. <a href="http://www.python.org/~jeremy/weblog/040204.html" rel="noreferrer">Jeremy Hylton's blog post</a> is suggestive about the causes, but I don't really understand CPython's implementation well-enough to figure out... | [
{
"answer_id": 225801,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 5,
"selected": true,
"text": "<p>The problem is that with <code>return self.display</code> you return a <em>reference</em> to this list (not a copy). So w... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15842/"
] | I believe I'm getting bitten by some combination of nested scoping rules and list comprehensions. [Jeremy Hylton's blog post](http://www.python.org/~jeremy/weblog/040204.html) is suggestive about the causes, but I don't really understand CPython's implementation well-enough to figure out how to get around this.
Here ... | The problem is that with `return self.display` you return a *reference* to this list (not a copy). So what you end up with is a list where each element is a reference to self.display. To illustrate, look at the following:
```
>>> a = [1,2]
>>> b = [a,a]
>>> b
[[1, 2], [1, 2]]
>>> a.append(3)
>>> b
[[1, 2, 3], [1, 2, 3... |
225,686 | <p>I have a singleton that uses the "static readonly T Instance = new T();" pattern. However, I ran into a case where T is disposable, and actually needs to be disposed for unit tests. How can I modify this pattern to support a disposable singleton?</p>
<p>The interface I would like is something like:</p>
<pre><code>... | [
{
"answer_id": 225695,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "<p>At that point I don't think I'd really consider it to be a singleton any more, to be honest.</p>\n\n<p>In particular,... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11236/"
] | I have a singleton that uses the "static readonly T Instance = new T();" pattern. However, I ran into a case where T is disposable, and actually needs to be disposed for unit tests. How can I modify this pattern to support a disposable singleton?
The interface I would like is something like:
```
var x = Foo.Instance;... | Mark `Release` as `internal` and use the `InternalsVisibleTo` attribute to expose it only to your unit testing assembly. You can either do that, or if you're wary someone in your own assembly will call it, you can mark it as `private` and access it using reflection.
Use a finalizer in your singleton that calls the `Di... |
225,699 | <p>Does anyone know if you can programmatically open a .webarchive on the iPhone? A .webarchive is Safari's way of packaging up a webpage and it's associated resources into a single file.</p>
<p>I tried creating one and browsing to a link to one in mobile safari, but it didn't work....</p>
<p>Note: I was kind of hop... | [
{
"answer_id": 225718,
"author": "J Francis",
"author_id": 19169,
"author_profile": "https://Stackoverflow.com/users/19169",
"pm_score": 0,
"selected": false,
"text": "<p>AirSharing on the iPhone will open webarchive files, but I've no idea if they are doing it all themselves or using na... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26510/"
] | Does anyone know if you can programmatically open a .webarchive on the iPhone? A .webarchive is Safari's way of packaging up a webpage and it's associated resources into a single file.
I tried creating one and browsing to a link to one in mobile safari, but it didn't work....
Note: I was kind of hoping this could be ... | webarchive is supported on iOS. Just load it on UIWebView. It just works!
for loading a webarchive on your bundle, just do
```
NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"myFile"
withExtension:@"webarchive"];
[webView loadRequest:[NSURLRequest requestWithURL:fileURL]];
```
webview is your UIWebvi... |
225,700 | <p>I am developing a website and for the main navigation, I was thinking it would be a good idea to include the title attribute.</p>
<pre><code><a href="/results/" title="Results">Results</a>
</code></pre>
<p>Is this a good thing to do? Also, is it good for SEO and accessibility?</p>
| [
{
"answer_id": 225702,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 6,
"selected": true,
"text": "<p>It is a great thing to do. For accessibility, for SEO, for standards, for good netiquette.<br>\nYou may want to make t... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | I am developing a website and for the main navigation, I was thinking it would be a good idea to include the title attribute.
```
<a href="/results/" title="Results">Results</a>
```
Is this a good thing to do? Also, is it good for SEO and accessibility? | It is a great thing to do. For accessibility, for SEO, for standards, for good netiquette.
You may want to make them slightly more descriptive though: title="Results of your Search" or "Results of Test #2" |
225,711 | <p>Any ideas how to stop the system bell from sounding when <kbd>CTRL</kbd>-<kbd>A</kbd> is used to select text in a Winforms application?</p>
<p>Here's the problem. Create a Winforms project. Place a text box on the form and add the following event handler on the form to allow <kbd>CTRL</kbd>-<kbd>A</kbd> to select a... | [
{
"answer_id": 225752,
"author": "itsmatt",
"author_id": 7862,
"author_profile": "https://Stackoverflow.com/users/7862",
"pm_score": 1,
"selected": false,
"text": "<p>This worked for me:</p>\n\n<p>Set the KeyPreview on the Form to True.</p>\n\n<p>Hope that helps.</p>\n"
},
{
"ans... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30363/"
] | Any ideas how to stop the system bell from sounding when `CTRL`-`A` is used to select text in a Winforms application?
Here's the problem. Create a Winforms project. Place a text box on the form and add the following event handler on the form to allow `CTRL`-`A` to select all the text in the textbox (no matter which co... | ```
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.A)
{
this.textBox1.SelectAll();
e.SuppressKeyPress = true;
}
}
```
hope this helps |
225,717 | <p>Given a FieldInfo object and an object, I need to get the actual bytes representation of the field. I know that the field is either <code>int,Int32,uint,short</code> etc.</p>
<p>How can I get the actual byte representation? BinaryFormatter.Serialize won't help, since it'll give me more information than I need (it a... | [
{
"answer_id": 225729,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 3,
"selected": false,
"text": "<p>Use BitConverter.GetBytes()</p>\n\n<p>You'll first have to convert the value to it's native type, than use BitConv... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Given a FieldInfo object and an object, I need to get the actual bytes representation of the field. I know that the field is either `int,Int32,uint,short` etc.
How can I get the actual byte representation? BinaryFormatter.Serialize won't help, since it'll give me more information than I need (it also records type name... | You may also try code like the following if what you actually want is to transfer structures as a byte array:
```
int rawsize = Marshal.SizeOf(value);
byte[] rawdata = new byte[rawsize];
GCHandle handle = GCHandle.Alloc(rawdata, GCHandleType.Pinned);
Marshal.StructureToPtr(value, handle.AddrOfPinnedObject(), false);
h... |
225,735 | <p>Is there an easy way to rename a group of files already contained in a directory, using Python?</p>
<p><strong>Example:</strong> I have a directory full of *.doc files and I want to rename them in a consistent way.</p>
<blockquote>
<p>X.doc -> "new(X).doc"</p>
<p>Y.doc -> "new(Y).doc"</p>
</blockquote>
| [
{
"answer_id": 225755,
"author": "xsl",
"author_id": 11387,
"author_profile": "https://Stackoverflow.com/users/11387",
"pm_score": 3,
"selected": false,
"text": "<p>Try: <a href=\"http://www.mattweber.org/2007/03/04/python-script-renamepy/\" rel=\"noreferrer\">http://www.mattweber.org/20... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11760/"
] | Is there an easy way to rename a group of files already contained in a directory, using Python?
**Example:** I have a directory full of \*.doc files and I want to rename them in a consistent way.
>
> X.doc -> "new(X).doc"
>
>
> Y.doc -> "new(Y).doc"
>
>
> | Such renaming is quite easy, for example with [os](http://docs.python.org/lib/module-os.html) and [glob](http://docs.python.org/lib/module-glob.html) modules:
```
import glob, os
def rename(dir, pattern, titlePattern):
for pathAndFilename in glob.iglob(os.path.join(dir, pattern)):
title, ext = os.path.spl... |
225,741 | <p>Is there a way to set the StartPosition of a Windows Forms form using code? It seems whatever I try results in the StartPostion being the default.</p>
<p>Here is what I am doing in the form to display:</p>
<pre><code> public DealsForm()
{
InitializeComponent();
this.StartPosition = FormStartP... | [
{
"answer_id": 225767,
"author": "Vordreller",
"author_id": 11795,
"author_profile": "https://Stackoverflow.com/users/11795",
"pm_score": -1,
"selected": false,
"text": "<p>My first reaction is: experiment a bit with VS2008. It should be in the general properties screen.</p>\n\n<p>If you... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] | Is there a way to set the StartPosition of a Windows Forms form using code? It seems whatever I try results in the StartPostion being the default.
Here is what I am doing in the form to display:
```
public DealsForm()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterParent... | >
> If I do a ShowDialog() and pass the
> parent it works ... but I really don't
> want to show it as a Dialog.
>
>
>
That is correct since ShowDialog would set frm.Parent == nvShowDeals.Parent
Since you are using .Show() then frm.Parent == null thus FormStartPosition.CenterParent is ignored.
So to accomplish ... |
225,764 | <p>I'm trying to safely update the home directory as specified in <code>/etc/passwd</code>,
but the standard Linux utils - usermod and vipw - for doing so aren't provided
by Cygwin.</p>
<p>Could anyone tell me how they changed this in Cygwin?</p>
| [
{
"answer_id": 225821,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 2,
"selected": false,
"text": "<p>I always set HOME as a user-specific environment variable in Computer Properties.</p>\n"
},
{
"answer_id": 2261... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4893/"
] | I'm trying to safely update the home directory as specified in `/etc/passwd`,
but the standard Linux utils - usermod and vipw - for doing so aren't provided
by Cygwin.
Could anyone tell me how they changed this in Cygwin? | I ended up exiting all my cygwin shells and editing it by hand in a text editor. So far, so good.
Note: don't escape the spaces in the "Documents and Settings" directory. The entry will look like
```
user:...:/cygdrive/c/Documents and Settings/user:/bin/bash
```
The line is tokenized on the `:` character. |
225,772 | <p>I'm currently developing an application using a MySQL database.</p>
<p>The database-structure is still in flux and changes while development progresses (I change my local copy, leaving the one on the test-server alone).</p>
<p>Is there a way to compare the two instances of the database to see if there were any cha... | [
{
"answer_id": 225776,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 0,
"selected": false,
"text": "<p>For the first part of the question, I just do a dump of both and diff them. Not sure about mysql, but postgres pg_d... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27439/"
] | I'm currently developing an application using a MySQL database.
The database-structure is still in flux and changes while development progresses (I change my local copy, leaving the one on the test-server alone).
Is there a way to compare the two instances of the database to see if there were any changes?
While curr... | If you're working with small databases I've found running mysqldump on both databases with the `--skip-comments` and `--skip-extended-insert` options to generate SQL scripts, then running diff on the SQL scripts works pretty well.
By skipping comments you avoid meaningless differences such as the time you ran the mysq... |
225,825 | <p>I'm developing a piece in VB.NET. Inside my primary form, I'm creating a new form to use as a dialog. I was wondering if there was a way to, upon the close of the new dialog, save it's size settings for each user (probably in a file on their machine, through XML or something?)</p>
| [
{
"answer_id": 225853,
"author": "Kris Erickson",
"author_id": 3798,
"author_profile": "https://Stackoverflow.com/users/3798",
"pm_score": 2,
"selected": false,
"text": "<p>Although <a href=\"https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicati... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13244/"
] | I'm developing a piece in VB.NET. Inside my primary form, I'm creating a new form to use as a dialog. I was wondering if there was a way to, upon the close of the new dialog, save it's size settings for each user (probably in a file on their machine, through XML or something?) | you can save it to the settings file, and update it on the 'onclosing' event.
to make a setting goto Project Properties ->settings -> then make a setting like 'dialogsize' of type system.drawing.size.
then do this in your dialog form:
```
Public Sub New()
InitializeComponent()
End Sub
Public Sub New(ByVal userS... |
225,832 | <p>Here's the deal. I have an XML document with a lot of records. Something like this:</p>
<pre><code>print("<?xml version="1.0" encoding="utf-8" ?>
<Orders>
<Order>
<Phone>1254</Phone>
<City>City1</City>
<State>State</State>
... | [
{
"answer_id": 225885,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>If the data maps fairly cleanly to an object model, you could try using xsd.exe to generate some classes from the ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] | Here's the deal. I have an XML document with a lot of records. Something like this:
```
print("<?xml version="1.0" encoding="utf-8" ?>
<Orders>
<Order>
<Phone>1254</Phone>
<City>City1</City>
<State>State</State>
</Order>
<Order>
<Phone>98764321</Phone>
... | You have a couple of options:
1. [XmlDataDocument](http://msdn.microsoft.com/en-us/library/system.xml.xmldatadocument(VS.80).aspx) or [XmlDocument](http://msdn.microsoft.com/en-us/library/system.xml.xmldocument(VS.80).aspx). The downside to this approach is that the data will be cached in memory, which is bad if you h... |
225,833 | <p>I have to add a coupon table to my db. There are 3 types of coupons : percentage, amount or 2 for 1.</p>
<p>So far I've come up with a coupon table that contains these 3 fields. If there's a percentage value not set to null then it's this kind of coupon.</p>
<p>I feel it's not the proper way to do it. Should I cre... | [
{
"answer_id": 225862,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 3,
"selected": true,
"text": "<p>You're correct, I think a CouponType table would be fit for your problem.</p>\n\n<p>Two tables: Coupons and CouponType... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24291/"
] | I have to add a coupon table to my db. There are 3 types of coupons : percentage, amount or 2 for 1.
So far I've come up with a coupon table that contains these 3 fields. If there's a percentage value not set to null then it's this kind of coupon.
I feel it's not the proper way to do it. Should I create a CouponType ... | You're correct, I think a CouponType table would be fit for your problem.
Two tables: Coupons and CouponTypes. Store the CouponTypeId inside the Coupons table.
So for an example, you'll have a Coupon record called "50% off", if would reference the percent off CouponType record and from there you could determine the l... |
225,843 | <p>I have a menu div that I want to slide down so it's always visible, but I want it to be positioned under my title div. I don't want it to move until the top of the menu hits the top of the screen and then stay in place. Basically I want a sliding menu with a maximum height it can slide to.</p>
| [
{
"answer_id": 225899,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 0,
"selected": false,
"text": "<p>Slashdot does this. Check it out at, for example, <a href=\"http://tech.slashdot.org/tech/08/10/22/1246200.shtml\" ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30377/"
] | I have a menu div that I want to slide down so it's always visible, but I want it to be positioned under my title div. I don't want it to move until the top of the menu hits the top of the screen and then stay in place. Basically I want a sliding menu with a maximum height it can slide to. | I think I understand what you're talking about—we used a similar technique on [The King](http://www.kingtray.com) with jQuery. Here's how:
```
///// CONFIGURATION VARIABLES:
var name = "#rightsidebar";
var menu_top_limit = 241;
var menu_top_margin = 20;
var menu_shift_duration = 500;
var menuY... |
225,845 | <p>I'm trying to get a kernel module to load at boot.</p>
<p>If I run <code>insmod /path/to/module.ko</code>, it works fine. But this has to be repeated every time I reboot.</p>
<p>If I run <code>modprobe /path/to/module.ko</code>, it can't find the module.
I know modprobe uses a configuration file, but I can't get i... | [
{
"answer_id": 225971,
"author": "Jaime Soriano",
"author_id": 28855,
"author_profile": "https://Stackoverflow.com/users/28855",
"pm_score": 7,
"selected": true,
"text": "<p>You can make a symbolic link of your module to the standard path, so depmod will see it and you'll be able load it... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13652/"
] | I'm trying to get a kernel module to load at boot.
If I run `insmod /path/to/module.ko`, it works fine. But this has to be repeated every time I reboot.
If I run `modprobe /path/to/module.ko`, it can't find the module.
I know modprobe uses a configuration file, but I can't get it to load the module even after adding ... | You can make a symbolic link of your module to the standard path, so depmod will see it and you'll be able load it as any other module.
```
sudo ln -s /path/to/module.ko /lib/modules/`uname -r`
sudo depmod -a
sudo modprobe module
```
If you add the module name to /etc/modules it will be loaded any time you boot.
An... |
225,881 | <p>Can anyone provide a clear explanation / example of what these functions do, and when it's appropriate to use them?</p>
| [
{
"answer_id": 225907,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 6,
"selected": true,
"text": "<p>Straight from <a href=\"http://www.postgresql.org/docs/8.3/static/ddl-constraints.html#DDL-CONSTRAINTS-FK\" rel=\"noreferre... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4196/"
] | Can anyone provide a clear explanation / example of what these functions do, and when it's appropriate to use them? | Straight from [the manual](http://www.postgresql.org/docs/8.3/static/ddl-constraints.html#DDL-CONSTRAINTS-FK)...
>
> We know that the foreign keys disallow creation of orders that do not relate to any products. But what if a product is removed after an order is created that references it? SQL allows you to handle tha... |
225,895 | <p>I'm trying to track down an issue in our system and the following code worries me. The following occurs in our doPost() method in the primary servlet (names have been changed to protect the guilty):</p>
<pre><code>...
if(Single.getInstance().firstTime()){
doPreperations();
}
normalResponse();
...
</code></pre>
... | [
{
"answer_id": 225909,
"author": "Epaga",
"author_id": 6583,
"author_profile": "https://Stackoverflow.com/users/6583",
"pm_score": 4,
"selected": false,
"text": "<p>No it won't get built over and over again. It's static, so it'll only be constructed once, right when the class is touched ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30381/"
] | I'm trying to track down an issue in our system and the following code worries me. The following occurs in our doPost() method in the primary servlet (names have been changed to protect the guilty):
```
...
if(Single.getInstance().firstTime()){
doPreperations();
}
normalResponse();
...
```
The singleton 'Single' ... | I found this on Sun's site:
>
> ### Multiple Singletons Simultaneously Loaded by Different Class Loaders
>
>
> When two class loaders load a class,
> you actually have two copies of the
> class, and each one can have its own
> Singleton instance. That is
> particularly relevant in servlets
> running in certai... |
225,915 | <p>I have a case where I have a bunch of text boxes and radio buttons on a screen all built dynamically with various DIVs. There are onblur routines for all of the text boxes to validate entry, but depending on the radio button selection, the text box entry could be invalid when it was valid originally. I can't use o... | [
{
"answer_id": 225969,
"author": "Erlend Halvorsen",
"author_id": 1920,
"author_profile": "https://Stackoverflow.com/users/1920",
"pm_score": -1,
"selected": false,
"text": "<p>First, for the love of god and all that is holy, stop writing native javascript and help yourself to some of th... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a case where I have a bunch of text boxes and radio buttons on a screen all built dynamically with various DIVs. There are onblur routines for all of the text boxes to validate entry, but depending on the radio button selection, the text box entry could be invalid when it was valid originally. I can't use onblur... | This question is a bit too involved for me at this time of the night, but I will give you this bit of advice:
```
eval("tagCreditOrDebit = document.forms[0]." + tagFactor.name.substr(0,3) + "CreditOrDebitC");
```
This can be written in a MUCH better way:
```
tagCreditOrDebit = document.forms[0][tagFactor.name.subst... |
225,916 | <p>Following on from this question <a href="https://stackoverflow.com/questions/150814/how-to-handle-an-activex-event-in-javascript">here</a></p>
<p>I have a custom ActiveX control which raises an event "BeforePageValidated" which has a parameter "args" which is an object which contains a boolean. The purpose of this ... | [
{
"answer_id": 225974,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Worked it out for myself.</p>\n\n<p>The problem was that the event was being passed down from another dll used by the activ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Following on from this question [here](https://stackoverflow.com/questions/150814/how-to-handle-an-activex-event-in-javascript)
I have a custom ActiveX control which raises an event "BeforePageValidated" which has a parameter "args" which is an object which contains a boolean. The purpose of this is to allow the clien... | Worked it out for myself.
The problem was that the event was being passed down from another dll used by the activeX control, and this is where the args class was declared.
Fixed it by creating a copy of the args class in the activeX object and using this when raising the event.
Unfortunately does mean the args class... |
225,929 | <p>I can see people asking all the time whether multiple inheritance should be included into the next version of C# or Java. C++ folks, who are fortunate enough to have this ability, say that this is like giving someone a rope to eventually hang themselves. </p>
<p>What’s the matter with multiple inheritance? Are ther... | [
{
"answer_id": 225945,
"author": "tloach",
"author_id": 14092,
"author_profile": "https://Stackoverflow.com/users/14092",
"pm_score": 4,
"selected": false,
"text": "<p>let's say you have objects A and B which are both inherited by C. A and B both implement foo() and C does not. I call ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22088/"
] | I can see people asking all the time whether multiple inheritance should be included into the next version of C# or Java. C++ folks, who are fortunate enough to have this ability, say that this is like giving someone a rope to eventually hang themselves.
What’s the matter with multiple inheritance? Are there any conc... | The most obvious problem is with function overriding.
Let's say have two classes `A` and `B`, both of which define a method `doSomething`. Now you define a third class `C`, which inherits from both `A` and `B`, but you don't override the `doSomething` method.
When the compiler seed this code...
```
C c = new C();
c.... |
225,937 | <p>There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you'd use one way over the other.</p>
<p>First type:</p>
<pre><code>List<string> someList = <some way to init>
foreach(string s in someList) {
<process the string>
}
</code></pre>
<p>Othe... | [
{
"answer_id": 225952,
"author": "Joachim Kerschbaumer",
"author_id": 20227,
"author_profile": "https://Stackoverflow.com/users/20227",
"pm_score": 4,
"selected": false,
"text": "<p>I guess the <code>someList.ForEach()</code> call could be easily parallelized whereas the normal <code>for... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450139/"
] | There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you'd use one way over the other.
First type:
```
List<string> someList = <some way to init>
foreach(string s in someList) {
<process the string>
}
```
Other Way:
```
List<string> someList = <some way to in... | There is one important, and useful, distinction between the two.
Because .ForEach uses a `for` loop to iterate the collection, this is valid (edit: **prior to .net 4.5** - the implementation changed and they both throw):
```
someList.ForEach(x => { if(x.RemoveMe) someList.Remove(x); });
```
whereas `foreach` uses ... |
225,953 | <p>Where can I find a list of all the C# Color constants and the associated R,G,B (Red, Green, Blue) values?</p>
<p>e.g.</p>
<p>Color.White == (255,255,255)</p>
<p>Color.Black == (0,0,0)</p>
<p>etc...</p>
| [
{
"answer_id": 225962,
"author": "Ryan",
"author_id": 17917,
"author_profile": "https://Stackoverflow.com/users/17917",
"pm_score": 3,
"selected": false,
"text": "<p>It looks like this <a href=\"http://www.flounder.com/csharp_color_table.htm\" rel=\"noreferrer\">page</a> has all of them.... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1816/"
] | Where can I find a list of all the C# Color constants and the associated R,G,B (Red, Green, Blue) values?
e.g.
Color.White == (255,255,255)
Color.Black == (0,0,0)
etc... | Run this program:
```
using System;
using System.Drawing;
using System.Reflection;
public class Test
{
static void Main()
{
var props = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static);
foreach (PropertyInfo prop in props)
{
Color color = (Color) prop.... |
225,984 | <p>I have a partial that renders a select box using the following method:</p>
<pre><code><%= collection_select 'type', 'id', @types, "id", "name",
{:prompt => true},
{:onchange =>
remote_function(
:loading => "Form.Element.disable('go_button')",
:url => '... | [
{
"answer_id": 486646,
"author": "Shalom Craimer",
"author_id": 54491,
"author_profile": "https://Stackoverflow.com/users/54491",
"pm_score": 2,
"selected": false,
"text": "<p>As per your \"UPDATE\", creating a custom <code>DataGridViewCell</code> is the way this is done. I've done it, a... | 2008/10/22 | [
"https://Stackoverflow.com/questions/225984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1486/"
] | I have a partial that renders a select box using the following method:
```
<%= collection_select 'type', 'id', @types, "id", "name",
{:prompt => true},
{:onchange =>
remote_function(
:loading => "Form.Element.disable('go_button')",
:url => '/sfc/criteria/services',
... | As per your "UPDATE", creating a custom `DataGridViewCell` is the way this is done. I've done it, and it doesn't require that much modification from the example code available from the MSDN. In my case, I needed a bunch of custom editing controls, so I ended up inheriting from `DataGridViewTextBoxCell` and `DataGridVie... |
226,002 | <p>Have you ever tried this before?</p>
<pre><code>static void Main(string[] args)
{
int x = 10;
x = x++;
Console.WriteLine(x);
}
</code></pre>
<p>Output: 10.</p>
<p>but for </p>
<pre><code>static void Main(string[] args)
{
int x = 10;
x++;
Console.WriteLine(x);
}
</code></pre>
<p>Output: 1... | [
{
"answer_id": 226008,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 7,
"selected": true,
"text": "<p>X++ will increment the value, but then return its old value. </p>\n\n<p>So in this case:</p>\n\n<pre><code>static v... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14118/"
] | Have you ever tried this before?
```
static void Main(string[] args)
{
int x = 10;
x = x++;
Console.WriteLine(x);
}
```
Output: 10.
but for
```
static void Main(string[] args)
{
int x = 10;
x++;
Console.WriteLine(x);
}
```
Output: 11.
Could anyone explain why this? | X++ will increment the value, but then return its old value.
So in this case:
```
static void Main(string[] args)
{
int x = 10;
x = x++;
Console.WriteLine(x);
}
```
You have X at 11 just for a moment, then it gets back to 10 because 10 is the return value of (x++).
You could instead do this for the s... |
226,042 | <p>As part of our build process we run a database update script as we deploy code to 4 different environments. Further, since the same query will get added to until we drop a release into production it <em>has</em> to be able to run multiple times on a given database. Like this:</p>
<pre><code>IF NOT EXISTS (SELECT *... | [
{
"answer_id": 226054,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 9,
"selected": true,
"text": "<p>Are you looking for <a href=\"http://msdn.microsoft.com/en-us/library/ms176011.aspx\" rel=\"noreferrer\">sys.schemas</a>?</... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2156/"
] | As part of our build process we run a database update script as we deploy code to 4 different environments. Further, since the same query will get added to until we drop a release into production it *has* to be able to run multiple times on a given database. Like this:
```
IF NOT EXISTS (SELECT * FROM sys.tables WHERE... | Are you looking for [sys.schemas](http://msdn.microsoft.com/en-us/library/ms176011.aspx)?
```
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'jim')
BEGIN
EXEC('CREATE SCHEMA jim')
END
```
Note that the `CREATE SCHEMA` must be run in its own batch (per [the answer below](https://stackoverflow.com/a/521271/2688... |
226,050 | <p>I am trying to use <code>ResourceBundle#getStringArray</code> to retrieve a <code>String[]</code> from a properties file. The description of this method in the documentation reads:</p>
<blockquote>
<p>Gets a string array for the given key from this resource bundle or one of its parents.</p>
</blockquote>
<p>Howe... | [
{
"answer_id": 226142,
"author": "Chris Kimpton",
"author_id": 48310,
"author_profile": "https://Stackoverflow.com/users/48310",
"pm_score": 3,
"selected": false,
"text": "<p>Umm, looks like this is a common problem, from threads <a href=\"http://saloon.javaranch.com/cgi-bin/ubb/ultimate... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9254/"
] | I am trying to use `ResourceBundle#getStringArray` to retrieve a `String[]` from a properties file. The description of this method in the documentation reads:
>
> Gets a string array for the given key from this resource bundle or one of its parents.
>
>
>
However, I have attempted to store the values in the prope... | A `Properties` object can hold **`Object`s**, not just `String`s. That tends to be forgotten because they're overwhelmingly used to load .properties files, and so often will only contain `String`s. [The documentation](https://web.archive.org/web/20081217073139/http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceB... |
226,064 | <p>How do I load a true color image into a CImageList?</p>
<p>Right now I have</p>
<pre><code>mImageList.Create(IDB_IMGLIST_BGTASK, 16, 1, RGB(255,0,255));
</code></pre>
<p>Where <code>IDB_IMGLIST_BGTASK</code> is a 64x16 True color image. The ClistCtrl I am using it in shows 16 bpp color. I don't see a Create ove... | [
{
"answer_id": 226104,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 4,
"selected": true,
"text": "<p>Needs 4 lines of code, but this works:</p>\n\n<pre><code>CBitmap bm;\nbm.LoadBitmap(IDB_IMGLIST_BGTASK);\nmImageList.Create(1... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] | How do I load a true color image into a CImageList?
Right now I have
```
mImageList.Create(IDB_IMGLIST_BGTASK, 16, 1, RGB(255,0,255));
```
Where `IDB_IMGLIST_BGTASK` is a 64x16 True color image. The ClistCtrl I am using it in shows 16 bpp color. I don't see a Create overload that allows me to specify both the bpp a... | Needs 4 lines of code, but this works:
```
CBitmap bm;
bm.LoadBitmap(IDB_IMGLIST_BGTASK);
mImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 4, 4);
mImageList.Add(&bm, RGB(255,0,255));
``` |
226,071 | <p>I have the HTML given below:</p>
<pre><code><ul id="thumbsPhotos">
<li src="/images/1alvaston-hall-relaxing-lg.jpg" onclick="updatePhoto (this.title)"><img src="/images/1alvaston-hall-relaxing-sl.jpg" width="56" height="56"></li>
<li onclick="updatePhoto(this.title)" src="">... | [
{
"answer_id": 226098,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>You could most likely use a RegEx replace that matches on the src attribute and do the conversion. I see that y... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30394/"
] | I have the HTML given below:
```
<ul id="thumbsPhotos">
<li src="/images/1alvaston-hall-relaxing-lg.jpg" onclick="updatePhoto (this.title)"><img src="/images/1alvaston-hall-relaxing-sl.jpg" width="56" height="56"></li>
<li onclick="updatePhoto(this.title)" src=""><img src="" width="56" height="56"></li>
... | Not tested, but here's a regex which might do it for you...
```
// find:
<li ([^>]*)src="(.*?)"(.*?)>
// replace:
<li $1title="$2"$3>
```
**Update**: tested and it works on your example.
If you wanted to run this on the client side using Javascript (for whatever whacky reason), you could do this:
```
var ul = doc... |
226,088 | <p>My predicament is fairly simple: This function gets the <code>id</code> of 'this' <code><li></code> element based on parent <code>id</code> of <code><ul></code>. It used to work fine but not any more, I will either need to have <code><ul></code> use <code>class</code>es instead of <code>id</code> ... | [
{
"answer_id": 226181,
"author": "cllpse",
"author_id": 20946,
"author_profile": "https://Stackoverflow.com/users/20946",
"pm_score": 1,
"selected": false,
"text": "<p>I'd suggest you using the jQuery framework. It will provide a nice abstraction over your DOM and make it way easier for ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/419730/"
] | My predicament is fairly simple: This function gets the `id` of 'this' `<li>` element based on parent `id` of `<ul>`. It used to work fine but not any more, I will either need to have `<ul>` use `class`es instead of `id` while still being able to assign `id` of 'current' to the current element, or change my css.
```js... | You should use classes for things like "current", not the id. The id normally shouldn't change, and "current" isn't a very good id, as you could have a bunch of things on a page that is "current" in some way. If you need some css style to override another, you can force it with !important:
```
ul#leftlist li.current a... |
226,131 | <p>Safari on iPhone automatically creates links for strings of digits that appear to the telephone numbers. I am writing a web page containing an IP address, and Safari is turning that into a phone number link. Is it possible to disable this behavior for a whole page or an element on a page?</p>
| [
{
"answer_id": 226229,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 1,
"selected": false,
"text": "<p>You could try encoding them as HTML entities:</p>\n\n<pre><code>&#48; = 0\n&#57; = 9\n</code... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10947/"
] | Safari on iPhone automatically creates links for strings of digits that appear to the telephone numbers. I am writing a web page containing an IP address, and Safari is turning that into a phone number link. Is it possible to disable this behavior for a whole page or an element on a page? | This seems to be the right thing to do, according to the [Safari HTML Reference](https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Introduction.html):
```
<meta name="format-detection" content="telephone=no">
```
If you disable this but still want telephone links, yo... |
226,144 | <p>We all know that you can overload a function according to the parameters:</p>
<pre><code>int mul(int i, int j) { return i*j; }
std::string mul(char c, int n) { return std::string(n, c); }
</code></pre>
<p>Can you overload a function according to the return value? Define a function that returns different things ac... | [
{
"answer_id": 226165,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know, you can't (big pity, though...). As a workaround, you can define an 'out' parameter instead, and overloa... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | We all know that you can overload a function according to the parameters:
```
int mul(int i, int j) { return i*j; }
std::string mul(char c, int n) { return std::string(n, c); }
```
Can you overload a function according to the return value? Define a function that returns different things according to how the return ... | ```
class mul
{
public:
mul(int p1, int p2)
{
param1 = p1;
param2 = p2;
}
operator int ()
{
return param1 * param2;
}
operator std::string ()
{
return std::string(param2, param1 + '0');
}
private:
int param1;
int param2;
};
```
Not that I w... |
226,157 | <p>I have a web service that has 8 web methods. These methods are called synchronously, the first call authenticates the user, and the rest of the methods perform a unit of work, these methods are called upon until the work is done.</p>
<p>I need to store the state of the work (e.g. what actions to perform next, and w... | [
{
"answer_id": 226185,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 0,
"selected": false,
"text": "<p>Idea 2 is mimicking Session state management. I don't see an intrinsic benefit from performing your own session statemen... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a web service that has 8 web methods. These methods are called synchronously, the first call authenticates the user, and the rest of the methods perform a unit of work, these methods are called upon until the work is done.
I need to store the state of the work (e.g. what actions to perform next, and what work h... | You should take a look at [Windows Workflow Foundation (WF)](http://msdn.microsoft.com/en-us/netframework/aa663328.aspx). You can design your workflow, then plug in persistence models and such.
That being said - you can't use the session! it won't scale once you create multiple web farms/servers. Surely the QBW develo... |
226,206 | <p>I would actually love to have an AlternatingItemTemplate on a GridView, but all it offers is an AlternatingItemStyle. In my grid, each two column row (in a table layout), has an image in the first column, and a description in the second column. I would like to have the positioning of the image and description alte... | [
{
"answer_id": 226230,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>You will need to either handle the data binding event to try and determine if it is an item or alternating item... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | I would actually love to have an AlternatingItemTemplate on a GridView, but all it offers is an AlternatingItemStyle. In my grid, each two column row (in a table layout), has an image in the first column, and a description in the second column. I would like to have the positioning of the image and description alternate... | You might consider managing this with AlternatingItemStyle for fun.
Use 1 column or a repeater:
Item Template:
```
<div class="MyImage"><img src="" /></div>
<div class="MyDescription">Blah...Blah...</div>
```
CSS:
```
.MyItemStyle .MyImage {width:49%; float:left;}
.MyItemStyle .MyDescription {width:49%; float:rig... |
226,221 | <p>I'd like to do something like this</p>
<blockquote>
<pre><code>raiserror(concat('Error in case @isFishy =', @isFishy, ' @isSmarmy=', @isSmarmy, ' @isTasty = ', @isTasty), 10, 1)
--or
raiserror('Error in case @isFishy =' + @isFishy + ' @isSmarmy=' + @isSmarmy + ' @isTasty = ' + @isTasty, 10, 1)
</code></pre>
</block... | [
{
"answer_id": 226245,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>I use raiserror a lot. We have some stored procedures that are called from a .Net app each night for batch process... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8435/"
] | I'd like to do something like this
>
>
> ```
> raiserror(concat('Error in case @isFishy =', @isFishy, ' @isSmarmy=', @isSmarmy, ' @isTasty = ', @isTasty), 10, 1)
> --or
> raiserror('Error in case @isFishy =' + @isFishy + ' @isSmarmy=' + @isSmarmy + ' @isTasty = ' + @isTasty, 10, 1)
>
> ```
>
>
But it just isn't ... | The error message in RAISERROR has actually similar syntax to printf function in C, so assuming your arguments are of the type of integer you would need to use:
```
raiserror(N'Error in case @isFishy = %d @isSmarmy = %d @isTasty = %d',10,1,@isFishy,@isSmarmy,@isTasty)
```
check out [BOL](http://msdn.microsoft.com/en... |
226,271 | <p>I know how to find out the current domain name in PHP already, the problem is when I put this code into a file and then include it from another server it shows the domain name of where the file is located. Is there any way for it to find out the domain or the site containing the include() code?</p>
| [
{
"answer_id": 226283,
"author": "Christian P.",
"author_id": 9479,
"author_profile": "https://Stackoverflow.com/users/9479",
"pm_score": 0,
"selected": false,
"text": "<p>If you include a PHP page from another server, the page will get parsed by the original server and the result will b... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] | I know how to find out the current domain name in PHP already, the problem is when I put this code into a file and then include it from another server it shows the domain name of where the file is located. Is there any way for it to find out the domain or the site containing the include() code? | You can run it locally using "eval" then it should use the proper domain
store your script as a text file then download it and then execute:
```
eval(file_get_contents("http://someDomain.com/somePhpscript.txt"));
``` |
226,272 | <p>I have one user who gets an error message when he closes his browser. This only happens when he has visited a page which contains my applet. It seems to have been registered as a bug at Sun but that was many years ago. He is using Java 1.6 and IE7.</p>
<p>Has anyone seen this before and know a solution or work-arou... | [
{
"answer_id": 226298,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 2,
"selected": true,
"text": "<p>I used to get that error a lot for just about every applet that was loaded in the browser. I never figured out <em>how</em>... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11249/"
] | I have one user who gets an error message when he closes his browser. This only happens when he has visited a page which contains my applet. It seems to have been registered as a bug at Sun but that was many years ago. He is using Java 1.6 and IE7.
Has anyone seen this before and know a solution or work-around?
```
j... | I used to get that error a lot for just about every applet that was loaded in the browser. I never figured out *how*, but Google Desktop was breaking java in some way. After uninstalling google desktop the error went away. |
226,280 | <p>In eclipse 3.4 I'm trying to do some performance tests on a large product, one of the included libraries is the vecmath.jar (javax.vecmath package) from the Java3D project. Everything was working fine and then when trying to run it yesterday I get this exception/error not long after starting it up:</p>
<pre><code>... | [
{
"answer_id": 226385,
"author": "jassuncao",
"author_id": 1009,
"author_profile": "https://Stackoverflow.com/users/1009",
"pm_score": 0,
"selected": false,
"text": "<p>I believe JRE 1.5 is required for the latest version of Java3D.</p>\n"
},
{
"answer_id": 226463,
"author": ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25920/"
] | In eclipse 3.4 I'm trying to do some performance tests on a large product, one of the included libraries is the vecmath.jar (javax.vecmath package) from the Java3D project. Everything was working fine and then when trying to run it yesterday I get this exception/error not long after starting it up:
```
java.lang.Unsup... | Could there be another javax.vecmath.Point2f on your classpath? |
226,288 | <p>When creating a new build in Team Foundation Server, I get the following error when attempting to run the new build:</p>
<blockquote>
<p>The path
C:\Build\ProductReleases\FullBuildv5.4.2x\Sources
is already mapped to workspace
BuildServer_23.</p>
</blockquote>
<p>I am unable to see a workspace by that name... | [
{
"answer_id": 226304,
"author": "NotMyself",
"author_id": 303,
"author_profile": "https://Stackoverflow.com/users/303",
"pm_score": 8,
"selected": true,
"text": "<p>Use the command line utility <em>TF - Team Foundation Version Control Tool</em> (<strong>tf</strong>).</p>\n\n<p>You can g... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303/"
] | When creating a new build in Team Foundation Server, I get the following error when attempting to run the new build:
>
> The path
> C:\Build\ProductReleases\FullBuildv5.4.2x\Sources
> is already mapped to workspace
> BuildServer\_23.
>
>
>
I am unable to see a workspace by that name in the workspaces dialog. | Use the command line utility *TF - Team Foundation Version Control Tool* (**tf**).
You can get a list of all workspaces by bringing up a *Visual Studio Command Prompt* then changing to your workspace folder and issuing the following commands:
```
C:\YourWorkspaceFolder>tf workspaces /owner:*
```
You should see your... |
226,300 | <p>What I want to do is an outer join to a table, where I exclude records from the joined table based on matching a constant, however keep records from the main table. For example:</p>
<pre><code>SELECT a.id, a.other, b.baz
FROM a
LEFT OUTER JOIN b
ON a.id = b.id
AND b.bar = 'foo'
</code></pre>
<p>Expected resul... | [
{
"answer_id": 231338,
"author": "DJ.",
"author_id": 10492,
"author_profile": "https://Stackoverflow.com/users/10492",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if you can do this in Crystal but how about joining to a Select?</p>\n\n<pre><code>SELECT a.id, x.baz\nFROM a\nLEF... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20068/"
] | What I want to do is an outer join to a table, where I exclude records from the joined table based on matching a constant, however keep records from the main table. For example:
```
SELECT a.id, a.other, b.baz
FROM a
LEFT OUTER JOIN b
ON a.id = b.id
AND b.bar = 'foo'
```
Expected results:
```
id other ... | Crystal reports can't generate that commonly used SQL statement based on its links and report selection criteria. You have to use a "command" or build a view.
In short, Crystal sucks. |
226,302 | <p>It seems safe to cast the result of my vector's <code>size()</code> function to an <code>unsigned int</code>. How can I tell for sure, though? My documentation isn't clear about how <code>size_type</code> is defined.</p>
| [
{
"answer_id": 226309,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>According to the standard, <em>you cannot be sure</em>. The exact type depends on your machine. You can look at th... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11575/"
] | It seems safe to cast the result of my vector's `size()` function to an `unsigned int`. How can I tell for sure, though? My documentation isn't clear about how `size_type` is defined. | Do not assume the type of the container size (or anything else typed inside).
### Today?
The best solution for now is to use:
```
std::vector<T>::size_type
```
Where T is your type. For example:
```
std::vector<std::string>::size_type i ;
std::vector<int>::size_type j ;
std::vector<std::vector<double> >::size_typ... |
226,315 | <p>I'm using polar plots (POLAR(THETA,RHO)) in MATLAB.</p>
<p>Is there an easy way to fix the range for the radial axis to say, 1.5?</p>
<p>I'm looking for something analogous to the xlim, ylim commands for cartesian axes. Haven't found anything in the docs yet.</p>
| [
{
"answer_id": 226493,
"author": "Tim Whitcomb",
"author_id": 24895,
"author_profile": "https://Stackoverflow.com/users/24895",
"pm_score": 4,
"selected": true,
"text": "<p>Here's how I was able to do it. </p>\n\n<p>The MATLAB polar plot (if you look at the Handle Graphics options avail... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20688/"
] | I'm using polar plots (POLAR(THETA,RHO)) in MATLAB.
Is there an easy way to fix the range for the radial axis to say, 1.5?
I'm looking for something analogous to the xlim, ylim commands for cartesian axes. Haven't found anything in the docs yet. | Here's how I was able to do it.
The MATLAB polar plot (if you look at the Handle Graphics options available) does not have anything like xlim or ylim. However, I realized that the first thing plotted sets the range, so I was able to plot a function with radius range [-.5 .5] on a [-1 1] plot as follows:
```
theta =... |
226,354 | <p>I'm trying to drag a <code>CALayer</code> in an iOS app.</p>
<p>As soon as I change its position property it tries to animate to the new position and flickers all over the place:</p>
<pre><code> layer.position = CGPointMake(x, y)
</code></pre>
<p>How can I move <code>CALayers</code> instantly? I can't seem to get... | [
{
"answer_id": 226761,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 8,
"selected": true,
"text": "<p>You want to wrap your call in the following:</p>\n\n<pre><code>[CATransaction begin]; \n[CATransaction setValue: (id)... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30420/"
] | I'm trying to drag a `CALayer` in an iOS app.
As soon as I change its position property it tries to animate to the new position and flickers all over the place:
```
layer.position = CGPointMake(x, y)
```
How can I move `CALayers` instantly? I can't seem to get my head around the Core Animation API. | You want to wrap your call in the following:
```
[CATransaction begin];
[CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];
layer.position = CGPointMake(x, y);
[CATransaction commit];
``` |
226,356 | <p>I am having trouble understanding how the System Registry can help me convert a DateTime object into the a corresponding TimeZone. I have an example that I've been trying to reverse engineer but I just can't follow the one critical step in which the UTCtime is offset depending on Daylight Savings Time.</p>
<p>I am... | [
{
"answer_id": 226408,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 2,
"selected": false,
"text": "<p>You can use DateTimeOffset to get the UTC offset so you shouldn't need to dig into the registry for that information.</p>... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30408/"
] | I am having trouble understanding how the System Registry can help me convert a DateTime object into the a corresponding TimeZone. I have an example that I've been trying to reverse engineer but I just can't follow the one critical step in which the UTCtime is offset depending on Daylight Savings Time.
I am using .NET... | Here is a code snippet in C# that I'm using in my WPF application. This will give you the current time (adjusted for Daylight Savings Time) for the time zone id you provide.
```
// _timeZoneId is the String value found in the System Registry.
// You can look up the list of TimeZones on your system using this:
// ReadO... |
226,365 | <p>I have a UIImagePickerController as one view in a TabBar setup. Is it possible to tell the UIImagePickerController to not show the Cancel button in the top navigation bar when browsing photos libraries?</p>
| [
{
"answer_id": 226408,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 2,
"selected": false,
"text": "<p>You can use DateTimeOffset to get the UTC offset so you shouldn't need to dig into the registry for that information.</p>... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29263/"
] | I have a UIImagePickerController as one view in a TabBar setup. Is it possible to tell the UIImagePickerController to not show the Cancel button in the top navigation bar when browsing photos libraries? | Here is a code snippet in C# that I'm using in my WPF application. This will give you the current time (adjusted for Daylight Savings Time) for the time zone id you provide.
```
// _timeZoneId is the String value found in the System Registry.
// You can look up the list of TimeZones on your system using this:
// ReadO... |
226,382 | <p>I have SQL query, which is working nice on Oracle and MSSQL. Now I'm trying this on PostgreSQL and it gives a strange exception: <code>org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "main"</code></p>
<p>Here is the query: </p>
<pre><code>SELECT *
FROM "main" main
INNER JOIN "som... | [
{
"answer_id": 226497,
"author": "l_39217_l",
"author_id": 13633,
"author_profile": "https://Stackoverflow.com/users/13633",
"pm_score": 2,
"selected": false,
"text": "<p>somehting=>something</p>\n\n<pre>\n\npostgres=# create database test\npostgres-# ;\nCREATE DATABASE\n\npostgres=# \\c... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/446104/"
] | I have SQL query, which is working nice on Oracle and MSSQL. Now I'm trying this on PostgreSQL and it gives a strange exception: `org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "main"`
Here is the query:
```
SELECT *
FROM "main" main
INNER JOIN "something_link" something_link ON m... | According to [this](http://sql-info.de/en/postgresql/postgres-gotchas.html#1_5), seems like you either mistyped an alias or used a table name in place of it. |
226,392 | <p>We have an intranet asp.net web application which uses the OOTB ASP.net membership and role providers. </p>
<p>Now we are planning to expose the application to internet, by moving the web server to the DMZ as represented in the following (crappy) text diagram</p>
<pre>
External Int... | [
{
"answer_id": 226416,
"author": "Chris Tybur",
"author_id": 741,
"author_profile": "https://Stackoverflow.com/users/741",
"pm_score": 1,
"selected": false,
"text": "<p>We have a couple of Internet-facing web servers in a DMZ and had to open tunnels in our firewall back to the SQL server... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/747/"
] | We have an intranet asp.net web application which uses the OOTB ASP.net membership and role providers.
Now we are planning to expose the application to internet, by moving the web server to the DMZ as represented in the following (crappy) text diagram
```
External Internal
inter... | Changing your DMZ policy and opening ports is usually REALLY hard. You might have better success doing what I did: expose a WCF service inside the network and communicate with it over HTTP on port 80.
Zero friction with the LAN folks, and I just mimic the same exact (though crappy) API that .NET gives us :)
Edit: to ... |
226,405 | <p>Anyone know how to get the position of a node using XPath?</p>
<p>Say I have the following xml:</p>
<pre><code><a>
<b>zyx</b>
<b>wvu</b>
<b>tsr</b>
<b>qpo</b>
</a>
</code></pre>
<p>I can use the following xpath query to select the third <... | [
{
"answer_id": 226616,
"author": "Steven Huwig",
"author_id": 28604,
"author_profile": "https://Stackoverflow.com/users/28604",
"pm_score": 3,
"selected": false,
"text": "<p>You can do this with XSLT but I'm not sure about straight XPath.</p>\n\n<pre><code><?xml version=\"1.0\" encodi... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6124/"
] | Anyone know how to get the position of a node using XPath?
Say I have the following xml:
```
<a>
<b>zyx</b>
<b>wvu</b>
<b>tsr</b>
<b>qpo</b>
</a>
```
I can use the following xpath query to select the third <b> node (<b>tsr</b>):
```
a/b[.='tsr']
```
Which is all well and good but I want to **retu... | Try:
```
count(a/b[.='tsr']/preceding-sibling::*)+1.
``` |
226,420 | <p>Is there a way in C# or .NET in general to create an attribute on a method which triggers an event when the method is invoked? Ideally, I would be able to run custom actions before and after the invocation of the method.</p>
<p>I mean something like this:</p>
<pre><code>[TriggersMyCustomAction()]
public void DoSom... | [
{
"answer_id": 226440,
"author": "OwenP",
"author_id": 2547,
"author_profile": "https://Stackoverflow.com/users/2547",
"pm_score": 5,
"selected": true,
"text": "<p>The only way I know how to do this is with <a href=\"https://www.postsharp.net/\" rel=\"noreferrer\">PostSharp</a>. It post... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8954/"
] | Is there a way in C# or .NET in general to create an attribute on a method which triggers an event when the method is invoked? Ideally, I would be able to run custom actions before and after the invocation of the method.
I mean something like this:
```
[TriggersMyCustomAction()]
public void DoSomeStuff()
{
}
```
I ... | The only way I know how to do this is with [PostSharp](https://www.postsharp.net/). It post-processes your IL and can do things like what you asked for. |
226,436 | <p>I have a custom control that exposes a property. When I set it using a fixed value, everything works correctly. But if I try to set its value using the <%= %> tags, it goes a little whacky:</p>
<pre><code><cc:CustomControl ID="CustomControl" runat="server" Property1='<%= MyProperty %>' />
<%= My... | [
{
"answer_id": 226452,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 1,
"selected": false,
"text": "<p>Try <%# MyProperty %> in the CustomControl and see if that works.</p>\n"
},
{
"answer_id": 226483,
"author... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | I have a custom control that exposes a property. When I set it using a fixed value, everything works correctly. But if I try to set its value using the <%= %> tags, it goes a little whacky:
```
<cc:CustomControl ID="CustomControl" runat="server" Property1='<%= MyProperty %>' />
<%= MyProperty %>
```
When this gets r... | You control is initialized from the markup during `OnInit`. So if that syntax worked, it wouldn't have the effect you wanted anyway, since `MyProperty` would be evaluated during `OnInit` and not at render time (like it is with the second usage).
You want to use the data binding syntax instead:
```
<cc:CustomControl I... |
226,445 | <p>As every Haxe developer knows, you could use <code>haxe.Timer.delayed()</code> to delay function call for some time. But this function doesn't exist for Neko at all. Is there a way to achieve the same results?</p>
| [
{
"answer_id": 226489,
"author": "vava",
"author_id": 6258,
"author_profile": "https://Stackoverflow.com/users/6258",
"pm_score": 3,
"selected": true,
"text": "<p>Have to check it first but </p>\n\n<pre><code>function delayed(f, time) {\n neko.vm.Thread.create(function() {\n neko... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6258/"
] | As every Haxe developer knows, you could use `haxe.Timer.delayed()` to delay function call for some time. But this function doesn't exist for Neko at all. Is there a way to achieve the same results? | Have to check it first but
```
function delayed(f, time) {
neko.vm.Thread.create(function() {
neko.Sys.sleep(time);
f();
});
}
```
might be the closest thing possible. The only cons is that application becomes multi threaded which could lead to serious problems. |
226,455 | <p>Someone at work just asked for the reasoning behind having to wrap a wait inside a synchronized.</p>
<p>Honestly I can't see the reasoning. I understand what the javadocs say--that the thread needs to be the owner of the object's monitor, but why? What problems does it prevent? (And if it's actually necessary, w... | [
{
"answer_id": 226479,
"author": "64BitBob",
"author_id": 16339,
"author_profile": "https://Stackoverflow.com/users/16339",
"pm_score": 4,
"selected": true,
"text": "<p>If the object does not own the object monitor when it calls Object.wait(), it will not be able to access the object to ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12943/"
] | Someone at work just asked for the reasoning behind having to wrap a wait inside a synchronized.
Honestly I can't see the reasoning. I understand what the javadocs say--that the thread needs to be the owner of the object's monitor, but why? What problems does it prevent? (And if it's actually necessary, why can't the ... | If the object does not own the object monitor when it calls Object.wait(), it will not be able to access the object to setup a notify listener until the the monitor is released. Instead, it will be treated as a thread attempting to access a method on a synchronized object.
Or to put it another way, there is no differe... |
226,460 | <p>I am trying to write a query for SQL Server 2005 but I can't figure out how to do it. I have a table with the following fields:</p>
<p><strong>MessageID int<br/>
CategoryID int<br/>
Priority tinyint<br/>
MessageText NVARCHAR(MAX)<br/></strong></p>
<p>I need a query that will return * for each row that has the hig... | [
{
"answer_id": 226490,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 1,
"selected": false,
"text": "<p>I believe that this should work, table name assumed as Messages</p>\n\n<pre><code>SELECT\n M.MessageId,\n ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | I am trying to write a query for SQL Server 2005 but I can't figure out how to do it. I have a table with the following fields:
**MessageID int
CategoryID int
Priority tinyint
MessageText NVARCHAR(MAX)**
I need a query that will return \* for each row that has the highest priority within a Category. For exam... | Verified:
```
SELECT
highest_priority_messages.*
FROM
(
SELECT
m.MessageID
, m.CategoryID
, m.Priority
, m.MessageText
, Rank() OVER
(PARTITION BY m.CategoryID ORDER BY m.Priority DESC) AS p_rank
FROM [Message] m
GROUP BY
m.CategoryID
, m.Priority
... |
226,465 | <p>Here's a silly fun question:</p>
<p>Let's say we have to perform a simple operation where we need half of the value of a variable. There are <em>typically</em> two ways of doing this:</p>
<pre><code>y = x / 2.0;
// or...
y = x * 0.5;
</code></pre>
<p>Assuming we're using the standard operators provided with the l... | [
{
"answer_id": 226494,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>I have always learned that multiplication is more efficient.</p>\n"
},
{
"answer_id": 226502,
"author"... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20494/"
] | Here's a silly fun question:
Let's say we have to perform a simple operation where we need half of the value of a variable. There are *typically* two ways of doing this:
```
y = x / 2.0;
// or...
y = x * 0.5;
```
Assuming we're using the standard operators provided with the language, which one has better performanc... | I think this is getting so nitpicky that you would be better off doing whatever makes the code more readable. Unless you perform the operations thousands, if not millions, of times, I doubt anyone will ever notice the difference.
If you really have to make the choice, benchmarking is the only way to go. Find what func... |
226,473 | <p>I'm betting that someone has already solved this and maybe I'm using the wrong search terms for google to tell me the answer, but here is my situation.</p>
<p>I have a script that I want to run, but I want it to run only when scheduled and only one at a time. (can't run the script simultaneously) </p>
<p>Now the... | [
{
"answer_id": 226531,
"author": "Steven Huwig",
"author_id": 28604,
"author_profile": "https://Stackoverflow.com/users/28604",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the at(1) command inside your script to schedule its next run. Before it exits, it can check myhappysc... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30413/"
] | I'm betting that someone has already solved this and maybe I'm using the wrong search terms for google to tell me the answer, but here is my situation.
I have a script that I want to run, but I want it to run only when scheduled and only one at a time. (can't run the script simultaneously)
Now the sticky part is tha... | add a column `exec_status` to `myhappytable` (maybe also `time_started` and `time_finished`, see pseudocode)
run the following cron script every x minutes
pseudocode of cron script:
```
[create/check pid lock (optional, but see "A potential pitfall" below)]
get number of rows from myhappytable where (exec_status == ... |
226,505 | <p>I have the following regex that does a great job matching urls: </p>
<pre><code>((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)`
</code></pre>
<p>However, it does not handle urls without a prefix, ie. <strong>stackoverflow.com</strong> or <strong>www.google.com</stron... | [
{
"answer_id": 226556,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": -1,
"selected": false,
"text": "<p>Just use:</p>\n\n<pre><code>.*\n</code></pre>\n\n<p>i.e. match everything. </p>\n\n<p>The things you want to matc... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | I have the following regex that does a great job matching urls:
```
((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)`
```
However, it does not handle urls without a prefix, ie. **stackoverflow.com** or **www.google.com** do not match. Anyone know how I can modify this regex... | The below regex is from the wonderful [Mastering Regular Expressions](http://www.amazon.co.uk/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/ref=sr_1_1/279-4458937-3540756?ie=UTF8&s=books&qid=1224694042&sr=8-1) book. If you are not familiar with the [free spacing/comments mode](http://www.regular-expression... |
226,510 | <p>Say I have a form like:</p>
<pre><code>class GeneralForm(forms.Form):
field1 = forms.IntegerField(required=False)
field2 = forms. IntegerField(required=False)
</code></pre>
<p>And I want to show it twice on a page within one form tag each time with a different prefix e.g.,:</p>
<pre><code>rest of page ...... | [
{
"answer_id": 226568,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 6,
"selected": true,
"text": "<p>You process each form as you normally would, ensuring that you create instances which have the same prefixes as tho... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13009/"
] | Say I have a form like:
```
class GeneralForm(forms.Form):
field1 = forms.IntegerField(required=False)
field2 = forms. IntegerField(required=False)
```
And I want to show it twice on a page within one form tag each time with a different prefix e.g.,:
```
rest of page ...
<form ..>
GeneralForm(data,prefix="f... | You process each form as you normally would, ensuring that you create instances which have the same prefixes as those used to generate the form initially.
Here's a slightly awkward example using the form you've given, as I don't know what the exact use case is:
```
def some_view(request):
if request.method == 'PO... |
226,514 | <p>I seem to remember reading that it's possible to declare taglib directives such as:</p>
<pre><code><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
</code></pre>
<p>in web.xml. This eliminates the need to duplicate this directive in every JSP file where the taglib is used. Could someone tell ... | [
{
"answer_id": 226585,
"author": "David M. Karr",
"author_id": 10508,
"author_profile": "https://Stackoverflow.com/users/10508",
"pm_score": 3,
"selected": false,
"text": "<p>Sorry, you're slightly mistaken. If a page uses a taglib, you have to have a taglib directive for it on the page... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I seem to remember reading that it's possible to declare taglib directives such as:
```
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
```
in web.xml. This eliminates the need to duplicate this directive in every JSP file where the taglib is used. Could someone tell me *how* these directives can be... | The `taglib` element in web.xml serves a different purpose to the `taglib` directive which you have above.
As David said, the `taglib` directive is required on each page.
If you have many pages which use common taglibs, you can shortcut this by putting the taglib directives into an include file, and including this fi... |
226,528 | <p>In Django templates, is there a variable in the context (e.g. <code>{{ BASE\_URL }}</code>, <code>{{ ROOT\_URL }}</code>, or <code>{{ MEDIA\_URL }}</code> that one can use to link to the <code>home</code> url of a project?</p>
<p>I.e. if Django is running in the root of a project, the variable (let's call it R) <co... | [
{
"answer_id": 226536,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 4,
"selected": false,
"text": "<p>I always use something like <code><a href=\"/\"></code> (assuming your home is at the root, of course). I seem to ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] | In Django templates, is there a variable in the context (e.g. `{{ BASE\_URL }}`, `{{ ROOT\_URL }}`, or `{{ MEDIA\_URL }}` that one can use to link to the `home` url of a project?
I.e. if Django is running in the root of a project, the variable (let's call it R) `{{ R }}` in a template would be `/`. If the root url is ... | You could give the URL configuration which you're using to handle the home page a name and use that:
urls.py:
```
from django.conf.urls.defaults import *
urlpatterns = patterns('myproject.views',
url(r'^$', 'index', name='index'),
)
```
Templates:
```
<a href="{% url index %}">...
```
**UPDATE:** Newer vers... |
226,555 | <p>I am trying to make a view slide from top to bottom. This is not a big deal, I used <code>CABasicAnimation</code> for this. The problem is when I want to remove the view. I use this animation.</p>
<pre><code>CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation set... | [
{
"answer_id": 226645,
"author": "Rob Drimmie",
"author_id": 24213,
"author_profile": "https://Stackoverflow.com/users/24213",
"pm_score": -1,
"selected": false,
"text": "<p>Can you set the view's hidden property to YES?</p>\n\n<p>I think it would be:</p>\n\n<pre><code>self.view.hidden =... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29642/"
] | I am trying to make a view slide from top to bottom. This is not a big deal, I used `CABasicAnimation` for this. The problem is when I want to remove the view. I use this animation.
```
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDelegate:self];
animation... | Well, according to the Apple sample "MoveMe", this (**removedOnCompletion**) should work, however, it doesn't seem to.
So, add these lines after your code:
````
[self.view.layer addAnimation:animation forKey:@"moveX"];
self.view.layer.position = [animation.toValue CGPointValue];
````
This ensures that after the a... |
226,561 | <p>The auto-collapse feature for <em>code</em> properties is neat AFTER you've got your properties all worked out, but while you're still editing them I find the feature to be REALLY annoying.</p>
<p><strong>How can you disable it?</strong></p>
<p>(I'm in VS2008 if it makes a difference)</p>
<p>Edit: I'm not talking... | [
{
"answer_id": 226673,
"author": "matt.mercieca",
"author_id": 30407,
"author_profile": "https://Stackoverflow.com/users/30407",
"pm_score": -1,
"selected": false,
"text": "<p>When the window is open, click on the pin in the upper right hand corner (the middle icon between the X and the ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] | The auto-collapse feature for *code* properties is neat AFTER you've got your properties all worked out, but while you're still editing them I find the feature to be REALLY annoying.
**How can you disable it?**
(I'm in VS2008 if it makes a difference)
Edit: I'm not talking about the Property Window... I'm talking ab... | From the EDIT menu, choose OUTLINING, STOP OUTLINING. You can also use the keyboard shortcut CTRL+M, CTRL+P. |
226,562 | <p>I am not very good with Regex but I am learning.</p>
<p>I would like to remove some html tag by the class name. This is what I have so far :</p>
<pre><code><div class="footer".*?>(.*?)</div>
</code></pre>
<p>The first .*? is because it might contain other attribute and the second is it might co... | [
{
"answer_id": 226583,
"author": "Hamish Downer",
"author_id": 3189,
"author_profile": "https://Stackoverflow.com/users/3189",
"pm_score": 0,
"selected": false,
"text": "<p>Partly depends on the exact regex engine you are using - which language etc. But one possibility is that you need... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | I am not very good with Regex but I am learning.
I would like to remove some html tag by the class name. This is what I have so far :
```
<div class="footer".*?>(.*?)</div>
```
The first .\*? is because it might contain other attribute and the second is it might contain other html stuff.
What am I doing wrong? I h... | You will also want to allow for other things before class in the div tag
```
<div[^>]*class="footer"[^>]*>(.*?)</div>
```
Also, go case-insensitive. You may need to escape things like the quotes, or the slash in the closing tag. What context are you doing this in?
Also note that HTML parsing with regular expression... |
226,577 | <p>Strange program hang, what does this mean in debug?</p>
<p>After attaching windbg I found the following:</p>
<pre>
(1714.258): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=015b5c74 ebx=178a13e0 ec... | [
{
"answer_id": 226590,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 2,
"selected": false,
"text": "<p>The ecx register has an invalid address (dddddddd). I would suggest this is a case of memory corruption. Consider ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | Strange program hang, what does this mean in debug?
After attaching windbg I found the following:
```
(1714.258): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=015b5c74 ebx=178a13e0 ecx=dddddddd edx=... | **The problem**
1. First chance exceptions means that the debugger is giving you, the person who is using the debugger, the first chance to debug the exception, before it throws it back at the program to handle the issue.
2. In this case the exception is "Access violation". This means that your program is trying to re... |
226,587 | <p><strong>NOTE:</strong> Using .NET 2.0, and VS2005 as IDE</p>
<p>Hello all,</p>
<p>I'm working on logging webservice calls to our database, and finally got the SoapExtension configured and running using a very stripped-down implementation that was ported over from another project. I've set it up in the configurati... | [
{
"answer_id": 226800,
"author": "Jay S",
"author_id": 30440,
"author_profile": "https://Stackoverflow.com/users/30440",
"pm_score": 3,
"selected": true,
"text": "<p>After some trial and error, I have been able to solve this issue. While I do not entirely understand why, the SoapMessage... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30440/"
] | **NOTE:** Using .NET 2.0, and VS2005 as IDE
Hello all,
I'm working on logging webservice calls to our database, and finally got the SoapExtension configured and running using a very stripped-down implementation that was ported over from another project. I've set it up in the configuration file so it will run for all ... | After some trial and error, I have been able to solve this issue. While I do not entirely understand why, the SoapMessage object is not completely initialized at the BeforeDeserialize stage. Both the Action and MethodInfo properties throw errors at this stage.
However, during the AfterSerialize stage, these objects se... |
226,596 | <p>What's the best way to initialize an array in PowerShell?</p>
<p>For example, the code</p>
<pre><code>$array = @()
for($i=0; $i -lt 5;$i++)
{
$array[$i] = $FALSE
}
</code></pre>
<p>generates the error</p>
<pre><code>Array assignment failed because index '0' was out of range.
At H:\Software\PowerShell\TestArr... | [
{
"answer_id": 226600,
"author": "Eric Ness",
"author_id": 18891,
"author_profile": "https://Stackoverflow.com/users/18891",
"pm_score": 3,
"selected": false,
"text": "<p>The solution I found was to use the New-Object cmdlet to initialize an array of the proper size.</p>\n\n<pre><code>$a... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18891/"
] | What's the best way to initialize an array in PowerShell?
For example, the code
```
$array = @()
for($i=0; $i -lt 5;$i++)
{
$array[$i] = $FALSE
}
```
generates the error
```
Array assignment failed because index '0' was out of range.
At H:\Software\PowerShell\TestArray.ps1:4 char:10
+ $array[$ <<<< i] ... | Yet another alternative:
```
for ($i = 0; $i -lt 5; $i++)
{
$arr += @($false)
}
```
This one works if $arr isn't defined yet.
**NOTE** - there are better (and more performant) ways to do this... see <https://stackoverflow.com/a/234060/4570> below as an example. |
226,599 | <p>So I have xml that looks like this:
</p>
<pre class="lang-html prettyprint-override"><code><todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
&l... | [
{
"answer_id": 226614,
"author": "Steve Horn",
"author_id": 10589,
"author_profile": "https://Stackoverflow.com/users/10589",
"pm_score": 5,
"selected": false,
"text": "<p>Boils down to using xsd.exe from tools in VS:</p>\n\n<pre><code>xsd.exe \"%xsdFile%\" /c /out:\"%outDirectory%\" /l:... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] | So I have xml that looks like this:
```html
<todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
<milestone-id type="integer">#{milestone_id}</milestone-id>
<position type="integer">#{position}</positi... | Create a class for each element that has a property for each element and a List or Array of objects (use the created one) for each child element. Then call System.Xml.Serialization.XmlSerializer.Deserialize on the string and cast the result as your object. Use the System.Xml.Serialization attributes to make adjustments... |
226,618 | <p>How can I transform a time value into YYYY-MM-DD format in Java?</p>
<pre><code>long lastmodified = file.lastModified();
String lasmod = /*TODO: Transform it to this format YYYY-MM-DD*/
</code></pre>
| [
{
"answer_id": 226638,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 6,
"selected": true,
"text": "<p>Something like:</p>\n\n<pre><code>Date lm = new Date(lastmodified);\nString lasmod = new SimpleDateFormat(\"yyyy-MM-dd\").... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | How can I transform a time value into YYYY-MM-DD format in Java?
```
long lastmodified = file.lastModified();
String lasmod = /*TODO: Transform it to this format YYYY-MM-DD*/
``` | Something like:
```
Date lm = new Date(lastmodified);
String lasmod = new SimpleDateFormat("yyyy-MM-dd").format(lm);
```
See the javadoc for [SimpleDateFormat](http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html). |
226,637 | <p>On a page from a website (one of ours) I can enter in the url the following code:</p>
<pre><code>javascript:createNewWindow('Something', 100, 100, 'Text')
</code></pre>
<p>Is there a way someone can exploit this?</p>
<pre><code>function createNewWindow(url, widthIn, heightIn, title)
{
var str... | [
{
"answer_id": 226877,
"author": "Adam Ness",
"author_id": 21973,
"author_profile": "https://Stackoverflow.com/users/21973",
"pm_score": 1,
"selected": false,
"text": "<p>Given that code, the createNewWindow() script isn't any more vulnerable than the raw javascript. </p>\n"
},
{
... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2357/"
] | On a page from a website (one of ours) I can enter in the url the following code:
```
javascript:createNewWindow('Something', 100, 100, 'Text')
```
Is there a way someone can exploit this?
```
function createNewWindow(url, widthIn, heightIn, title)
{
var strOptions='toolbar=0,location=0,directo... | Given that code, the createNewWindow() script isn't any more vulnerable than the raw javascript. |
226,643 | <p>If I've created a label in TFS, assigning it to several files, my coworkers cannot change the versions of files (nor add other files) to that label. We get this error:</p>
<pre><code>TF14077: The owner of a label cannot be changed.
</code></pre>
<p>Researching the problem, I found <a href="http://tinyurl.com/6zuw... | [
{
"answer_id": 226666,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 1,
"selected": false,
"text": "<p>Would shelve sets be a better solution for what you are doing? IIRC there is a fairly rich API for working with shelve s... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10082/"
] | If I've created a label in TFS, assigning it to several files, my coworkers cannot change the versions of files (nor add other files) to that label. We get this error:
```
TF14077: The owner of a label cannot be changed.
```
Researching the problem, I found [this article](http://tinyurl.com/6zuw9e), which states:
... | I never was able to make this work with labels. Instead, we devised a whole different process using branching, which I now strongly recommend to anyone reading this.
We set up a branching scheme so that there's a general development branch; from that, each developer has his/her own branch with which they can do what ... |
226,663 | <p>I want to use jQuery to parse RSS feeds. Can this be done with the base jQuery library out of the box or will I need to use a plugin?</p>
| [
{
"answer_id": 226679,
"author": "Nathan Strutz",
"author_id": 5918,
"author_profile": "https://Stackoverflow.com/users/5918",
"pm_score": 8,
"selected": false,
"text": "<p><a href=\"https://github.com/jfhovinne/jFeed\" rel=\"noreferrer\">Use jFeed</a> - a jQuery RSS/Atom plugin. Accordi... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12442/"
] | I want to use jQuery to parse RSS feeds. Can this be done with the base jQuery library out of the box or will I need to use a plugin? | **WARNING**
>
> [The Google Feed API](https://developers.google.com/feed/) is officially **deprecated** and **doesn't work anymore**!
>
>
>
---
No need for a whole plugin. This will return your RSS as a JSON object to a callback function:
```
function parseRSS(url, callback) {
$.ajax({
url: document.locat... |
226,664 | <p>I have a web service in C# and would like to have a nested inner class, that abstracts away the session collection, something like this: </p>
<pre>
<code>
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string Foo(string ticket)
{
SessionPool.getSession(ticket);
}
... | [
{
"answer_id": 226670,
"author": "cfeduke",
"author_id": 5645,
"author_profile": "https://Stackoverflow.com/users/5645",
"pm_score": 0,
"selected": false,
"text": "<pre><code>System.Web.HttpContext.Current\n</code></pre>\n\n<p>?</p>\n"
},
{
"answer_id": 226687,
"author": "Jon... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a web service in C# and would like to have a nested inner class, that abstracts away the session collection, something like this:
```
public class Service : System.Web.Services.WebService
{
[WebMethod]
public string Foo(string ticket)
{
SessionPool.getSession(ticket);
}
private cl... | Nested classes in C# aren't like (non-static) inner classes in Java. There is no implicit reference to an instance of the containing class - so you can't use any instance members of the containing class without an explicit reference.
However, you do have access to all private members of the containing class - with a s... |
226,683 | <p>I've got a ant <code>build.xml</code> that uses the <code><copy></code> task to copy a variety of xml files. It uses filtering to merge in properties from a <code>build.properties</code> file. Each environment (dev, stage, prod) has a different <code>build.properties</code> that stores configuration for that... | [
{
"answer_id": 226731,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 2,
"selected": false,
"text": "<p>I was going to suggest that you attempt to use <code><property file=\"${filter.file}\" prefix=\"filter\"></code> to ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25198/"
] | I've got a ant `build.xml` that uses the `<copy>` task to copy a variety of xml files. It uses filtering to merge in properties from a `build.properties` file. Each environment (dev, stage, prod) has a different `build.properties` that stores configuration for that environment.
Sometimes we add new properties to the S... | You can do it in ant 1.7, using a combination of the `LoadFile` task and the `match` condition.
```
<loadfile property="all-build-properties" srcFile="build.properties"/>
<condition property="missing-properties">
<matches pattern="@[^@]*@" string="${all-build-properties}"/>
</condition>
<fail message="Some propert... |
226,689 | <p>I'm writing a GreaseMonkey script where I'm iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The element itself doesn't have an <code>id</code> attribute, and I can't modify the original document to give it one (although I can make DOM change... | [
{
"answer_id": 226715,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "<p>In javascript, you could attach a custom ID field to the node</p>\n\n<pre><code>if(node.id) {\n node.myId = node.id;\n} ... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4287/"
] | I'm writing a GreaseMonkey script where I'm iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The element itself doesn't have an `id` attribute, and I can't modify the original document to give it one (although I can make DOM changes in my script... | **UPDATE:** Closures are indeed the answer. So after fiddling with it some more, I figured out why closures were initially problematic and how to fix it. The tricky thing with a closure is you have to be careful when iterating through the elements not to end up with all of your closures referencing the same element. Fo... |
226,701 | <p>QA tester was reading HTML/JS code to write a functional test of a web form, and saw:</p>
<pre><code>if (form_field == empty)
{
...do stuff for empty field
}
else if (form_field != empty)
{
...do stuff for non-empty field
}
else
{
...do stuff that will never be done
}
</code></pre>
<p>After a couple embarrassing a... | [
{
"answer_id": 226729,
"author": "UnhipGlint",
"author_id": 13010,
"author_profile": "https://Stackoverflow.com/users/13010",
"pm_score": 1,
"selected": false,
"text": "<p>I don't believe that this problem is at all language specific. You could construct similar (flawed) conditional sta... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2910/"
] | QA tester was reading HTML/JS code to write a functional test of a web form, and saw:
```
if (form_field == empty)
{
...do stuff for empty field
}
else if (form_field != empty)
{
...do stuff for non-empty field
}
else
{
...do stuff that will never be done
}
```
After a couple embarrassing attempts, tester realized t... | >
> Is this problem more or less language
> specific (can non-JS people learn
> lessons here?)
>
>
>
This is a language-agnostic problem. It's quite easy to write the following in Java, for example:
```
if(x)
{
//do something
}
else if(!x)
{
//do something else
}
else
{
//never, ever, do anything
}
```
... |
226,703 | <p>I want to pause input in a shell script, and prompt the user for choices.<br>
The standard <code>Yes</code>, <code>No</code>, or <code>Cancel</code> type question.<br>
How do I accomplish this in a typical bash prompt?</p>
| [
{
"answer_id": 226720,
"author": "Pistos",
"author_id": 28558,
"author_profile": "https://Stackoverflow.com/users/28558",
"pm_score": 8,
"selected": false,
"text": "<pre><code>echo \"Please enter some input: \"\nread input_variable\necho \"You entered: $input_variable\"\n</code></pre>\n"... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9084/"
] | I want to pause input in a shell script, and prompt the user for choices.
The standard `Yes`, `No`, or `Cancel` type question.
How do I accomplish this in a typical bash prompt? | The simplest and most widely available method to get user input at a shell prompt is the [`read`](https://www.gnu.org/software/bash/manual/bashref.html#index-read) command. The best way to illustrate its use is a simple demonstration:
```
while true; do
read -p "Do you wish to install this program? " yn
case $... |
226,717 | <p>When you are monitoring the TFS build from Visual Studio (2008 or 2005), you can see where it is up to.</p>
<p>The issue is that I have some Post-Build custom steps I would like the developer to be able to see directly throught the UI. Those steps take some times and we can also get a "timing" of the build step.</p... | [
{
"answer_id": 227063,
"author": "Martin Woodward",
"author_id": 6438,
"author_profile": "https://Stackoverflow.com/users/6438",
"pm_score": 4,
"selected": true,
"text": "<p>This is the pattern that I normally use for adding steps to the build report in TFS 2008. (See <a href=\"http://co... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24975/"
] | When you are monitoring the TFS build from Visual Studio (2008 or 2005), you can see where it is up to.
The issue is that I have some Post-Build custom steps I would like the developer to be able to see directly throught the UI. Those steps take some times and we can also get a "timing" of the build step.
Any idea ho... | This is the pattern that I normally use for adding steps to the build report in TFS 2008. (See <http://code.msdn.microsoft.com/buildwallboard/> for the full example that I usually use in my Team Build talks)
Basically, the magic is that there is a custom task provided for you in TFS2008 called "BuildStep". Here is the... |
226,721 | <p>I have a struts2 application with a single page that may show one of a number of values stored in a database. The application is for a school with many departments and each department has many programs. The department page is accessed using a url like this</p>
<pre><code>department.action?id=2
</code></pre>
<p>and... | [
{
"answer_id": 226827,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 2,
"selected": true,
"text": "<p>This is normally done by mapping a servlet to, in your case '/department', and then using the <a href=\"http://java.sun.c... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27439/"
] | I have a struts2 application with a single page that may show one of a number of values stored in a database. The application is for a school with many departments and each department has many programs. The department page is accessed using a url like this
```
department.action?id=2
```
and the DepartmentAction will... | This is normally done by mapping a servlet to, in your case '/department', and then using the [path](http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()) information (e.g., '/engineering') within the servlet to determine the ID.
Since the Struts2 dispatcher doesn't i... |
226,743 | <p>I am using the webbrowser control in visual studio. I think it is a wrapper around internet explorer. Anyway all is going well I am using it in edit mode however I can't get he document's keydown event to fire (in order to catch ctrl+v) anyone had similar problems with it?</p>
<p>Anyone have a solution?</p>
| [
{
"answer_id": 226789,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 1,
"selected": false,
"text": "<p>You should override a \"WndProc()\" method in derived class from WebBrowser control or in form, which contains a webbrowse... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16989/"
] | I am using the webbrowser control in visual studio. I think it is a wrapper around internet explorer. Anyway all is going well I am using it in edit mode however I can't get he document's keydown event to fire (in order to catch ctrl+v) anyone had similar problems with it?
Anyone have a solution? | Indeed the webbrowser control is just a wrapper of the IE browser control.
Is your problem that the controls PreviewKeyDown not working? Seems to be working for me as long as the control has focus.
```
webBrowser1.PreviewKeyDown += new PreviewKeyDownEventHandler(webBrowser1_PreviewKeyDown);
....
private voi... |
226,785 | <p>We have a netbeans project that has an xsd that we use to create a wsdl and we use the wsdl to create a webservice. Since we are using types in our xsd jaxb is used and one of our webservice methods looks like this: </p>
<pre><code>public void someMethod( org.netbeans.xml.schema.line.Line x )...
</code></pre>
... | [
{
"answer_id": 226795,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 6,
"selected": true,
"text": "<p>You can build one with the <a href=\"http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx\" rel=\"nore... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22763/"
] | We have a netbeans project that has an xsd that we use to create a wsdl and we use the wsdl to create a webservice. Since we are using types in our xsd jaxb is used and one of our webservice methods looks like this:
```
public void someMethod( org.netbeans.xml.schema.line.Line x )...
```
So that leaves us a problem... | You can build one with the [`HttpListener`](http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx) class to listen for incoming requests and the [`HttpWebRequest`](http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx) class to relay the requests. |
226,790 | <p>Forgive me for being a complete newbie with Windows DDK.</p>
<p>I have create a simple file named <code>test.cpp</code>:</p>
<pre><code>#include <windows.h>
#define BAD_ADDRESS 0xBAADF00D
int __cdecl main(int argc, char* args[])
{
char* p =(char*)BAD_ADDRESS;
*p='A';
return 0;
}
</code></pre>
... | [
{
"answer_id": 226952,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 2,
"selected": false,
"text": "<p>You have compiled a 'native application' rather than a win32 one. The TARGET_TYPE definition controls this.</p>\n\n<p... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6508/"
] | Forgive me for being a complete newbie with Windows DDK.
I have create a simple file named `test.cpp`:
```
#include <windows.h>
#define BAD_ADDRESS 0xBAADF00D
int __cdecl main(int argc, char* args[])
{
char* p =(char*)BAD_ADDRESS;
*p='A';
return 0;
}
```
In the same directory I created a `sources` fil... | [Rob Walker](https://stackoverflow.com/questions/226790/error-when-compiling-with-windows-ddk#226952) explains the why but [Kernel Mustard](http://blogs.msmvps.com/kernelmustard/2005/11/04/building-win32-apps-with-build-exe-and-the-ddk/) explains the how. |
226,828 | <p>After discussing with a newly arrived developer in my team, I realized that there are still, in C++, habits of using C constructs because they are supposed to be better (i.e. faster, leaner, prettier, pick your reason).</p>
<p><strong>What are the examples worth sharing, showing a C constructs, compared to the simi... | [
{
"answer_id": 226833,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 3,
"selected": false,
"text": "<h2>struct inline initialization vs. inline constructors</h2>\n<p>Sometimes, we need in C++ a simple aggregation of data... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14089/"
] | After discussing with a newly arrived developer in my team, I realized that there are still, in C++, habits of using C constructs because they are supposed to be better (i.e. faster, leaner, prettier, pick your reason).
**What are the examples worth sharing, showing a C constructs, compared to the similar C++ construc... | Macros vs. inline templates
---------------------------
C style:
```
#define max(x,y) (x) > (y) ? (x) : (y)
```
C++ style
```
inline template<typename T>
const T& max(const T& x, const T& y)
{
return x > y ? x : y;
}
```
Reason to prefer C++ approach:
* Type safety -- Enforces that arguments must be of same ... |
226,831 | <p>I'd like to make anchors to every post in my asp.net forum. Every forum's post is rendered using repeater control. How can I render <code><a name="anchor_name"></a></code> in asp.net?</p>
| [
{
"answer_id": 226838,
"author": "Travis Collins",
"author_id": 30460,
"author_profile": "https://Stackoverflow.com/users/30460",
"pm_score": 4,
"selected": true,
"text": "<pre><code><a name='<%# Eval(\"PostId\") %>' />\n</code></pre>\n\n<p>where PostId is the name of the pro... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3182/"
] | I'd like to make anchors to every post in my asp.net forum. Every forum's post is rendered using repeater control. How can I render `<a name="anchor_name"></a>` in asp.net? | ```
<a name='<%# Eval("PostId") %>' />
```
where PostId is the name of the property you want to appear in your anchor. |
226,834 | <p>I'm working on a C++ prettyprinter and would like to show the results of the prettyprinter by comparing code before and after running it. Does anyone know where I can find some ugly C++ code to run through the prettypretty? Ideally the code would come from some open source software.</p>
| [
{
"answer_id": 226852,
"author": "BoltBait",
"author_id": 20848,
"author_profile": "https://Stackoverflow.com/users/20848",
"pm_score": 3,
"selected": false,
"text": "<p>Try doing a search for 'C++ obfuscation' and you should be able to find C++ code that is hard to read.</p>\n"
},
{... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working on a C++ prettyprinter and would like to show the results of the prettyprinter by comparing code before and after running it. Does anyone know where I can find some ugly C++ code to run through the prettypretty? Ideally the code would come from some open source software. | Anything coded to the [GNU coding standards](http://www.gnu.org/prep/standards/html_node/Formatting.html#Formatting) will give you a shitty indentation style to practise on. Verbatim example:
```
if (x < foo (y, z))
haha = bar[4] + 5;
else
{
while (z)
{
haha += foo (z, z);
z--;
... |
226,847 | <p>I want to create a simple bit of JS code that creates an image element in the background and doesn't display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 =< only. Here is the code I have:</p>
<pre><code>var oImg = document.createElem... | [
{
"answer_id": 226856,
"author": "swilliams",
"author_id": 736,
"author_profile": "https://Stackoverflow.com/users/736",
"pm_score": 2,
"selected": false,
"text": "<p>Are you allowed to use a framework? <a href=\"http://jquery.com/\" rel=\"noreferrer\">jQuery</a> and <a href=\"http://pro... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3004/"
] | I want to create a simple bit of JS code that creates an image element in the background and doesn't display anything. The image element will call a tracking URL (such as Omniture) and needs to be simple and robust and work in IE 6 =< only. Here is the code I have:
```
var oImg = document.createElement("img");
oImg.se... | ```
oImg.setAttribute('width', '1px');
```
`px` is for CSS only. Use either:
```
oImg.width = '1';
```
to set a width through HTML, or:
```
oImg.style.width = '1px';
```
to set it through CSS.
Note that old versions of IE don't create a proper image with `document.createElement()`, and old versions of KHTML do... |
226,894 | <p>When you use the PHP <a href="http://us2.php.net/manual/en/function.copy.php" rel="noreferrer">copy</a> function, the operation blindly copies over the destination file, even if it already exists. How do you copy a file safely, only performing the copy if there is no existing file?</p>
| [
{
"answer_id": 226901,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "<p>I think you answered your own question - check to make sure the destination file exists before performing the copy. If... | 2008/10/22 | [
"https://Stackoverflow.com/questions/226894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8458/"
] | When you use the PHP [copy](http://us2.php.net/manual/en/function.copy.php) function, the operation blindly copies over the destination file, even if it already exists. How do you copy a file safely, only performing the copy if there is no existing file? | The obvious solution would be to call [file\_exists](http://us2.php.net/manual/en/function.file-exists.php) to check to see if the file exists, but doing that could cause a race condition. There is always the possibility that the other file will be created in between when you call [file\_exists](http://us2.php.net/manu... |