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
153,372
<p>I am trying to create a StringNameSpaceBinding using the wsadmin tool of Websphere 6.1</p> <p>Here are the steps i take set cell [$AdminConfig getid /Cell:cell/] $AdminConfig create StringNameSpaceBinding $cell { {name bindname} {nameInNameSpace Bindings/string} {stringToBind "This is the String value that gets bo...
[ { "answer_id": 3836682, "author": "Isaac", "author_id": 443716, "author_profile": "https://Stackoverflow.com/users/443716", "pm_score": 3, "selected": true, "text": "<p>I'm betting that the following command:</p>\n\n<pre><code>set cell [$AdminConfig getid /Cell:cell/]\n</code></pre>\n\n<...
2008/09/30
[ "https://Stackoverflow.com/questions/153372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11612/" ]
I am trying to create a StringNameSpaceBinding using the wsadmin tool of Websphere 6.1 Here are the steps i take set cell [$AdminConfig getid /Cell:cell/] $AdminConfig create StringNameSpaceBinding $cell { {name bindname} {nameInNameSpace Bindings/string} {stringToBind "This is the String value that gets bound"} } Bu...
I'm betting that the following command: ``` set cell [$AdminConfig getid /Cell:cell/] ``` Doesn't work. Most likely, `cell` is not the name of your cell. You don't need to specify a cell name; there's only one cell in the WAS topology. I would change this to: ``` set cell [$AdminConfig getid /Cell:/] ``` Good luc...
153,376
<p>We have similar code to the following in one of our projects. Can anyone explain (in simple English) why the fixed statement is needed here?</p> <pre><code>class TestClass { int iMyVariable; static void Main() { TestClass oTestClass = new TestClass(); unsafe { fixed (...
[ { "answer_id": 153382, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": false, "text": "<p>You need it anywhere you do pointer arithmetic, to prevent the garbage collector from moving it around on you.</p>\...
2008/09/30
[ "https://Stackoverflow.com/questions/153376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23790/" ]
We have similar code to the following in one of our projects. Can anyone explain (in simple English) why the fixed statement is needed here? ``` class TestClass { int iMyVariable; static void Main() { TestClass oTestClass = new TestClass(); unsafe { fixed (int* p = &oTes...
It fixes the pointer in memory. Garbage collected languages have the freedom to move objects around memory for efficiency. This is all transparent to the programmer because they don't really use pointers in "normal" CLR code. However, when you do require pointers, then you need to fix it in memory if you want to work w...
153,381
<p>I have to concatenate a bunch of Strings in Javascript and am searching for the fastest way to do so. Let's assume that the Javascript has to create a large XML-"file" that, naturally, consists of many small Strings. So I came up with:</p> <pre><code> var sbuffer = []; for (var idx=0; idx&lt;10000; idx=idx+1...
[ { "answer_id": 153395, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 1, "selected": false, "text": "<p>I think you are quite close to the optimum. YMMV, a great deal of speed is gained or lost within the JavaScript engine ...
2008/09/30
[ "https://Stackoverflow.com/questions/153381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13209/" ]
I have to concatenate a bunch of Strings in Javascript and am searching for the fastest way to do so. Let's assume that the Javascript has to create a large XML-"file" that, naturally, consists of many small Strings. So I came up with: ``` var sbuffer = []; for (var idx=0; idx<10000; idx=idx+1) { sbuff...
Changing the line: `sbuffer.push(‘Data comes here... bla... ’);` to `sbuffer[sbuffer.length] = ‘Data comes here... bla... ’;` will give you 5-50% speed gain (depending on browser, in IE - gain will be highest) Regards.
153,388
<p>I'm really sick of this problem. Google searches always seem to suggest "delete all bpls for the package", "delete all dcus". Sometimes this just-does-not-work. Hopefully I can get some other ideas here.</p> <p>I have a package written in-house, which had been installed without issue a few months ago. Having made a...
[ { "answer_id": 153435, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 3, "selected": false, "text": "<p>These are bugs in the compiler/linker. You can find many references of these bugs on the internet in different Delp...
2008/09/30
[ "https://Stackoverflow.com/questions/153388", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11820/" ]
I'm really sick of this problem. Google searches always seem to suggest "delete all bpls for the package", "delete all dcus". Sometimes this just-does-not-work. Hopefully I can get some other ideas here. I have a package written in-house, which had been installed without issue a few months ago. Having made a few chang...
I managed to solve this, following the below procedure 1. Create a new package 2. One by one, add the components to the package, compile & install, until it failed. 3. Investigate the unit causing the failure. As it turns out, the unit in question had a class constant array, eg ``` TMyClass = class(TComponent) priva...
153,394
<p>I believe in OO, but not to the point where inappropriate designs/implementations should be used just to be "OO Compliant".</p> <p>So, how to deal with the Serlvet/EJB/DataContainer layered architecture:</p> <ul> <li>Servlets receive requests and call a "business layer" (e.g. session EJBs)</li> <li>The business la...
[ { "answer_id": 153434, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverflow.com/users/6610", "pm_score": -1, "selected": false, "text": "<p>Crudely, the \"We don't want\" section has to go. Either you want it to be right, or you want it to stay as it is. There...
2008/09/30
[ "https://Stackoverflow.com/questions/153394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3029/" ]
I believe in OO, but not to the point where inappropriate designs/implementations should be used just to be "OO Compliant". So, how to deal with the Serlvet/EJB/DataContainer layered architecture: * Servlets receive requests and call a "business layer" (e.g. session EJBs) * The business layer locates DataContainers f...
So I'll address my thoughts on this in a few bullet points: 1. It seems in a Java EE system at some point you have to deal with the plumbing of Java EE, the plumbing doesn't always benefit from OO concepts, but it certainly can with a bit of creativity and work. For example you could might take advantage of things suc...
153,407
<p>I am upgrading a silverlight beta 2 app to RC0 and have a function that translates a point from a child element to it's parent. The purpose of the function is to ensure that an element appears exactly on top of the child even though they are not on the same canvas and don't share a parent.</p> <p>Here is the curre...
[ { "answer_id": 154150, "author": "Santiago Palladino", "author_id": 12791, "author_profile": "https://Stackoverflow.com/users/12791", "pm_score": 3, "selected": true, "text": "<p>See TransformToVisual method of framework element. It does exactly what you want: given another control, it g...
2008/09/30
[ "https://Stackoverflow.com/questions/153407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21818/" ]
I am upgrading a silverlight beta 2 app to RC0 and have a function that translates a point from a child element to it's parent. The purpose of the function is to ensure that an element appears exactly on top of the child even though they are not on the same canvas and don't share a parent. Here is the current function...
See TransformToVisual method of framework element. It does exactly what you want: given another control, it generates a new transform that maps the coordinates of a point relative to the current control, to coordinates relative to the passed in control. ``` var transform = from.TransformToVisual(to); return transform....
153,413
<p>I'm trying to extract the polygons from placemarks in a KML file. So far so good:</p> <pre><code>Imports &lt;xmlns:g='http://earth.google.com/kml/2.0'&gt; Imports System.Xml.Linq Partial Class Test_ImportPolygons Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System...
[ { "answer_id": 153486, "author": "tbrownell", "author_id": 1981, "author_profile": "https://Stackoverflow.com/users/1981", "pm_score": 1, "selected": false, "text": "<p>Have you tried:</p>\n\n<pre><code>Placemark.ToString()\n</code></pre>\n" }, { "answer_id": 153519, "author"...
2008/09/30
[ "https://Stackoverflow.com/questions/153413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/239663/" ]
I'm trying to extract the polygons from placemarks in a KML file. So far so good: ``` Imports <xmlns:g='http://earth.google.com/kml/2.0'> Imports System.Xml.Linq Partial Class Test_ImportPolygons Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ...
What I was missing was that `Placemark.<g:Polygon>` is a collection of XElements, not a single XElement. This works: ``` For Each Placemark As XElement In Kml.<g:Document>.<g:Folder>.<g:Placemark> Dim Name As String = Placemark.<g:name>.Value Dim PolygonsXml As String = "" For Each Polygon ...
153,420
<p>I'm starting a project using a Restful architecture implemented in Java (using the new JAX-RS standard)</p> <p>We are planning to develop the GUI with a Flex application. I have already found some problems with this implementation using the HTTPService component (the response error codes, headers access...).</p> <...
[ { "answer_id": 153504, "author": "mbrevoort", "author_id": 18228, "author_profile": "https://Stackoverflow.com/users/18228", "pm_score": 3, "selected": false, "text": "<p>There are definite shortcomings of Flex's ability to act as a pure RESTful client.</p>\n\n<p>The comments below are f...
2008/09/30
[ "https://Stackoverflow.com/questions/153420", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2937/" ]
I'm starting a project using a Restful architecture implemented in Java (using the new JAX-RS standard) We are planning to develop the GUI with a Flex application. I have already found some problems with this implementation using the HTTPService component (the response error codes, headers access...). Any of you guys...
The problem here is that a lot of the web discussions around this issue are a year or more old. I'm working through this same research right now, and this is what I've learned today. This [IBM Developer Works article from August 2008](http://www.ibm.com/developerworks/websphere/library/techarticles/0808_rasillo/0808_r...
153,427
<p>I am currently using JUnit 4 and have a need to divide my tests into groups that can be run selectively in any combination. I know TestNG has a feature to annotate tests to assign them to groups, but I can't migrate to TestNG right now. It seems this could easily be accomplished in JUnit with some custom annotations...
[ { "answer_id": 153447, "author": "Tom", "author_id": 22850, "author_profile": "https://Stackoverflow.com/users/22850", "pm_score": 0, "selected": false, "text": "<p>You can create suites, although that puts all the configuration in the suite, and not in annotations.</p>\n" }, { "...
2008/09/30
[ "https://Stackoverflow.com/questions/153427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13041/" ]
I am currently using JUnit 4 and have a need to divide my tests into groups that can be run selectively in any combination. I know TestNG has a feature to annotate tests to assign them to groups, but I can't migrate to TestNG right now. It seems this could easily be accomplished in JUnit with some custom annotations an...
Check out Spring's [SpringJUnit4ClassRunner](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.html). I've used it to optionally run tests based on a System property, using the [IfProfileValue](http://static.springframework.org/spring/docs/2.5.x/api/...
153,438
<p>I have a VB6 COM component which I need to call from my .Net method. I use reflection to create an instance of the COM object and activate it in the following manner:</p> <pre><code>f_oType = Type.GetTypeFromProgID(MyProgId); f_oInstance = Activator.CreateInstance(f_oType); </code></pre> <p>I need to use GetTypeFrom...
[ { "answer_id": 153447, "author": "Tom", "author_id": 22850, "author_profile": "https://Stackoverflow.com/users/22850", "pm_score": 0, "selected": false, "text": "<p>You can create suites, although that puts all the configuration in the suite, and not in annotations.</p>\n" }, { "...
2008/09/30
[ "https://Stackoverflow.com/questions/153438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15570/" ]
I have a VB6 COM component which I need to call from my .Net method. I use reflection to create an instance of the COM object and activate it in the following manner: ``` f_oType = Type.GetTypeFromProgID(MyProgId); f_oInstance = Activator.CreateInstance(f_oType); ``` I need to use GetTypeFromProgID rather than using...
Check out Spring's [SpringJUnit4ClassRunner](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.html). I've used it to optionally run tests based on a System property, using the [IfProfileValue](http://static.springframework.org/spring/docs/2.5.x/api/...
153,439
<p>I'm trying to place 4 of my image containers into a new pane, having a total of 16 images. The jQuery below is what I came up with to do it. The first pane comes out correctly with 4 images in it. But the second has 4 images, plus the 3rd pane. And the 3rd pane has 4 images plus the 4th pane. I don't know exact...
[ { "answer_id": 153562, "author": "Per Hornshøj-Schierbeck", "author_id": 11619, "author_profile": "https://Stackoverflow.com/users/11619", "pm_score": 4, "selected": true, "text": "<p>I think your problem is your use of the gt() and lt() selectors. You should look up slice() instead. </p...
2008/09/30
[ "https://Stackoverflow.com/questions/153439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13611/" ]
I'm trying to place 4 of my image containers into a new pane, having a total of 16 images. The jQuery below is what I came up with to do it. The first pane comes out correctly with 4 images in it. But the second has 4 images, plus the 3rd pane. And the 3rd pane has 4 images plus the 4th pane. I don't know exactly why t...
I think your problem is your use of the gt() and lt() selectors. You should look up slice() instead. Check out this post: <http://docs.jquery.com/Traversing/slice>
153,451
<p>I am trying to use <code>WebClient</code> to download a file from web using a WinForms application. However, I really only want to download HTML file. Any other type I will want to ignore.</p> <p>I checked the <code>WebResponse.ContentType</code>, but its value is always <code>null</code>. </p> <p>Anyone have any ...
[ { "answer_id": 153457, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "<p>You could issue the first request with the HEAD verb, and check the content-type response header? [edit] It looks ...
2008/09/30
[ "https://Stackoverflow.com/questions/153451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to use `WebClient` to download a file from web using a WinForms application. However, I really only want to download HTML file. Any other type I will want to ignore. I checked the `WebResponse.ContentType`, but its value is always `null`. Anyone have any idea what could be the cause?
Given your update, you can do this by changing the .Method in GetWebRequest: ``` using System; using System.Net; static class Program { static void Main() { using (MyClient client = new MyClient()) { client.HeadOnly = true; string uri = "http://www.google.com"; ...
153,460
<p>Most applications only have "Restore, Move, Size, Minimize, Maximize and Close", however <i>MS SQL</i> offers extra options "Help, Customize view". Along those lines, is it possible to add to the right click menu of an application in the task bar? </p> <p>Note: I'm <b>not</b> referring to an icon in the notificati...
[ { "answer_id": 153568, "author": "C. Ross", "author_id": 16487, "author_profile": "https://Stackoverflow.com/users/16487", "pm_score": 1, "selected": false, "text": "<p>This is a simpler <a href=\"http://bytes.com/forum/thread529258.html\" rel=\"nofollow noreferrer\">answer</a> I found. ...
2008/09/30
[ "https://Stackoverflow.com/questions/153460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1484/" ]
Most applications only have "Restore, Move, Size, Minimize, Maximize and Close", however *MS SQL* offers extra options "Help, Customize view". Along those lines, is it possible to add to the right click menu of an application in the task bar? Note: I'm **not** referring to an icon in the notification area next to the...
This is a simpler [answer](http://bytes.com/forum/thread529258.html) I found. I quickly tested it and it works. My code: ``` private const int WMTaskbarRClick = 0x0313; protected override void WndProc(ref Message m) { switch (m.Msg) { case WMTaskbarRClick: { ...
153,482
<p>I have a Tapestry application that is serving its page as UTF-8. That is, server responses have header:</p> <pre><code>Content-type: text/html;charset=UTF-8 </code></pre> <p>Now within this application there is a single page that should be served with ISO-8859-1 encoding. That is, server response should have this ...
[ { "answer_id": 160706, "author": "Brian", "author_id": 700, "author_profile": "https://Stackoverflow.com/users/700", "pm_score": 3, "selected": true, "text": "<p>Have you considered a Filter? Maybe not as elegant as something within Tapestry, but using a plain Filter, that registers the...
2008/09/30
[ "https://Stackoverflow.com/questions/153482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1431/" ]
I have a Tapestry application that is serving its page as UTF-8. That is, server responses have header: ``` Content-type: text/html;charset=UTF-8 ``` Now within this application there is a single page that should be served with ISO-8859-1 encoding. That is, server response should have this header: ``` Content-type:...
Have you considered a Filter? Maybe not as elegant as something within Tapestry, but using a plain Filter, that registers the url mapping(s) of interest. One of its init parameters would be the encoding your after. Example: ``` public class EncodingFilter implements Filter { private String encoding; private FilterConf...
153,507
<p>How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)?</p> <p>For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere.</p> <p>Any ideas? </p>
[ { "answer_id": 153517, "author": "Chris Johnson", "author_id": 23732, "author_profile": "https://Stackoverflow.com/users/23732", "pm_score": 6, "selected": true, "text": "<p>The equation is: s = ut + (1/2)a t^2</p>\n\n<p>where s is position, u is velocity at t=0, t is time and a is a con...
2008/09/30
[ "https://Stackoverflow.com/questions/153507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11911/" ]
How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)? For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere. Any ideas?
The equation is: s = ut + (1/2)a t^2 where s is position, u is velocity at t=0, t is time and a is a constant acceleration. For example, if a car starts off stationary, and accelerates for two seconds with an acceleration of 3m/s^2, it moves (1/2) \* 3 \* 2^2 = 6m This equation comes from integrating analytically th...
153,527
<p>I have a page that contains a form. This page is served with content type text/html;charset=utf-8. I need to submit this form to server using ISO-8859-1 character encoding. Is this possible with Internet Explorer?</p> <p>Setting accept-charset attribute to form element, like this, works for Firefox, Opera etc. but ...
[ { "answer_id": 153578, "author": "pdc", "author_id": 8925, "author_profile": "https://Stackoverflow.com/users/8925", "pm_score": -1, "selected": false, "text": "<p>I am pretty sure it won't be possible with older versions of IE. Before the <code>accept-charset</code> attribute was devise...
2008/09/30
[ "https://Stackoverflow.com/questions/153527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1431/" ]
I have a page that contains a form. This page is served with content type text/html;charset=utf-8. I need to submit this form to server using ISO-8859-1 character encoding. Is this possible with Internet Explorer? Setting accept-charset attribute to form element, like this, works for Firefox, Opera etc. but not for IE...
There is a simple hack to this: Insert a hidden input field in the form with an entity which only occur in the character set the server your posting (or doing a GET) to accepts. Example: If the form is located on a server serving ISO-8859-1 and the form will post to a server expecting UTF-8 insert something like this...
153,573
<p>Take the following C# class:</p> <pre><code>c1 { event EventHandler someEvent; } </code></pre> <p>If there are a lot of subscriptions to <code>c1</code>'s <code>someEvent</code> event and I want to clear them all, what is the best way to achieve this? <strong>Also consider that subscriptions to this event could b...
[ { "answer_id": 153577, "author": "programmer", "author_id": 5289, "author_profile": "https://Stackoverflow.com/users/5289", "pm_score": 5, "selected": false, "text": "<p>Add a method to c1 that will set 'someEvent' to null.</p>\n<pre><code>public class c1\n{\n event EventHandler someE...
2008/09/30
[ "https://Stackoverflow.com/questions/153573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289/" ]
Take the following C# class: ``` c1 { event EventHandler someEvent; } ``` If there are a lot of subscriptions to `c1`'s `someEvent` event and I want to clear them all, what is the best way to achieve this? **Also consider that subscriptions to this event could be/are lambdas/anonymous delegates.** Currently my sol...
From within the class, you can set the (hidden) variable to null. A null reference is the canonical way of representing an empty invocation list, effectively. From outside the class, you can't do this - events basically expose "subscribe" and "unsubscribe" and that's it. It's worth being aware of what field-like even...
153,584
<p>How do I iterate over a timespan after days, hours, weeks or months?</p> <p>Something like:</p> <pre><code>for date in foo(from_date, to_date, delta=HOURS): print date </code></pre> <p>Where foo is a function, returning an iterator. I've been looking at the calendar module, but that only works for one specifi...
[ { "answer_id": 153640, "author": "dguaraglia", "author_id": 2384, "author_profile": "https://Stackoverflow.com/users/2384", "pm_score": -1, "selected": false, "text": "<p>This library provides a handy calendar tool: <a href=\"http://www.egenix.com/products/python/mxBase/mxDateTime/\" rel...
2008/09/30
[ "https://Stackoverflow.com/questions/153584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/473/" ]
How do I iterate over a timespan after days, hours, weeks or months? Something like: ``` for date in foo(from_date, to_date, delta=HOURS): print date ``` Where foo is a function, returning an iterator. I've been looking at the calendar module, but that only works for one specific year or month, not between date...
Use [dateutil](http://labix.org/python-dateutil) and its rrule implementation, like so: ``` from dateutil import rrule from datetime import datetime, timedelta now = datetime.now() hundredDaysLater = now + timedelta(days=100) for dt in rrule.rrule(rrule.MONTHLY, dtstart=now, until=hundredDaysLater): print dt ``...
153,585
<p>In MS Transact SQL, let's say I have a table (Orders) like this:</p> <pre><code> Order Date Order Total Customer # 09/30/2008 8.00 1 09/15/2008 6.00 1 09/01/2008 9.50 1 09/01/2008 1.45 2 09/16/2008 4.50 2 09/17/2008...
[ { "answer_id": 153601, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 4, "selected": true, "text": "<p>This should make it</p>\n\n<pre><code>select avg(total), customer \nfrom orders o1 \nwhere orderdate in \n ( select t...
2008/09/30
[ "https://Stackoverflow.com/questions/153585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8173/" ]
In MS Transact SQL, let's say I have a table (Orders) like this: ``` Order Date Order Total Customer # 09/30/2008 8.00 1 09/15/2008 6.00 1 09/01/2008 9.50 1 09/01/2008 1.45 2 09/16/2008 4.50 2 09/17/2008 8.75 ...
This should make it ``` select avg(total), customer from orders o1 where orderdate in ( select top 2 date from orders o2 where o2.customer = o1.customer order by date desc ) group by customer ```
153,592
<p>I'm using .NET to make an application with a drawing surface, similar to Visio. The UI connects two objects on the screen with Graphics.DrawLine. This simple implementation works fine, but as the surface gets more complex, I need a more robust way to represent the objects. One of these robust requirements is determi...
[ { "answer_id": 153631, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 2, "selected": false, "text": "<p>You can ask Dr. Math, see <a href=\"https://web.archive.org/web/20180211083203/http://mathforum.org/library/drmath...
2008/09/30
[ "https://Stackoverflow.com/questions/153592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
I'm using .NET to make an application with a drawing surface, similar to Visio. The UI connects two objects on the screen with Graphics.DrawLine. This simple implementation works fine, but as the surface gets more complex, I need a more robust way to represent the objects. One of these robust requirements is determinin...
The representation of lines by y = mx + c is problematic for computer graphics, because vertical lines require m to be infinite. Furthermore, lines in computer graphics have a start and end point, unlike mathematical lines which are infinite in extent. One is usually only interested in a crossing of lines if the cross...
153,596
<p>What would be the most efficient way of recording to a log (.txt) from a console program on C# and .NET 2.2? My program loops multiple times always outputting different data based on what the user wants, so I'm searching for the most efficient way to achieve this.</p> <p>I know I can always reopen a stream and then...
[ { "answer_id": 153610, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 4, "selected": false, "text": "<p>Consider using <a href=\"http://logging.apache.org/log4net/index.html\" rel=\"nofollow noreferrer\">log4net</a>:</...
2008/09/30
[ "https://Stackoverflow.com/questions/153596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22582/" ]
What would be the most efficient way of recording to a log (.txt) from a console program on C# and .NET 2.2? My program loops multiple times always outputting different data based on what the user wants, so I'm searching for the most efficient way to achieve this. I know I can always reopen a stream and then close it,...
You could hook into the tracing framework that forms part of the CLR. Using a simple class like: <http://www.chaosink.co.uk/files/tracing.zip> you can selectively log diagnostic information. To use it add the class to your application. Create an inistance of the tracer in your class like: ``` private Tracing trace = n...
153,598
<p>I have a simple query:</p> <pre><code>SELECT u_name AS user_name FROM users WHERE user_name = "john"; </code></pre> <p>I get <code>Unknown Column 'user_name' in where clause</code>. Can I not refer to <code>'user_name'</code> in other parts of the statement even after <code>select 'u_name as user_name'</code>?</p...
[ { "answer_id": 153603, "author": "Jarrett Meyer", "author_id": 5834, "author_profile": "https://Stackoverflow.com/users/5834", "pm_score": 2, "selected": false, "text": "<p>No you cannot. user_name is doesn't exist until return time.</p>\n" }, { "answer_id": 153608, "author":...
2008/09/30
[ "https://Stackoverflow.com/questions/153598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a simple query: ``` SELECT u_name AS user_name FROM users WHERE user_name = "john"; ``` I get `Unknown Column 'user_name' in where clause`. Can I not refer to `'user_name'` in other parts of the statement even after `select 'u_name as user_name'`?
SQL is evaluated backwards, from right to left. So the where clause is parsed and evaluate prior to the select clause. Because of this the aliasing of u\_name to user\_name has not yet occurred.
153,630
<p>Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use </p> <pre><code>Elmah.ErrorLog.Default </code></pre> <p>However, this is now marked as obsolete. The compil...
[ { "answer_id": 153683, "author": "SHODAN", "author_id": 2622, "author_profile": "https://Stackoverflow.com/users/2622", "pm_score": 8, "selected": true, "text": "<p>Try <code>System.Web.HttpContext.Current</code>. It should do the trick.</p>\n\n<p>Gets HTTP-specific information about an ...
2008/09/30
[ "https://Stackoverflow.com/questions/153630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use ``` Elmah.ErrorLog.Default ``` However, this is now marked as obsolete. The compiler directs me to use the metho...
Try `System.Web.HttpContext.Current`. It should do the trick. Gets HTTP-specific information about an individual HTTP request. [MSDN](https://msdn.microsoft.com/en-us/library/system.web.httpcontext.current%28v=vs.110%29.aspx)
153,639
<p>Greetings!</p> <p>I have a WebService that contains a WebMethod that does some work and returns a boolean value. The work that it does may or may not take some time, so I'd like to call it asynchronously.</p> <pre><code>[WebService(Namespace = "http://tempuri.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.Ba...
[ { "answer_id": 153854, "author": "craigmoliver", "author_id": 12252, "author_profile": "https://Stackoverflow.com/users/12252", "pm_score": 0, "selected": false, "text": "<p>A Literal in a conditional Update Panel would be fine.</p>\n\n<pre><code>&lt;asp:UpdatePanel ID=\"up\" runat=\"ser...
2008/09/30
[ "https://Stackoverflow.com/questions/153639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27870/" ]
Greetings! I have a WebService that contains a WebMethod that does some work and returns a boolean value. The work that it does may or may not take some time, so I'd like to call it asynchronously. ``` [WebService(Namespace = "http://tempuri.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [Syste...
[Asynchronous pages](http://msdn.microsoft.com/en-us/magazine/cc163725.aspx) are helpful in scenarios when you need to asynchronously call web service methods.
153,644
<p>Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array <code>@myarray</code> and a hash <code>%myhash</code>, why do you need to do:</p> <pre><code>$x ...
[ { "answer_id": 153668, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": false, "text": "<p>I can think of one way that </p>\n\n<pre><code>$x = myarray[1];\n</code></pre>\n\n<p>is ambiguous - what if you wanted...
2008/09/30
[ "https://Stackoverflow.com/questions/153644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array `@myarray` and a hash `%myhash`, why do you need to do: ``` $x = $myarray[1]; $y = $myhash{'foo'}; ...
Slices aren't illegal: ``` @slice = @myarray[1, 2, 5]; @slice = @myhash{qw/foo bar baz/}; ``` And I suspect that's part of the reason why you need to specify if you want to get a single value out of the hash/array or not.
153,666
<p>I'm having a problem with some mail merge code that is supposed to produce letters within our application. I'm aware that this code is a bit rough at the moment, but we're in the "Get something working" phase before we tidy it up.</p> <p>Now the way this is supposed to work, and the way it works when we do it manua...
[ { "answer_id": 153793, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 0, "selected": false, "text": "<p>I think the problem is this line:</p>\n\n<pre><code>wrdDoc.MailMerge.OpenDataSource(templateName)\n</code></pre>\n...
2008/09/30
[ "https://Stackoverflow.com/questions/153666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11496/" ]
I'm having a problem with some mail merge code that is supposed to produce letters within our application. I'm aware that this code is a bit rough at the moment, but we're in the "Get something working" phase before we tidy it up. Now the way this is supposed to work, and the way it works when we do it manually, is we...
I've found the solution. When you merge a document, it creates a new document with the merge results in it. Code fragment below explains. ``` wrdDoc = wrdApp.Documents.Add(TemplateFileName) wrdDoc.Select() Dim wrdSelection As Word.Selection Dim wrdMailMerge As Word.MailMerge wrdDoc.MailMerge.OpenDataSource(DataFileNa...
153,689
<p>I'm designing an application which deals with two sets of data - Users and Areas. The data is read from files produced by a third party. I have a User class and an Area class, and the data is read into a Users array and an Areas array (or other appropriate memory structure, depending on the technology we go with)....
[ { "answer_id": 153698, "author": "Saif Khan", "author_id": 23667, "author_profile": "https://Stackoverflow.com/users/23667", "pm_score": 0, "selected": false, "text": "<p>Why not use DataTables with relations, if .NET is involved? You may want to look into Generics as well, again, if .NE...
2008/09/30
[ "https://Stackoverflow.com/questions/153689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8354/" ]
I'm designing an application which deals with two sets of data - Users and Areas. The data is read from files produced by a third party. I have a User class and an Area class, and the data is read into a Users array and an Areas array (or other appropriate memory structure, depending on the technology we go with). Bot...
this is really a many-to-many relationship, ``` User <<--->> Area ``` break it up into 3 objects, User, Area, and UserArea: ``` User: Id, name, etc. Area: Id, name, etc. UserArea: UserId, AreaId ```
153,706
<p>It seems to me that phpMyAdmin imports tables by default with collation latin1_swedish_ci, how i change this?</p>
[ { "answer_id": 153765, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": false, "text": "<p>This is not a phpMyAdmin question.</p>\n\n<p>Collations are part of recent MySQL releases, you must set the default col...
2008/09/30
[ "https://Stackoverflow.com/questions/153706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
It seems to me that phpMyAdmin imports tables by default with collation latin1\_swedish\_ci, how i change this?
In your Mysql configuration change the default-character-set operative under the [mysqld] tab. For example: ``` [mysqld] default-character-set=utf8 ``` Don't forget to restart your Mysql server afterwards for the changes to take effect.
153,707
<p>Suppose I have the following declaration:</p> <pre><code>class Over1 { protected: class Under1 { }; }; </code></pre> <p>I know that I could do the following:</p> <pre><code>class Over2 : public Over1 { protected: class Under2 : public Under1 { }; }; </code></pre> <...
[ { "answer_id": 153766, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 1, "selected": false, "text": "<p>Better than creating nested classes, you might want to look at embedding those closses into a namespace. That way,...
2008/09/30
[ "https://Stackoverflow.com/questions/153707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23829/" ]
Suppose I have the following declaration: ``` class Over1 { protected: class Under1 { }; }; ``` I know that I could do the following: ``` class Over2 : public Over1 { protected: class Under2 : public Under1 { }; }; ``` But is there a way to declare Under2 without Ov...
Using templates and explicit specializations you can do this with just one additional class declaration in Over1. ``` class Over1 { protected: class Under1 { }; template <typename T> class UnderImplementor; }; struct Under2Tag; struct Under3Tag; struct Under4Tag; template <> class Over1::UnderImplementor<...
153,716
<p>Is there any way to verify in Java code that an e-mail address is valid. By valid, I don't just mean that it's in the correct format (someone@domain.subdomain), but that's it's a real active e-mail address.</p> <p>I'm almost certain that there's no 100% reliable way to do this, because such a technique would be the...
[ { "answer_id": 153727, "author": "Joe Skora", "author_id": 14057, "author_profile": "https://Stackoverflow.com/users/14057", "pm_score": 2, "selected": false, "text": "<p>Without sending an email, it could be hard to get 100%, but if you <strong>do a DNS lookup on the host</strong> that ...
2008/09/30
[ "https://Stackoverflow.com/questions/153716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
Is there any way to verify in Java code that an e-mail address is valid. By valid, I don't just mean that it's in the correct format (someone@domain.subdomain), but that's it's a real active e-mail address. I'm almost certain that there's no 100% reliable way to do this, because such a technique would be the stuff of ...
Here is what I have around. To check that the address is a valid format, here is a regex that verifies that it's nearly rfc2822 (it doesn't catch some weird corner cases). I found it on the 'net last year. ``` private static final Pattern rfc2822 = Pattern.compile( "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#...
153,724
<p>What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.</p> <p>I also would like only significant digits to be ...
[ { "answer_id": 153753, "author": "asterite", "author_id": 20459, "author_profile": "https://Stackoverflow.com/users/20459", "pm_score": 9, "selected": false, "text": "<p>Assuming <code>value</code> is a <code>double</code>, you can do:</p>\n\n<pre><code>(double)Math.round(value * 100000d...
2008/09/30
[ "https://Stackoverflow.com/questions/153724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12149/" ]
What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations. I also would like only significant digits to be displayed ...
Use [`setRoundingMode`](http://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html#setRoundingMode(java.math.RoundingMode)), set the [`RoundingMode`](http://docs.oracle.com/javase/8/docs/api/java/math/RoundingMode.html) explicitly to handle your issue with the half-even round, then use the format pattern for...
153,731
<p>I am looking for validation framework and while I am already using NHibernate I am thinking of using NHibernate.validator from contrib project however I also look at MS Validation Block which seem to be robust but i am not yet get into detail of each one yet so I wonder has anyone had step into these two frameworks ...
[ { "answer_id": 153839, "author": "Daniel Honig", "author_id": 1129162, "author_profile": "https://Stackoverflow.com/users/1129162", "pm_score": -1, "selected": false, "text": "<p>How about D) None of the above.\nI remember evaluating this last year and decided on going with Spring.NET's ...
2008/09/30
[ "https://Stackoverflow.com/questions/153731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15396/" ]
I am looking for validation framework and while I am already using NHibernate I am thinking of using NHibernate.validator from contrib project however I also look at MS Validation Block which seem to be robust but i am not yet get into detail of each one yet so I wonder has anyone had step into these two frameworks and...
NHibernate Validator does not require you to use NHibernate for persistence. Usage can be as simple as: ``` var engine = new ValidatorEngine(); InvalidValue[] errors = engine.Validate(someModelObjectWithAttributes); foreach(var error in errors) { Console.WriteLine(error.Message); } ``` Of course it can hook int...
153,748
<p>I've tried this:</p> <pre><code>string newScript = textBox1.Text; HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = browserCtrl.Document.CreateElement("script"); lblStatus.Text = scriptEl.GetType().ToString(); scriptEl.SetAttribute("type", "text/javascript"); head.Appen...
[ { "answer_id": 153756, "author": "mattlant", "author_id": 14642, "author_profile": "https://Stackoverflow.com/users/14642", "pm_score": 0, "selected": false, "text": "<p>What you want to do is use Page.RegisterStartupScript(key, script) \n:</p>\n\n<p>See here for more details: <a href=\"...
2008/09/30
[ "https://Stackoverflow.com/questions/153748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1432/" ]
I've tried this: ``` string newScript = textBox1.Text; HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = browserCtrl.Document.CreateElement("script"); lblStatus.Text = scriptEl.GetType().ToString(); scriptEl.SetAttribute("type", "text/javascript"); head.AppendChild(scriptE...
For some reason Richard's solution didn't work on my end (insertAdjacentText failed with an exception). This however seems to work: ``` HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = webBrowser1.Document.CreateElement("script"); IHTMLScriptElement element = (IHTMLScript...
153,759
<p>How do I use the jQuery Datepicker with a textbox input:</p> <pre><code>$("#my_txtbox").datepicker({ // options }); </code></pre> <p>that doesn't allow the user to input random text in the textbox. I want the Datepicker to pop up when the textbox gains focus or the user clicks on it, but I want the textbox to ig...
[ { "answer_id": 153804, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 9, "selected": true, "text": "<p>You should be able to use the <strong>readonly</strong> attribute on the text input, and jQuery will still be able...
2008/09/30
[ "https://Stackoverflow.com/questions/153759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024/" ]
How do I use the jQuery Datepicker with a textbox input: ``` $("#my_txtbox").datepicker({ // options }); ``` that doesn't allow the user to input random text in the textbox. I want the Datepicker to pop up when the textbox gains focus or the user clicks on it, but I want the textbox to ignore any user input using ...
You should be able to use the **readonly** attribute on the text input, and jQuery will still be able to edit its contents. ``` <input type='text' id='foo' readonly='true'> ```
153,762
<p>Our graphics person uses Adobe Illustrator and we'd like to use her images inside our WPF application as paths. Is there a way to do this?</p>
[ { "answer_id": 153875, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 0, "selected": false, "text": "<p>Get her to export the illustrations as some other format (recent versions of Illustrator support SVG)...
2008/09/30
[ "https://Stackoverflow.com/questions/153762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
Our graphics person uses Adobe Illustrator and we'd like to use her images inside our WPF application as paths. Is there a way to do this?
You can go from AI to SVG to XAML. 1. From Adobe Illustrator: File -> Save As -> \*.SVG. * SVG "Profile 1.1" seems to be sufficient. * Note that to preserve path/group names in XAML you should enable "Preserve Illustrator Editing Capabilities" (or at least as it's called in CS4). 2. [SharpVectors](https://sharpvect...
153,769
<p>As in subject... is there a way of looking at an empty table schema without inserting any rows and issuing a SELECT?</p>
[ { "answer_id": 153779, "author": "Plasmer", "author_id": 397314, "author_profile": "https://Stackoverflow.com/users/397314", "pm_score": 4, "selected": true, "text": "<p>Are you looking for <a href=\"http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/...
2008/09/30
[ "https://Stackoverflow.com/questions/153769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437/" ]
As in subject... is there a way of looking at an empty table schema without inserting any rows and issuing a SELECT?
Are you looking for [DESCRIBE](http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0002019.htm)? `db2 describe table user1.department` ``` Table: USER1.DEPARTMENT Column Type Type name schema name Length Scale Nulls -...
153,776
<p>I am inside of...</p> <pre><code>public class bgchange : IMapServerDropDownBoxAction { void IServerAction.ServerAction(ToolbarItemInfo info) { Some code... </code></pre> <p>and after "some code" I want to trigger</p> <pre><code>[WebMethod] public static void DoSome() { } </code></pre> <p>Which trig...
[ { "answer_id": 153847, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>hmmm... the question changed dramatically since my original answer.</p>\n\n<p>Now I think the answer is no. But I might be ...
2008/09/30
[ "https://Stackoverflow.com/questions/153776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
I am inside of... ``` public class bgchange : IMapServerDropDownBoxAction { void IServerAction.ServerAction(ToolbarItemInfo info) { Some code... ``` and after "some code" I want to trigger ``` [WebMethod] public static void DoSome() { } ``` Which triggers some javascript. Is this possible? Ok, swit...
I'm not sure I fully understand the sequence of what you are trying to do, what's client-side and what's not.... However, you could add a Start-up javascript method to the page which would then call the WebMethod. When calling a WebMethod via javascript, you can add a call-back function, which would then be called whe...
153,782
<p>I am using a codebehind page in ASP.NET to perform a SQL query. The query is loaded into a string, the connection is established (To Oracle), and we get it started by having the connection perform .ExecuteReader into a OleDBDataReader (We'll call it DataRead). I'll try to hammer out an example below. (Consider Dr...
[ { "answer_id": 153788, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 1, "selected": false, "text": "<p>Pardon my possibly faulty VB</p>\n\n<pre><code>Dim item as New ListItem()\nitem.Value = \"foo\"\nitem.Text = \"bar\"...
2008/09/30
[ "https://Stackoverflow.com/questions/153782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12545/" ]
I am using a codebehind page in ASP.NET to perform a SQL query. The query is loaded into a string, the connection is established (To Oracle), and we get it started by having the connection perform .ExecuteReader into a OleDBDataReader (We'll call it DataRead). I'll try to hammer out an example below. (Consider Drop as ...
The [Add](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listitemcollection.add.aspx) function can take a [ListItem](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listitem.aspx), so you can do ``` Dim li as new ListItem(DataRead.Item("Subgroup of Bunnies"), "myValue") Drop.Items....
153,796
<p>I'm trying to loop through all the controls on a sharepoint page, for the purposes of testing i just want to output the control ID</p> <p>this is the code i'm using</p> <p>Public Shared Sub SubstituteValues3(ByVal CurrentPage As Page, ByRef s As StringBuilder)</p> <pre><code> 'Page() '- MasterPage '- H...
[ { "answer_id": 155868, "author": "Aaron Powell", "author_id": 11388, "author_profile": "https://Stackoverflow.com/users/11388", "pm_score": 0, "selected": false, "text": "<p>A MasterPage isn't a control of the current page, it's a property of it, in <strong>Page.MasterPage</strong></p>\n...
2008/09/30
[ "https://Stackoverflow.com/questions/153796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to loop through all the controls on a sharepoint page, for the purposes of testing i just want to output the control ID this is the code i'm using Public Shared Sub SubstituteValues3(ByVal CurrentPage As Page, ByRef s As StringBuilder) ``` 'Page() '- MasterPage '- HtmlForm '- ContentPlaceH...
Start with Page.Master.Controls From there what you have should basically work ``` For Each ctlForm As Control In Page.Master.Controls If TypeOf ctlForm Is HtmlForm Then HttpContext.Current.Response.Output.Write("HTML Form <br/>") For Each ctlContent As Control In...
153,801
<p>I've got a script that takes a user uploaded RTF document and merges in some person data into the letter (name, address, etc), and does this for multiple people. I merge the letter contents, then combine that with the next merge letter contents, for all people records.</p> <p>Affectively I'm combining a single RTF ...
[ { "answer_id": 155094, "author": "Randy", "author_id": 9361, "author_profile": "https://Stackoverflow.com/users/9361", "pm_score": 3, "selected": true, "text": "<p>I would question the use of RTF in this case. It's not entirely clear to me what you're trying to do overall, so I can't ne...
2008/09/30
[ "https://Stackoverflow.com/questions/153801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43/" ]
I've got a script that takes a user uploaded RTF document and merges in some person data into the letter (name, address, etc), and does this for multiple people. I merge the letter contents, then combine that with the next merge letter contents, for all people records. Affectively I'm combining a single RTF document i...
I would question the use of RTF in this case. It's not entirely clear to me what you're trying to do overall, so I can't necessarily suggest anything better, but if you can try to explain your project more broadly, maybe I can help. If this is really the way you want to go though, this regex gave me the correct output...
153,815
<p>I am coming from the SQL server world where we had uniqueidentifier. Is there an equivalent in oracle? This column will be frequently queried so performance is the key.</p> <p>I am generating the GUID in .Net and will be passing it to Oracle. For a couple reasons it cannot be generated by oracle so I cannot use seq...
[ { "answer_id": 153836, "author": "MusiGenesis", "author_id": 14606, "author_profile": "https://Stackoverflow.com/users/14606", "pm_score": 1, "selected": false, "text": "<p>There is no uniqueidentifier in Oracle.</p>\n\n<p>You can implement one yourself by using RAW (kind of a pain) or C...
2008/09/30
[ "https://Stackoverflow.com/questions/153815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1514/" ]
I am coming from the SQL server world where we had uniqueidentifier. Is there an equivalent in oracle? This column will be frequently queried so performance is the key. I am generating the GUID in .Net and will be passing it to Oracle. For a couple reasons it cannot be generated by oracle so I cannot use sequence.
``` CREATE table test (testguid RAW(16) default SYS_GUID() ) ``` [This blog](http://preferisco.blogspot.com/2007/02/unique-ids-for-multi-master-replication.html) studied the relative performance.
153,825
<p>I've got the following query to determine how many votes a story has received:</p> <pre><code>SELECT s_id, s_title, s_time, (s_time-now()) AS s_timediff, ( (SELECT COUNT(*) FROM s_ups WHERE stories.q_id=s_ups.s_id) - (SELECT COUNT(*) FROM s_downs WHERE stories.s_id=s_downs.s_id) ) AS votes FROM stories </code>...
[ { "answer_id": 154094, "author": "J.J.", "author_id": 21204, "author_profile": "https://Stackoverflow.com/users/21204", "pm_score": 2, "selected": false, "text": "<p>y and z are the tricky ones. You want a specific return based on x's value. That sounds like a good reason to make a funct...
2008/09/30
[ "https://Stackoverflow.com/questions/153825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've got the following query to determine how many votes a story has received: ``` SELECT s_id, s_title, s_time, (s_time-now()) AS s_timediff, ( (SELECT COUNT(*) FROM s_ups WHERE stories.q_id=s_ups.s_id) - (SELECT COUNT(*) FROM s_downs WHERE stories.s_id=s_downs.s_id) ) AS votes FROM stories ``` I'd like to app...
Try this: ``` SELECT s_id, s_title, log10(Z) + (Y * s_timediff)/45000 AS redditfunction FROM ( SELECT stories.s_id, stories.s_title, stories.s_time, stories.s_time - now() AS s_timediff, count(s_ups.s_id) - count(s_downs.s_id) as X, if(X>0,1,if(x<0,-1,0)) as Y, if(abs(x)>=1,abs(x),1) a...
153,835
<p>When I want to validate my XML docuemnts against a schema in my server-side Java, I use the built-in JRE Xerces implementation and javax.xml.validation.Schema. It works fine, but when validation fails, Xerces gives error messages that are very close to useless, for example:</p> <pre><code>cvc-minLength-valid: Valu...
[ { "answer_id": 153891, "author": "dacracot", "author_id": 13930, "author_profile": "https://Stackoverflow.com/users/13930", "pm_score": 0, "selected": false, "text": "<p>We use <a href=\"http://www.oracle.com/technology/tech/xml/xdkhome.html\" rel=\"nofollow noreferrer\">Oracle's XDK (XM...
2008/09/30
[ "https://Stackoverflow.com/questions/153835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21234/" ]
When I want to validate my XML docuemnts against a schema in my server-side Java, I use the built-in JRE Xerces implementation and javax.xml.validation.Schema. It works fine, but when validation fails, Xerces gives error messages that are very close to useless, for example: ``` cvc-minLength-valid: Value '' with lengt...
In your handler for the validation, you should receive a SAXParseException with that message, as well as the [column number and the line number](http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/SAXParseException.html#method_summary) in the XML file. Isnt't it the case?
153,846
<p>We have a WCF service deployed on a Windows 2003 server that is exhibiting some problems. The configuration is using <code>wsHttpBinding</code> and we are specifying the IP address. The services is being hosted by a Windows Service.</p> <p>When we start the service up, most of the time it grabs the wrong IP addre...
[ { "answer_id": 154658, "author": "aogan", "author_id": 4795, "author_profile": "https://Stackoverflow.com/users/4795", "pm_score": 1, "selected": false, "text": "<p>Your WCF configuration looks OK to me. This might be an issue with the binding order of your NIC cards. Make sure that the ...
2008/09/30
[ "https://Stackoverflow.com/questions/153846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/312/" ]
We have a WCF service deployed on a Windows 2003 server that is exhibiting some problems. The configuration is using `wsHttpBinding` and we are specifying the IP address. The services is being hosted by a Windows Service. When we start the service up, most of the time it grabs the wrong IP address. A few times it boun...
Your WCF configuration looks OK to me. This might be an issue with the binding order of your NIC cards. Make sure that the NIC with correct address is first. Here is an article that discuss how to set and view nic binding orders: <http://theregime.wordpress.com/2008/03/04/how-to-setview-the-nic-bind-order-in-windows/...
153,861
<p>What do the brackets do in a sql statement?</p> <p>For example, in the statement: </p> <pre>insert into table1 ([columnname1], columnname2) values (val1, val2)</pre> <p>Also, what does it do if the table name is in brackets?</p>
[ { "answer_id": 153870, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 3, "selected": false, "text": "<p>They are meant to escape reserved keywords or invalid column identifiers.</p>\n\n<pre><code>CREATE TABLE test\n(\n...
2008/09/30
[ "https://Stackoverflow.com/questions/153861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/673/" ]
What do the brackets do in a sql statement? For example, in the statement: ``` insert into table1 ([columnname1], columnname2) values (val1, val2) ``` Also, what does it do if the table name is in brackets?
The [] marks the delimitation of a identifier, so if you have a column whose name contains spaces like Order Qty you need to enclose it with [] like: ``` select [Order qty] from [Client sales] ``` They are also to escape reserved keywords used as identifiers
153,863
<p>I have a large 'Manager' class which I think is doing too much but I am unsure on how to divide it into more logical units. </p> <p>Generally speaking the class basically consists of the following methods:</p> <pre> class FooBarManager { GetFooEntities(); AddFooEntity(..); UpdateFooEntity(..); SubmitFooEnt...
[ { "answer_id": 153901, "author": "Jamie Ide", "author_id": 12752, "author_profile": "https://Stackoverflow.com/users/12752", "pm_score": 1, "selected": false, "text": "<p>You really shouldn't put all data access into one class unless it's generic. I would start by splitting out your data...
2008/09/30
[ "https://Stackoverflow.com/questions/153863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15771/" ]
I have a large 'Manager' class which I think is doing too much but I am unsure on how to divide it into more logical units. Generally speaking the class basically consists of the following methods: ``` class FooBarManager { GetFooEntities(); AddFooEntity(..); UpdateFooEntity(..); SubmitFooEntity(..); GetF...
You really shouldn't put all data access into one class unless it's generic. I would start by splitting out your data access classes into one manager per object or related groups of objects, i.e. CompanyManager, CustomerManager, etc. If your need to access the manager through one "god class" you could have an instance ...
153,879
<p>As part of a build setup on a windows machine I need to add a registry entry and I'd like to do it from a simple batch file.</p> <p>The entry is for a third party app so the format is fixed.</p> <p>The entry takes the form of a REG_SZ string but needs to contain newlines ie. 0xOA characters as separators.</p> <p>...
[ { "answer_id": 153952, "author": "tloach", "author_id": 14092, "author_profile": "https://Stackoverflow.com/users/14092", "pm_score": 3, "selected": true, "text": "<p>You could create a VBScript(.vbs) file and just call it from a batch file, assuming you're doing other things in the batc...
2008/09/30
[ "https://Stackoverflow.com/questions/153879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5427/" ]
As part of a build setup on a windows machine I need to add a registry entry and I'd like to do it from a simple batch file. The entry is for a third party app so the format is fixed. The entry takes the form of a REG\_SZ string but needs to contain newlines ie. 0xOA characters as separators. I've hit a few problems...
You could create a VBScript(.vbs) file and just call it from a batch file, assuming you're doing other things in the batch other than this registry change. In vbscript you would be looking at something like: ``` set WSHShell = CreateObject("WScript.Shell") WSHShell.RegWrite "HKEY_LOCAL_MACHINE\SOMEKEY", "value", "ty...
153,890
<p>I'm trying to find a good way to print leading <code>0</code>, such as <code>01001</code> for a <a href="https://en.wikipedia.org/wiki/ZIP_Code" rel="noreferrer">ZIP Code</a>. While the number would be stored as <code>1001</code>, what is a good way to do it?</p> <p>I thought of using either <code>case</code> statem...
[ { "answer_id": 153895, "author": "EvilTeach", "author_id": 7734, "author_profile": "https://Stackoverflow.com/users/7734", "pm_score": 10, "selected": true, "text": "<pre><code>printf(&quot;%05d&quot;, zipCode);\n</code></pre>\n<p>The <code>0</code> indicates what you are padding with an...
2008/09/30
[ "https://Stackoverflow.com/questions/153890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
I'm trying to find a good way to print leading `0`, such as `01001` for a [ZIP Code](https://en.wikipedia.org/wiki/ZIP_Code). While the number would be stored as `1001`, what is a good way to do it? I thought of using either `case` statements or `if` to figure out how many digits the number is and then convert it to a...
``` printf("%05d", zipCode); ``` The `0` indicates what you are padding with and the `5` shows the width of the integer number. Example 1: If you use `"%02d"` (useful for dates) this would only pad zeros for numbers in the ones column. E.g., `06` instead of `6`. Example 2: `"%03d"` would pad 2 zeros for one number ...
153,909
<p>I call my JavaScript function. Why do I <em>sometimes</em> get the error 'myFunction is not defined' when it <em>is</em> defined?</p> <p>For example. I'll occasionally get 'copyArray is not defined' even in this example:</p> <pre><code>function copyArray( pa ) { var la = []; for (var i=0; i &lt; pa.length;...
[ { "answer_id": 153925, "author": "Per Hornshøj-Schierbeck", "author_id": 11619, "author_profile": "https://Stackoverflow.com/users/11619", "pm_score": 2, "selected": false, "text": "<p>My guess is, somehow the document is not fully loaded by the time the method is called. Have your code ...
2008/09/30
[ "https://Stackoverflow.com/questions/153909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4525/" ]
I call my JavaScript function. Why do I *sometimes* get the error 'myFunction is not defined' when it *is* defined? For example. I'll occasionally get 'copyArray is not defined' even in this example: ``` function copyArray( pa ) { var la = []; for (var i=0; i < pa.length; i++) la.push( pa[i] ); re...
It shouldn't be possible for this to happen if you're just including the scripts on the page. The "copyArray" function should always be available when the JavaScript code starts executing no matter if it is declared before or after it -- unless you're loading the JavaScript files in dynamically with a dependency libr...
153,920
<p>Code I am trying to run:</p> <pre><code>$query = "DESCRIBE TABLE TABLENAME"; $result = odbc_exec($h, $query); </code></pre> <p>The result:</p> <blockquote> <p>PHP Warning: odbc_exec(): SQL error: [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token TABLENAME was not valid. Valid tokens: INTO...
[ { "answer_id": 154182, "author": "Mike Wills", "author_id": 2535, "author_profile": "https://Stackoverflow.com/users/2535", "pm_score": 0, "selected": false, "text": "<p>To me it looks like you need to provide a way for the statement to return a value \"Valid tokens: INTO\" tells me that...
2008/09/30
[ "https://Stackoverflow.com/questions/153920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437/" ]
Code I am trying to run: ``` $query = "DESCRIBE TABLE TABLENAME"; $result = odbc_exec($h, $query); ``` The result: > > PHP Warning: odbc\_exec(): SQL error: [unixODBC][IBM][iSeries Access > ODBC Driver][DB2 UDB]SQL0104 - Token TABLENAME was not valid. Valid > tokens: INTO., SQL state 37000 in SQLExecDirect in .....
The iSeries flavor of DB2 does not support the SQL DESCRIBE statement. Instead, you have to query the system table: ``` select * from qsys2.columns where table_schema = 'my_schema' and table_name = 'my_table' ```
153,934
<p>I'm trying to modify the class of an element if an ajax call based on that element is successful</p> <pre><code>&lt;script type='text/javascript'&gt; $("#a.toggle").click(function(e){ $.ajax({ url: '/changeItem.php', dataType: 'json', type: 'POST', success: function(data,text){ ...
[ { "answer_id": 153948, "author": "Dan Goldstein", "author_id": 23427, "author_profile": "https://Stackoverflow.com/users/23427", "pm_score": 5, "selected": true, "text": "<p>You can just store it in a variable. Example:</p>\n\n<pre><code>$(\"#a.toggle\").click(function(e)\n{\n var targ...
2008/09/30
[ "https://Stackoverflow.com/questions/153934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
I'm trying to modify the class of an element if an ajax call based on that element is successful ``` <script type='text/javascript'> $("#a.toggle").click(function(e){ $.ajax({ url: '/changeItem.php', dataType: 'json', type: 'POST', success: function(data,text){ if(data.e...
You can just store it in a variable. Example: ``` $("#a.toggle").click(function(e) { var target = $(this); $.ajax({ url: '/changeItem.php', dataType: 'json', type: 'POST', success: function(data,text) { if(data.error=='') { if(target.hasClass('class1'))...
153,953
<p>I’m trying to debug a memory leak problem. I’m using <a href="http://www.gnu.org/software/libc/manual/html_node/Tracing-malloc.html#Tracing-malloc" rel="noreferrer">mtrace()</a> to get a malloc/free/realloc trace. I’ve ran my prog and have now a huge log file. So far so good. But I have problems interpreting the fil...
[ { "answer_id": 154019, "author": "florin", "author_id": 18308, "author_profile": "https://Stackoverflow.com/users/18308", "pm_score": 0, "selected": false, "text": "<p>One possible explanation is that the same function is allocating different buffer sizes? One such example is strdup.</p>...
2008/09/30
[ "https://Stackoverflow.com/questions/153953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17428/" ]
I’m trying to debug a memory leak problem. I’m using [mtrace()](http://www.gnu.org/software/libc/manual/html_node/Tracing-malloc.html#Tracing-malloc) to get a malloc/free/realloc trace. I’ve ran my prog and have now a huge log file. So far so good. But I have problems interpreting the file. Look at these lines: ``` @ ...
The function that is allocating the memory is being called more than once. The caller address points to the code that did the allocation, and that code is simply being run more than once. Here is an example in C: ``` void *allocate (void) { return (malloc(1000)); } int main() { mtrace(); allocate(); allocate...
153,974
<p>I'm wondering how (un)common it is to encapsulate an algorithm into a class? More concretely, instead of having a number of separate functions that forward common parameters between each other:</p> <pre><code>void f(int common1, int param1, int *out1); void g(int common1, int common2, int param1, int *out2) { f(c...
[ { "answer_id": 153984, "author": "ctrlShiftBryan", "author_id": 6161, "author_profile": "https://Stackoverflow.com/users/6161", "pm_score": 0, "selected": false, "text": "<p>If you would ever need to call both methods with the constructor parameters then i would do it.</p>\n\n<p>If you w...
2008/09/30
[ "https://Stackoverflow.com/questions/153974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2583/" ]
I'm wondering how (un)common it is to encapsulate an algorithm into a class? More concretely, instead of having a number of separate functions that forward common parameters between each other: ``` void f(int common1, int param1, int *out1); void g(int common1, int common2, int param1, int *out2) { f(common1, param1...
It's not a bad strategy at all. In fact, if you have the ability in your language (which you do in C++) to define some type of abstract superclass which defines an opaque interface to the underlying functionality, you can swap different algorithms in and out at runtime (think sorting algorithms, for example). If your c...
153,988
<p>I need to copy some records from our SQLServer 2005 test server to our live server. It's a flat lookup table, so no foreign keys or other referential integrity to worry about.</p> <p>I could key-in the records again on the live server, but this is tiresome. I could export the test server records and table data in...
[ { "answer_id": 154011, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 2, "selected": false, "text": "<p>An SSIS package would be best suited to do the transfer, it would take literally seconds to setup!</p>\n" }, ...
2008/09/30
[ "https://Stackoverflow.com/questions/153988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7703/" ]
I need to copy some records from our SQLServer 2005 test server to our live server. It's a flat lookup table, so no foreign keys or other referential integrity to worry about. I could key-in the records again on the live server, but this is tiresome. I could export the test server records and table data in its entiret...
If your production SQL server and test SQL server can talk, you could just do in with a SQL insert statement. first run the following on your test server: ``` Execute sp_addlinkedserver PRODUCTION_SERVER_NAME ``` Then just create the insert statement: ``` INSERT INTO [PRODUCTION_SERVER_NAME].DATABASE_NAME.dbo.TABL...
153,989
<p>I have a little logging app (written in wxPython) that receives data from a bit of kit we're developing, and I want to display the text in a scrolling window. As it stands I'm using a wx.TextCtrl for the text display, but I'm having some issues with the scrolling behaviour.</p> <p>Basically, I'd like it so that if ...
[ { "answer_id": 154225, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 2, "selected": true, "text": "<p>I just tested a simple example (checking <code>GetScrollPos(0)</code> and <code>GetScrollRange(0)</code> in <code>EVT_TEXT...
2008/09/30
[ "https://Stackoverflow.com/questions/153989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15369/" ]
I have a little logging app (written in wxPython) that receives data from a bit of kit we're developing, and I want to display the text in a scrolling window. As it stands I'm using a wx.TextCtrl for the text display, but I'm having some issues with the scrolling behaviour. Basically, I'd like it so that if the scroll...
I just tested a simple example (checking `GetScrollPos(0)` and `GetScrollRange(0)` in `EVT_TEXT` event handler for `wx.TextCtrl`) and it works fine for me - they return index of currently shown line and total number of lines, respectively. Maybe the problem is your wxPython version? I used: ``` >>> import wx >>> wx.v...
153,994
<p>I want to have a class which implements an interface, which specifies the specific subclass as a parameter.</p> <pre><code>public abstract Task implements TaskStatus&lt;Task&gt; { TaskStatus&lt;T&gt; listener; protected complete() { // ugly, unsafe cast callback.complete((T) this); } } public in...
[ { "answer_id": 154340, "author": "Bruno De Fraine", "author_id": 6918, "author_profile": "https://Stackoverflow.com/users/6918", "pm_score": 3, "selected": true, "text": "<p>It is not clear what you are trying to do inside of <code>Task</code>. However, if you define the generic class <c...
2008/09/30
[ "https://Stackoverflow.com/questions/153994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/758/" ]
I want to have a class which implements an interface, which specifies the specific subclass as a parameter. ``` public abstract Task implements TaskStatus<Task> { TaskStatus<T> listener; protected complete() { // ugly, unsafe cast callback.complete((T) this); } } public interface TaskStatus<T> { ...
It is not clear what you are trying to do inside of `Task`. However, if you define the generic class `Task<T>` as follows: ``` class Task<T extends Task<T>> { ... } ``` The following two are possible: ``` class MyTask extends Task<MyTask> { ... } class YourTask extends Task<MyTask> { ... } ``` But the following i...
154,004
<p>I have a link that I dynamically create which looks something like the following:</p> <pre><code>&lt;a onclick="Edit('value from a text column here')" href="javascript:void(null);"&gt;Edit&lt;/a&gt; </code></pre> <p>with the Edit function then taking the passed in value and putting it into a Yahoo Rich Text Editor...
[ { "answer_id": 154018, "author": "Chris Johnson", "author_id": 23732, "author_profile": "https://Stackoverflow.com/users/23732", "pm_score": 5, "selected": true, "text": "<p>Convert quote charaters to their HTML equivalents, <code>&amp;quot;</code> etc. before you insert them into the HT...
2008/09/30
[ "https://Stackoverflow.com/questions/154004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22777/" ]
I have a link that I dynamically create which looks something like the following: ``` <a onclick="Edit('value from a text column here')" href="javascript:void(null);">Edit</a> ``` with the Edit function then taking the passed in value and putting it into a Yahoo Rich Text Editor. This works well except for when ther...
Convert quote charaters to their HTML equivalents, `&quot;` etc. before you insert them into the HTML. There's a [long list](http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references) of HTML/XML character codes on wikipedia. There may well be a function to do this for you, depending on how you're...
154,013
<p>My Django app has a Person table, which contains the following text in a field named <code>details</code>:</p> <p><code>&lt;script&gt;alert('Hello');&lt;/script&gt;</code></p> <p>When I call <code>PersonForm.details</code> in my template, the page renders the script accordingly (a.k.a., an alert with the word "Hel...
[ { "answer_id": 154027, "author": "Jon Cage", "author_id": 15369, "author_profile": "https://Stackoverflow.com/users/15369", "pm_score": 4, "selected": true, "text": "<p>You need to mark the values as | safe I think (I'm guessing that you're filling in the value from the database here(?))...
2008/09/30
[ "https://Stackoverflow.com/questions/154013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
My Django app has a Person table, which contains the following text in a field named `details`: `<script>alert('Hello');</script>` When I call `PersonForm.details` in my template, the page renders the script accordingly (a.k.a., an alert with the word "Hello" is displayed). I'm confused by this behavior because I alw...
You need to mark the values as | safe I think (I'm guessing that you're filling in the value from the database here(?)): ``` {{ value|safe }} ``` Could you post a sample of the template? Might make it easier to see what's wrong **[Edit]** ..or are you saying that you *want* it to escape the values (make them safe)?...
154,031
<pre><code>Pattern pattern = Pattern.compile("^[a-z]+$"); String string = "abc-def"; assertTrue( pattern.matcher(string).matches() ); // obviously fails </code></pre> <p>Is it possible to have the character class match a "-" ?</p>
[ { "answer_id": 154037, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 3, "selected": false, "text": "<p>Escape the minus sign</p>\n\n<pre><code>[a-z\\\\-]\n</code></pre>\n" }, { "answer_id": 154040, "author": ...
2008/09/30
[ "https://Stackoverflow.com/questions/154031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11858/" ]
``` Pattern pattern = Pattern.compile("^[a-z]+$"); String string = "abc-def"; assertTrue( pattern.matcher(string).matches() ); // obviously fails ``` Is it possible to have the character class match a "-" ?
Don't put the minus sign between characters. ``` "[a-z-]" ```
154,042
<p>I'm using spring 2.5 and annotations to configure my spring-mvc web context. Unfortunately, I am unable to get the following to work. I'm not sure if this is a bug (seems like it) or if there is a basic misunderstanding on how the annotations and interface implementation subclassing works.</p> <p>For example,</p>...
[ { "answer_id": 355234, "author": "Ed Thomas", "author_id": 8256, "author_profile": "https://Stackoverflow.com/users/8256", "pm_score": 3, "selected": false, "text": "<p>There's no doubt that annotations and inheritance can get a little tricky, but I think that should work. Try explicitly...
2008/09/30
[ "https://Stackoverflow.com/questions/154042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9955/" ]
I'm using spring 2.5 and annotations to configure my spring-mvc web context. Unfortunately, I am unable to get the following to work. I'm not sure if this is a bug (seems like it) or if there is a basic misunderstanding on how the annotations and interface implementation subclassing works. For example, ``` @Controlle...
Ed is right, adding ``` <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> ``` works fine
154,059
<p>Is there a <code>string.Empty</code> in JavaScript, or is it just a case of checking for <code>&quot;&quot;</code>?</p>
[ { "answer_id": 154068, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 13, "selected": true, "text": "<h3>Empty string, undefined, null, ...</h3>\n<p>To check for a <a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Tr...
2008/09/30
[ "https://Stackoverflow.com/questions/154059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5619/" ]
Is there a `string.Empty` in JavaScript, or is it just a case of checking for `""`?
### Empty string, undefined, null, ... To check for a [truthy value](https://developer.mozilla.org/en-US/docs/Glossary/Truthy): ``` if (strValue) { // strValue was non-empty string, true, 42, Infinity, [], ... } ``` To check for a [falsy value](https://developer.mozilla.org/en-US/docs/Glossary/Falsy): ``` if (...
154,075
<p>I have a Virtual Machine in Virtual PC 2007.</p> <p>To start it from the desktop, I have the following command in a batch file:</p> <pre><code>"c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch </code></pre> <p>But that leaves a dos prompt on the host machine until the virtual machine shut...
[ { "answer_id": 154083, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": -1, "selected": false, "text": "<p>have you tried:</p>\n\n<pre><code>start \"c:\\program files\\Microsoft Virtual PC\\Virtual PC.exe\" \"-pc MY-PC -lau...
2008/09/30
[ "https://Stackoverflow.com/questions/154075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
I have a Virtual Machine in Virtual PC 2007. To start it from the desktop, I have the following command in a batch file: ``` "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch ``` But that leaves a dos prompt on the host machine until the virtual machine shuts down, and I exit out of the Vir...
START has a peculiarity involving double quotes around the first parameter. If the first parameter has double quotes it uses that as the optional TITLE for the new window. I believe what you want is: ``` start "" "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc MY-PC -launch ``` In other words, give it a...
154,089
<p>Anyone know how to programmatically mute the Windows XP Volume using C#?</p>
[ { "answer_id": 154128, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 4, "selected": false, "text": "<p>Declare this for P/Invoke:</p>\n\n<pre><code>private const int APPCOMMAND_VOLUME_MUTE = 0x80000;\nprivate const in...
2008/09/30
[ "https://Stackoverflow.com/questions/154089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316/" ]
Anyone know how to programmatically mute the Windows XP Volume using C#?
Declare this for P/Invoke: ``` private const int APPCOMMAND_VOLUME_MUTE = 0x80000; private const int WM_APPCOMMAND = 0x319; [DllImport("user32.dll")] public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); ``` And then use this line to mute/unmute the sound. ``` SendMessageW(t...
154,109
<p>When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark method...
[ { "answer_id": 154120, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 6, "selected": false, "text": "<p>In some compilers you can use #warning to issue a warning:</p>\n\n<pre><code>#warning \"Do not use ABC, which is de...
2008/09/30
[ "https://Stackoverflow.com/questions/154109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark methods o...
Update ------ This is now possible with Roslyn (Visual Studio 2015). You can [build](https://johnkoerner.com/csharp/creating-your-first-code-analyzer/) a [code analyzer](https://github.com/dotnet/roslyn/wiki/How-To-Write-a-C%23-Analyzer-and-Code-Fix) to check for a custom attribute --- *Original outdated answer:* I...
154,112
<p>Without running this code, identify which <code>Foo</code> method will be called:</p> <pre><code>class A { public void Foo( int n ) { Console.WriteLine( "A::Foo" ); } } class B : A { /* note that A::Foo and B::Foo are not related at all */ public void Foo( double n ) { Console.WriteLi...
[ { "answer_id": 154139, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 3, "selected": false, "text": "<p>Console.WriteLine( \"B::Foo\");</p>\n\n<p>Because it will cast automatictly and use the first without going ...
2008/09/30
[ "https://Stackoverflow.com/questions/154112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
Without running this code, identify which `Foo` method will be called: ``` class A { public void Foo( int n ) { Console.WriteLine( "A::Foo" ); } } class B : A { /* note that A::Foo and B::Foo are not related at all */ public void Foo( double n ) { Console.WriteLine( "B::Foo" ); } } s...
I really wouldn't use this as an interview question. I know the answer and the reasoning behind it, but something like this should come up so rarely that it shouldn't be a problem. Knowing the answer really doesn't show much about a candidate's ability to code. Note that you'll get the same behaviour even if A.Foo is ...
154,117
<p>Is there a way to execute a full ASPX source file where the page source is from a string/database/resource and not a file on the file system? It's straightfoward to render dynamic content/images/etc using HTTP Handlers and Modules and writing to the Response, but there doesn't seem to be a way to execute/compile AS...
[ { "answer_id": 154240, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 1, "selected": false, "text": "<p>Update: Check the post by <a href=\"https://stackoverflow.com/questions/154117#154279\">korchev</a> using virtualpat...
2008/09/30
[ "https://Stackoverflow.com/questions/154117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a way to execute a full ASPX source file where the page source is from a string/database/resource and not a file on the file system? It's straightfoward to render dynamic content/images/etc using HTTP Handlers and Modules and writing to the Response, but there doesn't seem to be a way to execute/compile ASPX s...
Perhaps you need a [virtual path provider](http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx). It allows you to store the ASPX and codebehind in different media - RDBMS, xml file etc.
154,119
<p>This was an interview question. Given Visual Studio 2008 and an icon saved as a .PNG file, they required the image as an embedded resource and to be used as the icon within the title bar of a form.</p> <p>I'm looking for what would have been the model answer to this question, Both (working!) code and any Visual Stu...
[ { "answer_id": 154127, "author": "Patrik Svensson", "author_id": 936, "author_profile": "https://Stackoverflow.com/users/936", "pm_score": 1, "selected": false, "text": "<p>A good resource on the subject in <em><a href=\"http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/4a10d...
2008/09/30
[ "https://Stackoverflow.com/questions/154119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
This was an interview question. Given Visual Studio 2008 and an icon saved as a .PNG file, they required the image as an embedded resource and to be used as the icon within the title bar of a form. I'm looking for what would have been the model answer to this question, Both (working!) code and any Visual Studio tricks...
Fire up VS, start new Windows Application. Open the properties sheet, add the .png file as a resource (in this example: glider.png ). From hereon, you can access the resource as a Bitmap file as WindowsFormsApplication10.Properties.Resources.glider Code for using it as an application icon: ``` public Form1() ...
154,136
<p>In many C/C++ macros I'm seeing the code of the macro wrapped in what seems like a meaningless <code>do while</code> loop. Here are examples.</p> <pre><code>#define FOO(X) do { f(X); g(X); } while (0) #define FOO(X) if (1) { f(X); g(X); } else </code></pre> <p>I can't see what the <code>do while</code> is doing. ...
[ { "answer_id": 154138, "author": "jfm3", "author_id": 11138, "author_profile": "https://Stackoverflow.com/users/11138", "pm_score": 11, "selected": true, "text": "<p>The <code>do ... while</code> and <code>if ... else</code> are there to make it so that a\nsemicolon after your macro alwa...
2008/09/30
[ "https://Stackoverflow.com/questions/154136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11138/" ]
In many C/C++ macros I'm seeing the code of the macro wrapped in what seems like a meaningless `do while` loop. Here are examples. ``` #define FOO(X) do { f(X); g(X); } while (0) #define FOO(X) if (1) { f(X); g(X); } else ``` I can't see what the `do while` is doing. Why not just write this without it? ``` #define ...
The `do ... while` and `if ... else` are there to make it so that a semicolon after your macro always means the same thing. Let's say you had something like your second macro. ``` #define BAR(X) f(x); g(x) ``` Now if you were to use `BAR(X);` in an `if ... else` statement, where the bodies of the if statement were n...
154,163
<p>I need to detect whether my application is running within a virtualized OS instance or not.</p> <p>I've found <A HREF="http://www.codeproject.com/KB/system/VmDetect.aspx" rel="noreferrer">an article</A> with some useful information on the topic. The same article appears in multiple places, I'm unsure of the origina...
[ { "answer_id": 154168, "author": "warren", "author_id": 4418, "author_profile": "https://Stackoverflow.com/users/4418", "pm_score": 3, "selected": false, "text": "<p>Under Linux, you can report on /proc/cpuinfo. If it's in VMware, it usually comes-up differently than if it is on bare met...
2008/09/30
[ "https://Stackoverflow.com/questions/154163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4761/" ]
I need to detect whether my application is running within a virtualized OS instance or not. I've found [an article](http://www.codeproject.com/KB/system/VmDetect.aspx) with some useful information on the topic. The same article appears in multiple places, I'm unsure of the original source. [VMware](http://www.vmware.c...
Have you heard about [blue pill, red pill?](http://web.archive.org/web/20100725003848/http://www.redlightsecurity.com/2008/04/virtualization-red-pill-or-blue.html). It's a technique used to see if you are running inside a virtual machine or not. The origin of the term stems from [the matrix movie](http://www.imdb.com/t...
154,204
<p>Is there any way to change the default tab size in a .NET RichTextBox? It currently seems to be set to the equivalent of 8 spaces which is kinda large for my taste.</p> <p>Edit: To clarify, I want to set the global default of "\t" displays as 4 spaces for the control. From what I can understand, the SelectionTabs...
[ { "answer_id": 154255, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 6, "selected": true, "text": "<p>You can set it by setting the <a href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.sel...
2008/09/30
[ "https://Stackoverflow.com/questions/154204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
Is there any way to change the default tab size in a .NET RichTextBox? It currently seems to be set to the equivalent of 8 spaces which is kinda large for my taste. Edit: To clarify, I want to set the global default of "\t" displays as 4 spaces for the control. From what I can understand, the SelectionTabs property re...
You can set it by setting the [SelectionTabs](http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectiontabs.aspx) property. ``` private void Form1_Load(object sender, EventArgs e) { richTextBox1.SelectionTabs = new int[] { 100, 200, 300, 400 }; } ``` UPDATE: The sequence matters.... ...
154,209
<p>In Ruby-on-Rails, this is called a "polymorphic association."</p> <p>I have several <code>Commentable</code> things in my application, the tables for each are below:</p> <pre><code>Post id | title | text | author (FK:Person.id) | ... Person id | name | ... Photo id | title | owner (FK:Person.id) | path | ... </c...
[ { "answer_id": 154237, "author": "Joe Phillips", "author_id": 20471, "author_profile": "https://Stackoverflow.com/users/20471", "pm_score": 0, "selected": false, "text": "<p>I believe many people make meta-tables for that sort of thing. Pretty much exactly as you described it.</p>\n" }...
2008/09/30
[ "https://Stackoverflow.com/questions/154209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1190/" ]
In Ruby-on-Rails, this is called a "polymorphic association." I have several `Commentable` things in my application, the tables for each are below: ``` Post id | title | text | author (FK:Person.id) | ... Person id | name | ... Photo id | title | owner (FK:Person.id) | path | ... ``` I'd like to add a `Comments` ...
This technique is known colloquially in the SQL world as 'subclassing'. For a worked example (SQL Server syntax but is easily adapted for MS Access), see [David Porta's blog.](http://web.archive.org/web/20100309034643/http://consultingblogs.emc.com/davidportas/archive/2007/01/08/Distributed-Keys-and-Disjoint-Subtypes.a...
154,232
<p>The app uses DLLImport to call a legacy unmanaged dll. Let's call this dll Unmanaged.dll for the sake of this question. Unmanaged.dll has dependencies on 5 other legacy dll's. All of the legacy dll's are placed in the WebApp/bin/ directory of my ASP.NET application.</p> <p>When IIS is running in 5.0 isolation mode,...
[ { "answer_id": 154360, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 0, "selected": false, "text": "<p>What is the error given? if the application truly crashed you might have to go into the Windows Event Log to g...
2008/09/30
[ "https://Stackoverflow.com/questions/154232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The app uses DLLImport to call a legacy unmanaged dll. Let's call this dll Unmanaged.dll for the sake of this question. Unmanaged.dll has dependencies on 5 other legacy dll's. All of the legacy dll's are placed in the WebApp/bin/ directory of my ASP.NET application. When IIS is running in 5.0 isolation mode, the app w...
Solution: Create a new thread in which to run the imported dll, assign more memory to its stack.
154,248
<p>I tried:</p> <pre><code>DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f); Node mapNode = getMapNode(doc); System.out.print("\r\n elementName "+ mapNode.getNodeName());//This works fine. Element e = (Element) mapNode; //Thi...
[ { "answer_id": 154297, "author": "Garth Gilmour", "author_id": 2635682, "author_profile": "https://Stackoverflow.com/users/2635682", "pm_score": 0, "selected": false, "text": "<p>Might the first child be a whitespace only text node or suchlike?</p>\n\n<p>Try:</p>\n\n<pre><code>System.out...
2008/09/30
[ "https://Stackoverflow.com/questions/154248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
I tried: ``` DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f); Node mapNode = getMapNode(doc); System.out.print("\r\n elementName "+ mapNode.getNodeName());//This works fine. Element e = (Element) mapNode; //This is where the...
I was using a different dtd file on the server. That was causing the issue.
154,256
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/105372/c-how-to-enumerate-an-enum">C#: How to enumerate an enum?</a> </p> </blockquote> <p>The subject says all. I want to use that to add the values of an enum in a combobox.</p> <p>Thanks</p> <p>vIceBerg</p...
[ { "answer_id": 154263, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 6, "selected": true, "text": "<pre><code>string[] names = Enum.GetNames (typeof(MyEnum));\n</code></pre>\n\n<p>Then just populate the dropdown withe th...
2008/09/30
[ "https://Stackoverflow.com/questions/154256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17766/" ]
> > **Possible Duplicate:** > > [C#: How to enumerate an enum?](https://stackoverflow.com/questions/105372/c-how-to-enumerate-an-enum) > > > The subject says all. I want to use that to add the values of an enum in a combobox. Thanks vIceBerg
``` string[] names = Enum.GetNames (typeof(MyEnum)); ``` Then just populate the dropdown withe the array
154,261
<p>I frequently run into problems of this form and haven't found a good solution yet:</p> <p>Assume we have two database tables representing an e-commerce system.</p> <pre><code>userData (userId, name, ...) orderData (orderId, userId, orderType, createDate, ...) </code></pre> <p>For all users in the system, select t...
[ { "answer_id": 154272, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 0, "selected": false, "text": "<p>Their newest you mean all new in the current day? You can always check with your createDate and get all user...
2008/09/30
[ "https://Stackoverflow.com/questions/154261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9304/" ]
I frequently run into problems of this form and haven't found a good solution yet: Assume we have two database tables representing an e-commerce system. ``` userData (userId, name, ...) orderData (orderId, userId, orderType, createDate, ...) ``` For all users in the system, select their user information, their most...
This should work, you'll have to adjust the table / column names: ``` select ud.name, order1.order_id, order1.order_type, order1.create_date, order2.order_id, order2.order_type, order2.create_date from user_data ud, order_data order1, order_data order2 where u...
154,262
<p>It's very easy to mark an image file to become an embedded resource however how does one access the image thereafter. Please can I have some example code?</p>
[ { "answer_id": 154271, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 1, "selected": false, "text": "<p>Look at the third code snippet at <a href=\"http://msdn.microsoft.com/en-us/library/aa309403(VS.71).aspx\" rel=\"n...
2008/09/30
[ "https://Stackoverflow.com/questions/154262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
It's very easy to mark an image file to become an embedded resource however how does one access the image thereafter. Please can I have some example code?
The most direct method: ``` YourProjectsBaseNamespace.Properties.Resources.YourImageResourceName ```
154,295
<p>In the latest MVC preview, I'm using this route for a legacy URL:</p> <pre><code>routes.MapRoute( "Legacy-Firefox", // Route name "Firefox-Extension/", // URL with parameters new { controller = "Home", action = "Firefox", id = "" } // Parameter defaults ); </code></pre> <p>The problem is that both of these URL's w...
[ { "answer_id": 274431, "author": "Armstrongest", "author_id": 26931, "author_profile": "https://Stackoverflow.com/users/26931", "pm_score": 2, "selected": false, "text": "<p>When you write your links, you should always include the final slash. I don't know if this applies to the mvc fra...
2008/09/30
[ "https://Stackoverflow.com/questions/154295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23837/" ]
In the latest MVC preview, I'm using this route for a legacy URL: ``` routes.MapRoute( "Legacy-Firefox", // Route name "Firefox-Extension/", // URL with parameters new { controller = "Home", action = "Firefox", id = "" } // Parameter defaults ); ``` The problem is that both of these URL's work: <http://example.com/F...
When you write your links, you should always include the final slash. I don't know if this applies to the mvc framework (or URL Routing in general), but I know that for static resources, if you don't put the slash in you add a slight overhead as the request gets done twice. The slash immediately identifies the url as...
154,299
<p>I am debugging a VB6 executable. The executable loads dlls and files from it's current directory, when running. When run in debugger, the current directory seems to be VB6's dir. </p> <p>How do I set working directory for VB6?</p>
[ { "answer_id": 154327, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://sintaks.blogspot.com/2006/07/vb6-set-current-working-directory.html\" rel=\"nofollow noreferrer\">W...
2008/09/30
[ "https://Stackoverflow.com/questions/154299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814/" ]
I am debugging a VB6 executable. The executable loads dlls and files from it's current directory, when running. When run in debugger, the current directory seems to be VB6's dir. How do I set working directory for VB6?
It doesn't seems to be a "out of the box" solution for this thing. Taken from [The Old Joel On Software Forums](http://discuss.fogcreek.com/joelonsoftware1/default.asp?cmd=show&ixPost=19026&ixReplies=5) > > Anyways.. to put this topic to rest.. > the following was my VB6 solution: I > define 2 symbols in my VB pr...
154,305
<p>Given the following canvas:</p> <pre><code>&lt;Canvas&gt; &lt;Canvas.LayoutTransform&gt; &lt;ScaleTransform ScaleX="1" ScaleY="1" CenterX=".5" CenterY=".5" /&gt; &lt;/Canvas.LayoutTransform&gt; &lt;Button x:Name="scaleButton" Content="Scale Me" Canvas.Top="10" Canvas.Left="10" /&gt; &lt;Butt...
[ { "answer_id": 154380, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 4, "selected": true, "text": "<p>Not in XAML. You can do this in code by building the reverse transform and applying it to the object you don't want...
2008/09/30
[ "https://Stackoverflow.com/questions/154305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4580/" ]
Given the following canvas: ``` <Canvas> <Canvas.LayoutTransform> <ScaleTransform ScaleX="1" ScaleY="1" CenterX=".5" CenterY=".5" /> </Canvas.LayoutTransform> <Button x:Name="scaleButton" Content="Scale Me" Canvas.Top="10" Canvas.Left="10" /> <Button x:Name="dontScaleButton" Content="DON'T Scal...
Not in XAML. You can do this in code by building the reverse transform and applying it to the object you don't want transformed. If you want to go fancy, you can build a dependency property that you can attach in XAML to any object you don't want to be transformed by any parent transforms. This dependency property wil...
154,307
<p>I just saw this behaviour and I'm a bit surprised by it...</p> <p>If I add 3 or 4 elements to a Dictionary, and then do a "For Each" to get all the keys, they appear in the same order I added them.</p> <p>The reason this surprises me is that a Dictionary is supposed to be a HashTable internally, so I expected thin...
[ { "answer_id": 154313, "author": "Brad Wilson", "author_id": 1554, "author_profile": "https://Stackoverflow.com/users/1554", "pm_score": 3, "selected": false, "text": "<p>A dictionary retrieves items in hashed order. The fact that they came out in insertion order was a total coincidence....
2008/09/30
[ "https://Stackoverflow.com/questions/154307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
I just saw this behaviour and I'm a bit surprised by it... If I add 3 or 4 elements to a Dictionary, and then do a "For Each" to get all the keys, they appear in the same order I added them. The reason this surprises me is that a Dictionary is supposed to be a HashTable internally, so I expected things to come out in...
If you use .NET Reflector on the 3.5 class libraries you can see that the implementation of Dictionary actually stores the items in an array (which is resized as needed), and hashes indexes into that array. When getting the keys, it completely ignores the hashtable and iterates over the array of items. For this reason,...
154,309
<p>One of our programs is sometimes getting an <code>OutOfMemory</code> error on one user's machine, but of course not when I'm testing it. I just ran it with JProfiler (on a 10 day evaluation license because I've never used it before), and filtering on our code prefix, the biggest chunk both in total size and number ...
[ { "answer_id": 154362, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 2, "selected": false, "text": "<p>Keep an eye out for static containers. Any objects in a static container will remain as long as the class is loaded.</p...
2008/09/30
[ "https://Stackoverflow.com/questions/154309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3333/" ]
One of our programs is sometimes getting an `OutOfMemory` error on one user's machine, but of course not when I'm testing it. I just ran it with JProfiler (on a 10 day evaluation license because I've never used it before), and filtering on our code prefix, the biggest chunk both in total size and number of instances is...
Dump the heap and inspect it. I'm sure there's more than one way to do this, but here is a simple one. This description is for MS Windows, but similar steps can be taken on other operating systems. 1. Install the JDK if you don't already have it. [It comes with a bunch of neat tools.](http://java.sun.com/javase/6/doc...
154,332
<p>I'm using <strong>mysqldump</strong> to replicate a database between accounts on a particular machine. Everything works just great, except when we get to our defined views. Because the dump includes a line like the following ...</p> <pre><code>/*!50013 DEFINER=`user_a`@`localhost` SQL SECURITY DEFINER */ </code><...
[ { "answer_id": 154574, "author": "Max Stewart", "author_id": 18338, "author_profile": "https://Stackoverflow.com/users/18338", "pm_score": 2, "selected": false, "text": "<p>The SQL SECURITY clauses determine which MySQL account to use when checking access privileges for the view (as you ...
2008/09/30
[ "https://Stackoverflow.com/questions/154332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21632/" ]
I'm using **mysqldump** to replicate a database between accounts on a particular machine. Everything works just great, except when we get to our defined views. Because the dump includes a line like the following ... ``` /*!50013 DEFINER=`user_a`@`localhost` SQL SECURITY DEFINER */ ``` ... when loading the dump into ...
same problem. I solved it that way: ``` mysqldump -uuser1 -ppassword1 database1 > backup.sql sed '/^\/\*\!50013 DEFINER/d' backup.sql > backup_without_50013.sql mysql -u user2 -ppassword2 -D database2 < backup_without_50013.sql ``` The interesting thing is the [sed](http://soft.zoneo.net/Linux/remove_comment_lines...
154,372
<p>How do I get a list of all the tables defined for the database when using active record?</p>
[ { "answer_id": 154449, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 0, "selected": false, "text": "<p>Don't know about active record, but here's a simple query:</p>\n\n<p>select table_name \nfrom INFORMATION_SCHEMA.Tables \nw...
2008/09/30
[ "https://Stackoverflow.com/questions/154372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3547/" ]
How do I get a list of all the tables defined for the database when using active record?
Call [`ActiveRecord::ConnectionAdapters::SchemaStatements#tables`](http://github.com/rails/rails/tree/master/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb#L21). This method is undocumented in the MySQL adapter, but is documented in the PostgreSQL adapter. SQLite/SQLite3 also has the m...
154,387
<p>I'm trying to get something very subtle to work, it looks pretty awful right now. I'm trying to paint the background of a TGroupBox which I have overloaded the paint function of so that the corners are show through to their parent object. I've got a bunch of nested group boxes that look very decent without XPThemes...
[ { "answer_id": 154470, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 2, "selected": true, "text": "<p>I'm trying to duplicate this problem with the following steps:</p>\n\n<p>1 - Set theme to Windows XP default</p>\n\n<p>...
2008/09/30
[ "https://Stackoverflow.com/questions/154387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1765/" ]
I'm trying to get something very subtle to work, it looks pretty awful right now. I'm trying to paint the background of a TGroupBox which I have overloaded the paint function of so that the corners are show through to their parent object. I've got a bunch of nested group boxes that look very decent without XPThemes. ...
I'm trying to duplicate this problem with the following steps: 1 - Set theme to Windows XP default 2 - Drop a TGroupBox on an empty form (align = alNone) 3 - Drop two TGroupBoxes inside the first one, with align = alBottom and align = alClient But visually it looks just fine for me. Can you provide some more info ...
154,411
<p>I am having trouble getting Team Build to execute my MbUnit unit tests. I have tried to edit TFSBuild.proj and added the following parts:</p> <pre><code>&lt;Project ...&gt; &lt;UsingTask TaskName="MbUnit.MSBuild.Tasks.MbUnit" AssemblyFile="path_to_MbUnit.MSBuild.Tasks.dll" /&gt; ... ... &lt;ItemGroup&gt; ...
[ { "answer_id": 154807, "author": "Martin Woodward", "author_id": 6438, "author_profile": "https://Stackoverflow.com/users/6438", "pm_score": 0, "selected": false, "text": "<p>The way ItemGroups in MSBuild work is that they are evaluated at the very start of the MSBuild scripts, before an...
2008/09/30
[ "https://Stackoverflow.com/questions/154411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4582/" ]
I am having trouble getting Team Build to execute my MbUnit unit tests. I have tried to edit TFSBuild.proj and added the following parts: ``` <Project ...> <UsingTask TaskName="MbUnit.MSBuild.Tasks.MbUnit" AssemblyFile="path_to_MbUnit.MSBuild.Tasks.dll" /> ... ... <ItemGroup> <TestAssemblies Include="$(Out...
Above suggestion didn't help me a lot, but I found some documentation for Team Build and adjusted my build script to override the AfterCompile target: *(EDIT: Now that I have a better understanding of Team Build, I have added some more to the test runner. It will now update the Build Explorer/Build monitor with build ...
154,427
<p>What's the object type returned by Datepicker? Supposing I have the following:</p> <pre><code>$("#txtbox").datepicker({ onClose: function(date){ //something } }); </code></pre> <p>What is <code>date</code>? I'm interested in reading the date object from another Datepicker for comparison, someth...
[ { "answer_id": 154448, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": -1, "selected": false, "text": "<blockquote>\n <p>What is date?</p>\n</blockquote>\n\n<p>it's the $(\"#txtbox\") object</p>\n" }, { "answer_id": ...
2008/09/30
[ "https://Stackoverflow.com/questions/154427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024/" ]
What's the object type returned by Datepicker? Supposing I have the following: ``` $("#txtbox").datepicker({ onClose: function(date){ //something } }); ``` What is `date`? I'm interested in reading the date object from another Datepicker for comparison, something like: ``` function(date){ ...
I just downloaded the source from [here](http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/scripts/jquery.datePicker.js) and noticed (ex line 600) the author is using .getTime() to compare dates, have you tried that? ``` if (oDate.getTime() > date.getTime()) { ... } ``` Also this is tangential but you m...
154,430
<p>I need to store encrypted data (few small strings) between application runs. I do not want the user to provide a passphrase every time (s)he launches the application. I.e. after all it goes down to storing securely the encryption key(s).</p> <p>I was looking into RSACryptoServiceProvider and using PersistentKeyInCs...
[ { "answer_id": 154687, "author": "Michael Petrotta", "author_id": 23897, "author_profile": "https://Stackoverflow.com/users/23897", "pm_score": 6, "selected": true, "text": "<p>The Data Protection API (DPAPI) does exactly what you want. It provides symmetric encryption of arbitrary data...
2008/09/30
[ "https://Stackoverflow.com/questions/154430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8220/" ]
I need to store encrypted data (few small strings) between application runs. I do not want the user to provide a passphrase every time (s)he launches the application. I.e. after all it goes down to storing securely the encryption key(s). I was looking into RSACryptoServiceProvider and using PersistentKeyInCsp, but I'm...
The Data Protection API (DPAPI) does exactly what you want. It provides symmetric encryption of arbitrary data, using the credentials of the machine or (better) the user, as the encryption key. You don't have to worry about managing the keys; Windows takes care of that for you. If the user changes his password, Windows...
154,434
<p>How do you get spreadsheet data in Excel to recalculate itself from within VBA, without the kluge of just changing a cell value?</p>
[ { "answer_id": 154439, "author": "Lance Roberts", "author_id": 13295, "author_profile": "https://Stackoverflow.com/users/13295", "pm_score": 7, "selected": true, "text": "<p>The following lines will do the trick:</p>\n\n<pre><code>ActiveSheet.EnableCalculation = False \nActiveSheet.Enab...
2008/09/30
[ "https://Stackoverflow.com/questions/154434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13295/" ]
How do you get spreadsheet data in Excel to recalculate itself from within VBA, without the kluge of just changing a cell value?
The following lines will do the trick: ``` ActiveSheet.EnableCalculation = False ActiveSheet.EnableCalculation = True ``` **Edit:** The `.Calculate()` method will not work for all functions. I tested it on a sheet with add-in array functions. The production sheet I'm using is complex enough that I don't want to ...
154,441
<p>I need to test some HTTP interaction with a client I'd rather not modify. What I need to test is the behavior of the server when the client's requests include a certain, static header.</p> <p>I'm thinking the easiest way to run this test is to set up an HTTP proxy that inserts the header on every request. What woul...
[ { "answer_id": 154475, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 2, "selected": false, "text": "<p>i'd try <a href=\"http://www.banu.com/tinyproxy/\" rel=\"nofollow noreferrer\">tinyproxy</a>. in fact, the vey best woul...
2008/09/30
[ "https://Stackoverflow.com/questions/154441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3518/" ]
I need to test some HTTP interaction with a client I'd rather not modify. What I need to test is the behavior of the server when the client's requests include a certain, static header. I'm thinking the easiest way to run this test is to set up an HTTP proxy that inserts the header on every request. What would be the s...
I do something like this in my development environment by configuring Apache on port 80 as a proxy for my application server on port 8080, with the following Apache config: ``` NameVirtualHost * <VirtualHost *> <Proxy http://127.0.0.1:8080/*> Allow from all </Proxy> <LocationMatch "/myapp"> ProxyP...
154,446
<p>I am trying to save data to a database on a button push, but the variables seem to be private by the nature of where they are defined. I have tried to move where they are defined, but this seems to produce other errors.</p> <p>Given a fix, why was it fixed that way?</p> <p>The code follows.</p> <pre><code>namespa...
[ { "answer_id": 154458, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 0, "selected": false, "text": "<p>Update: [sigh] I forgot to move dTable to the class cope as well...</p>\n\n<pre><code>namespace enable\n{ \n ...
2008/09/30
[ "https://Stackoverflow.com/questions/154446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19802/" ]
I am trying to save data to a database on a button push, but the variables seem to be private by the nature of where they are defined. I have tried to move where they are defined, but this seems to produce other errors. Given a fix, why was it fixed that way? The code follows. ``` namespace enable { public parti...
You're declaring `dTable` and `adapter` in the constructor, so it goes out of scope as soon as the constructor is completed. You want to move the variable declarations out into the main class, like: ``` public partial class Form1 : Form { private DataTable dTable; private OleDbDataAdapter adapter; Public...
154,463
<p>I'm using SharpZipLib version 0.85.5 to unzip files. My code has been working nicely for a couple of months until I found a ZIP file that it doesn't like.</p> <pre><code>ICSharpCode.SharpZipLib.Zip.ZipException: End of extra data at ICSharpCode.SharpZipLib.Zip.ZipExtraData.ReadCheck(Int32 length) in C:\C#\...
[ { "answer_id": 154545, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>It's possible that the other zip tools are ignoring extra data which is corrupt - or it's equally possible that there...
2008/09/30
[ "https://Stackoverflow.com/questions/154463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]
I'm using SharpZipLib version 0.85.5 to unzip files. My code has been working nicely for a couple of months until I found a ZIP file that it doesn't like. ``` ICSharpCode.SharpZipLib.Zip.ZipException: End of extra data at ICSharpCode.SharpZipLib.Zip.ZipExtraData.ReadCheck(Int32 length) in C:\C#\SharpZLib\Zip\...
It's possible that the other zip tools are ignoring extra data which is corrupt - or it's equally possible that there's a bug in #ZipLib. (I found one a while ago - a certain file that wouldn't compress and then decompress cleanly with certain options.) In this particular case, I suggest you post on the #ZipLib forum ...
154,469
<p>A feature of C++ is the ability to create unnamed (anonymous) namespaces, like so:</p> <pre><code>namespace { int cannotAccessOutsideThisFile() { ... } } // namespace </code></pre> <p>You would think that such a feature would be useless -- since you can't specify the name of the namespace, it's impossible to a...
[ { "answer_id": 154482, "author": "luke", "author_id": 16434, "author_profile": "https://Stackoverflow.com/users/16434", "pm_score": 10, "selected": true, "text": "<p><s>The C++ Standard reads in section 7.3.1.1 Unnamed namespaces, paragraph 2:</s>\n<s></p>\n<blockquote>\n<p>The use of th...
2008/09/30
[ "https://Stackoverflow.com/questions/154469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12193/" ]
A feature of C++ is the ability to create unnamed (anonymous) namespaces, like so: ``` namespace { int cannotAccessOutsideThisFile() { ... } } // namespace ``` You would think that such a feature would be useless -- since you can't specify the name of the namespace, it's impossible to access anything within it f...
~~The C++ Standard reads in section 7.3.1.1 Unnamed namespaces, paragraph 2:~~ > > The use of the static keyword is > deprecated when declaring objects in a > namespace scope, the unnamed-namespace > provides a superior alternative. > > > > Static only applies to names of objects, functions, and anonymous unions...
154,483
<p>I would like to do some condition formatting of strings. I know that you can do some conditional formatting of integers and floats as follows:</p> <pre><code>Int32 i = 0; i.ToString("$#,##0.00;($#,##0.00);Zero"); </code></pre> <p>The above code would result in one of three formats if the variable is positive, neg...
[ { "answer_id": 154487, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 1, "selected": false, "text": "<p>This is probably not what you're looking for, but how about...</p>\n\n<pre><code>formatString = (items.Count &gt; 0) ? \"It...
2008/09/30
[ "https://Stackoverflow.com/questions/154483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4066/" ]
I would like to do some condition formatting of strings. I know that you can do some conditional formatting of integers and floats as follows: ``` Int32 i = 0; i.ToString("$#,##0.00;($#,##0.00);Zero"); ``` The above code would result in one of three formats if the variable is positive, negative, or zero. I would li...
Well, you can simplify it a bit with the conditional operator: ``` string formatString = items.Count > 0 ? "Items: {0}; Values: {1}" : "Values: {1}"; return string.Format(formatString, itemList, valueList); ``` Or even include it in the same statement: ``` return string.Format(items.Count > 0 ? "Items: {0}; Values:...
154,489
<p>I've been trying this a few different ways, but I'm reaching the conclusion that it can't be done. It's a language feature I've enjoyed from other languages in the past. Is it just something I should just write off?</p>
[ { "answer_id": 154524, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>No, static indexers aren't supported in C#. Unlike other answers, however, I see how there could easily be point in ha...
2008/09/30
[ "https://Stackoverflow.com/questions/154489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
I've been trying this a few different ways, but I'm reaching the conclusion that it can't be done. It's a language feature I've enjoyed from other languages in the past. Is it just something I should just write off?
No, static indexers aren't supported in C#. Unlike other answers, however, I see how there could easily be point in having them. Consider: ``` Encoding x = Encoding[28591]; // Equivalent to Encoding.GetEncoding(28591) Encoding y = Encoding["Foo"]; // Equivalent to Encoding.GetEncoding("Foo") ``` It would be relative...
154,533
<p>What is the best way to bind WPF properties to ApplicationSettings in C#? Is there an automatic way like in a Windows Forms Application? Similar to <a href="https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c">this question</a>, how (and is it possible to)...
[ { "answer_id": 155585, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 2, "selected": false, "text": "<p>Kris, I'm not sure this is the best way to bind ApplicationSettings, but this is how I did it in <a href=\"http://code.go...
2008/09/30
[ "https://Stackoverflow.com/questions/154533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
What is the best way to bind WPF properties to ApplicationSettings in C#? Is there an automatic way like in a Windows Forms Application? Similar to [this question](https://stackoverflow.com/questions/18421/best-way-to-bind-windows-forms-properties-to-applicationsettings-in-c), how (and is it possible to) do you do the ...
You can directly bind to the static object created by Visual Studio. In your windows declaration add: ``` xmlns:p="clr-namespace:UserSettings.Properties" ``` where `UserSettings` is the application namespace. Then you can add a binding to the correct setting: ``` <TextBlock Height="{Binding Source={x:Static p:Set...
154,535
<p>I have used Photoshop CS2's "Save for Web" feature to create a table of images for my site layout.</p> <p>This HTML appears fine in a web browser, however when imported into Visual Studio and viewed in the site designer, the metrics are wrong and there are horizontal gaps between images (table cells).</p> <p>The o...
[ { "answer_id": 155585, "author": "Alan Le", "author_id": 1133, "author_profile": "https://Stackoverflow.com/users/1133", "pm_score": 2, "selected": false, "text": "<p>Kris, I'm not sure this is the best way to bind ApplicationSettings, but this is how I did it in <a href=\"http://code.go...
2008/09/30
[ "https://Stackoverflow.com/questions/154535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/414107/" ]
I have used Photoshop CS2's "Save for Web" feature to create a table of images for my site layout. This HTML appears fine in a web browser, however when imported into Visual Studio and viewed in the site designer, the metrics are wrong and there are horizontal gaps between images (table cells). The output from Photos...
You can directly bind to the static object created by Visual Studio. In your windows declaration add: ``` xmlns:p="clr-namespace:UserSettings.Properties" ``` where `UserSettings` is the application namespace. Then you can add a binding to the correct setting: ``` <TextBlock Height="{Binding Source={x:Static p:Set...
154,536
<p>Does anyone know of any good C++ code that does this?</p>
[ { "answer_id": 154564, "author": "alanc10n", "author_id": 14059, "author_profile": "https://Stackoverflow.com/users/14059", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://www.gnu.org/software/cgicc/\" rel=\"noreferrer\">CGICC</a> includes methods to do url encode and deco...
2008/09/30
[ "https://Stackoverflow.com/questions/154536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2033811/" ]
Does anyone know of any good C++ code that does this?
I faced the encoding half of this problem the other day. Unhappy with the available options, and after taking a look at [this C sample code](http://www.geekhideout.com/urlcode.shtml), i decided to roll my own C++ url-encode function: ``` #include <cctype> #include <iomanip> #include <sstream> #include <string> using ...
154,538
<p>Long story short, I need to put some text in my Flex application and I don't want users to be able to copy. I was going to use a label, but apparently labels do not support text wrapping. Can I make it so that users cannot select text in a Flex Text control?</p> <p>Thanks.</p>
[ { "answer_id": 154848, "author": "Brandon", "author_id": 23133, "author_profile": "https://Stackoverflow.com/users/23133", "pm_score": 0, "selected": false, "text": "<p>You can set the enabled property to \"false\" which disables user interaction. You may want to also change the disabled...
2008/09/30
[ "https://Stackoverflow.com/questions/154538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
Long story short, I need to put some text in my Flex application and I don't want users to be able to copy. I was going to use a label, but apparently labels do not support text wrapping. Can I make it so that users cannot select text in a Flex Text control? Thanks.
You could use the Text control and set the selectable property to false... ``` <mx:Text width="175" selectable="false" text="This is an example of a multiline text string in a Text control." /> ```
154,554
<p>I'm writing a simple web service using Microsoft Visual Web Developer 2005 (Express Edition), and the dynamically generated WSDL has a minOccurs="0" for all the parameters. </p> <p>How do I get minOccurs="1" for the required parameters without resorting to creating a static WSDL file?</p> <p>I need to do this <str...
[ { "answer_id": 154650, "author": "Jack B Nimble", "author_id": 3800, "author_profile": "https://Stackoverflow.com/users/3800", "pm_score": 1, "selected": false, "text": "<p>from an msdn forum \n\"If you are creating a new web service, I highly recommend building the web service using the...
2008/09/30
[ "https://Stackoverflow.com/questions/154554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23899/" ]
I'm writing a simple web service using Microsoft Visual Web Developer 2005 (Express Edition), and the dynamically generated WSDL has a minOccurs="0" for all the parameters. How do I get minOccurs="1" for the required parameters without resorting to creating a static WSDL file? I need to do this **using a ASP.NET Web...
I think that the `XmlElement(IsNullable = true)` attribute will do the job: ``` using System.Xml.Serialization; [WebMethod] public string MyService([XmlElement(IsNullable = true)] string arg) { return "1"; } ```
154,577
<p>In terms of Java, when someone asks: </p> <blockquote> <p>what is polymorphism?</p> </blockquote> <p>Would <strong>overloading</strong> or <strong>overriding</strong> be an acceptable answer?</p> <p>I think there is a bit more to it than that. </p> <p><em>IF you had a abstract base class that defined a method ...
[ { "answer_id": 154594, "author": "Clyde", "author_id": 945, "author_profile": "https://Stackoverflow.com/users/945", "pm_score": 2, "selected": false, "text": "<p>The term overloading refers to having multiple versions of something with the same name, usually methods with different param...
2008/09/30
[ "https://Stackoverflow.com/questions/154577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
In terms of Java, when someone asks: > > what is polymorphism? > > > Would **overloading** or **overriding** be an acceptable answer? I think there is a bit more to it than that. *IF you had a abstract base class that defined a method with no implementation, and you defined that method in the sub class, is th...
The clearest way to express polymorphism is via an abstract base class (or interface) ``` public abstract class Human{ ... public abstract void goPee(); } ``` This class is abstract because the `goPee()` method is not definable for Humans. It is only definable for the subclasses Male and Female. Also, Human is...