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
447,781
<p>I am currently playing with Qt trying to set up a small particle system. Therein I've subclassed the GLWidget and hacked away at it. Everything was going well until I made some unknown change and now the widget only repaints when I move the mouse (it should be doing it all the time due to the QTimer I have firing)...
[ { "answer_id": 521628, "author": "NicJ", "author_id": 43815, "author_profile": "https://Stackoverflow.com/users/43815", "pm_score": 3, "selected": false, "text": "<p>Please see <a href=\"https://stackoverflow.com/questions/497945/using-schtasks-from-the-command-line-what-parameter-will-w...
2009/01/15
[ "https://Stackoverflow.com/questions/447781", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22780/" ]
I am currently playing with Qt trying to set up a small particle system. Therein I've subclassed the GLWidget and hacked away at it. Everything was going well until I made some unknown change and now the widget only repaints when I move the mouse (it should be doing it all the time due to the QTimer I have firing). Rel...
I recently came across the same issue. The way I resolved it was to add the /V1 switch to the schtasks command. /V1 creates a pre-vista compatible scheduled task and automatically populates the Start In directory.
447,783
<p>I've never been much for math and I'm hoping that someone can help me out with the following.</p> <p>I have 5 boxes: </p> <pre><code> 1 2 3 4 5 [ ] [ ] [ ] [ ] [ ] </code></pre> <p>The boxes can either be white, gray, or black (or think of it as 0, 1, 2)</p> <p>How many possible states can the box set be...
[ { "answer_id": 447798, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 0, "selected": false, "text": "<p>The number of possibilities is 3 to the power 5</p>\n\n<p>If you loop from 0 to that number minus 1 and express it...
2009/01/15
[ "https://Stackoverflow.com/questions/447783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36263/" ]
I've never been much for math and I'm hoping that someone can help me out with the following. I have 5 boxes: ``` 1 2 3 4 5 [ ] [ ] [ ] [ ] [ ] ``` The boxes can either be white, gray, or black (or think of it as 0, 1, 2) How many possible states can the box set be in? What is the pseudocode (or in any ...
This is a classic permutation generation problem. You have 3 possibilities for each position, and 5 positions. The total number of generated string is 3^5 = 243. You need recursion if you want a general solution (a simple iterative loop only works for a single instance of the problem). Here's a quick example: ``` pub...
447,785
<p>You'll have to pardon me as I wasn't sure where to place this. This overlaps in the areas of C# Web Services and Network/Security management I suppose.</p> <p>I have a server that runs various web applications. One of them is a web service. The account everything runs under is a local account on the machine. It is ...
[ { "answer_id": 447798, "author": "DanSingerman", "author_id": 43965, "author_profile": "https://Stackoverflow.com/users/43965", "pm_score": 0, "selected": false, "text": "<p>The number of possibilities is 3 to the power 5</p>\n\n<p>If you loop from 0 to that number minus 1 and express it...
2009/01/15
[ "https://Stackoverflow.com/questions/447785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50947/" ]
You'll have to pardon me as I wasn't sure where to place this. This overlaps in the areas of C# Web Services and Network/Security management I suppose. I have a server that runs various web applications. One of them is a web service. The account everything runs under is a local account on the machine. It is not a doma...
This is a classic permutation generation problem. You have 3 possibilities for each position, and 5 positions. The total number of generated string is 3^5 = 243. You need recursion if you want a general solution (a simple iterative loop only works for a single instance of the problem). Here's a quick example: ``` pub...
447,821
<p>Basic premise:</p> <p>I have a Room which publishes an event when an Avatar "enters" to all Avatars within the Room. When an Avatar leaves the Room I want it to remove all subscriptions for that room.</p> <p>How can I best unsubscribe the Avatar from all events in the room before I add the Avatar to a new Room an...
[ { "answer_id": 447827, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 2, "selected": false, "text": "<p>Is there anything wrong with a standard remove?</p>\n\n<pre><code>public void RemovePlayer(Avatar theAvatar) {\n Avata...
2009/01/15
[ "https://Stackoverflow.com/questions/447821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4998/" ]
Basic premise: I have a Room which publishes an event when an Avatar "enters" to all Avatars within the Room. When an Avatar leaves the Room I want it to remove all subscriptions for that room. How can I best unsubscribe the Avatar from all events in the room before I add the Avatar to a new Room and subscribe to the...
Each delegate has a method named `GetInvocationList()` that returns all the actual delegates that have been registered. So, assuming the delegate Type (or event) is named say `MyDelegate`, and the handler instance variable is named `myDlgHandler`, you can write: ``` Delegate[] clientList = myDlgHandler.GetInvocationLi...
447,862
<p>I'm using the Dialog editor in Visual Studio 2005 to create a Dialog box with a static text control. I'd like the background of the static text control to be transparent since I'm using an static image control underneath it and the grey text background looks hideous. In the editor, I set the "Transparent" attribut...
[ { "answer_id": 448092, "author": "Nick", "author_id": 1490, "author_profile": "https://Stackoverflow.com/users/1490", "pm_score": 1, "selected": false, "text": "<p>Try hiding the control, then setting the text, then showing it.</p>\n" }, { "answer_id": 448237, "author": "Anth...
2009/01/15
[ "https://Stackoverflow.com/questions/447862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191808/" ]
I'm using the Dialog editor in Visual Studio 2005 to create a Dialog box with a static text control. I'd like the background of the static text control to be transparent since I'm using an static image control underneath it and the grey text background looks hideous. In the editor, I set the "Transparent" attribute to ...
As Anthony Johnson said, handle the `WM_CTLCOLORSTATIC` message in the dialog box (you don't have to handle `WM_NOTIFY` - I don't believe static controls use that message, anyway). But it doesn't seem to be enough to set the background mode to transparent. You also have to set the background brush to a null brush. Some...
447,875
<p>I think this must be a stupid question, but why do the results of urlsafe_b64encode() always end with a '=' for me? '=' isn't url safe?</p> <pre><code>from random import getrandbits from base64 import urlsafe_b64encode from hashlib import sha256 from time import sleep def genKey(): keyLenBits = 64 a = str(ge...
[ { "answer_id": 447925, "author": "schnaader", "author_id": 34065, "author_profile": "https://Stackoverflow.com/users/34065", "pm_score": 4, "selected": true, "text": "<p><a href=\"http://en.wikipedia.org/wiki/Base64\" rel=\"noreferrer\">Base64</a> uses '=' for padding. Your string bit le...
2009/01/15
[ "https://Stackoverflow.com/questions/447875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23402/" ]
I think this must be a stupid question, but why do the results of urlsafe\_b64encode() always end with a '=' for me? '=' isn't url safe? ``` from random import getrandbits from base64 import urlsafe_b64encode from hashlib import sha256 from time import sleep def genKey(): keyLenBits = 64 a = str(getrandbits(key...
[Base64](http://en.wikipedia.org/wiki/Base64) uses '=' for padding. Your string bit length isn't divisible by 24, so it's padded with '='. By the way, '=' should be URL safe as it's often used for parameters in URLs. See [this discussion](http://mail.python.org/pipermail/python-bugs-list/2007-February/037195.html), to...
447,885
<p>I'm trying to get this Javascript to work properly. My intention is, when a user is trying to close the site page to get an alert saying "stay on current page or close" If they hit 'ok' I want it to close, if they hit 'cancel' i want it to redirect to another page. The problem is, when they try to go to another page...
[ { "answer_id": 447911, "author": "Moran Helman", "author_id": 1409636, "author_profile": "https://Stackoverflow.com/users/1409636", "pm_score": 0, "selected": false, "text": "<p>you should use the window onbeforeunload Event.</p>\n\n<p><a href=\"http://msdn.microsoft.com/en-us/library/ms...
2009/01/15
[ "https://Stackoverflow.com/questions/447885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to get this Javascript to work properly. My intention is, when a user is trying to close the site page to get an alert saying "stay on current page or close" If they hit 'ok' I want it to close, if they hit 'cancel' i want it to redirect to another page. The problem is, when they try to go to another page on...
> > The problem is, when they try to go to another page on the same site, it gives them that popup. I want it to show only when closing > > > 1. Don't do this. 2. You can't detect closing only, but you can tell the difference between leaving by clicking on an internal link and other kinds of leaving, including ext...
447,941
<p>I have become accustomed to using <kbd>F6</kbd> to compile the current document. A third-party install appears to have turned this function off. (<kbd>F6</kbd> no longer does anything.)</p> <p>Can anyone tell me how to get it back?</p> <p>I'm using VS2008</p>
[ { "answer_id": 447953, "author": "Andrew Hare", "author_id": 34211, "author_profile": "https://Stackoverflow.com/users/34211", "pm_score": 5, "selected": true, "text": "<pre><code>Tools &gt; Options &gt; Keybord\n</code></pre>\n\n<p>This dialog lets you bind keyboard shortcuts to your he...
2009/01/15
[ "https://Stackoverflow.com/questions/447941", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55520/" ]
I have become accustomed to using `F6` to compile the current document. A third-party install appears to have turned this function off. (`F6` no longer does anything.) Can anyone tell me how to get it back? I'm using VS2008
``` Tools > Options > Keybord ``` This dialog lets you bind keyboard shortcuts to your heart's content. BTW this is how you bind keyboard shortcuts to custom IDE macros as well.
447,943
<p>I want to write a regex that matches if a string contains XYZ but doesn't contain ABC somewhere before it. So "blah XYZ blah" should match, but "blah ABC blah XYZ blah " should not.</p> <p>Any ideas? In particular I'm writing the regex in c#, in case there's anything specific to that syntax.</p> <p>I guess I can u...
[ { "answer_id": 447951, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 2, "selected": false, "text": "<p>is there anything wrong with</p>\n\n<pre><code> string.Contains(\"XYZ\") &amp;&amp; !string.contains(\"ABC\") \n</code></pr...
2009/01/15
[ "https://Stackoverflow.com/questions/447943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8479/" ]
I want to write a regex that matches if a string contains XYZ but doesn't contain ABC somewhere before it. So "blah XYZ blah" should match, but "blah ABC blah XYZ blah " should not. Any ideas? In particular I'm writing the regex in c#, in case there's anything specific to that syntax. I guess I can use negative lookb...
No need for lookbehind: ``` ^(?:(?!ABC).)*XYZ ```
447,944
<p>Is it possible to determine the type of a local variable at runtime in TSQL?</p> <p>For example, say I wanted to do something along these lines:</p> <pre><code>IF ( @value IS INTEGER ) </code></pre> <p>Or</p> <pre><code>IF ( TYPEOF(@value) = &lt;whatever&gt; ) </code></pre> <p>Does anyone know of any way to acc...
[ { "answer_id": 447970, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": -1, "selected": false, "text": "<p>I don't think so - BUT it is a local variable so are declaring it in the same procedure so you would know the type anyways...
2009/01/15
[ "https://Stackoverflow.com/questions/447944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22670/" ]
Is it possible to determine the type of a local variable at runtime in TSQL? For example, say I wanted to do something along these lines: ``` IF ( @value IS INTEGER ) ``` Or ``` IF ( TYPEOF(@value) = <whatever> ) ``` Does anyone know of any way to accomplish this? EDIT: This is not for a specific task, this is ...
run this ``` declare @d int select @d = 500 if cast(sql_variant_property(@d,'BaseType') as varchar(20)) = 'int' print 'yes' else print 'no' ```
447,947
<p>Is type checking considered bad practice even if you are checking against an interface? I understand that you should always program to an interface and not an implementation - is this what it means?</p> <p>For example, in PHP, is the following OK?</p> <pre><code>if($class instanceof AnInterface) { // Do some co...
[ { "answer_id": 447997, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 1, "selected": false, "text": "<p>If you can avoid type checking you should; however, one scenario where I found it handy, was we had a web service whi...
2009/01/15
[ "https://Stackoverflow.com/questions/447947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55549/" ]
Is type checking considered bad practice even if you are checking against an interface? I understand that you should always program to an interface and not an implementation - is this what it means? For example, in PHP, is the following OK? ``` if($class instanceof AnInterface) { // Do some code } ``` Or is ther...
As long as you follow the [LSP](http://en.wikipedia.org/wiki/Liskov_substitution_principle), I don't see a problem. Your code must work with *any* implementation of the interface. It's not a problem that certain implementations cause you to follow different code paths, as long as you can correctly work with *any* imple...
447,968
<p><strong>UPDATE - 1/21/09:</strong> </p> <p>The only way I've been able to get this working moderately well is to create routes that have additional path info... in other words instead of <strong><a href="http://company.com/myDepartment/myTeam/action/id" rel="nofollow noreferrer">http://company.com/myDepartment/myT...
[ { "answer_id": 449143, "author": "Jero", "author_id": 55675, "author_profile": "https://Stackoverflow.com/users/55675", "pm_score": 2, "selected": false, "text": "<p>First off, you don't need departmentAndTeam2 or departmentAndTeam3. departmentAndTeam1 can handle it because it has the de...
2009/01/15
[ "https://Stackoverflow.com/questions/447968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18269/" ]
**UPDATE - 1/21/09:** The only way I've been able to get this working moderately well is to create routes that have additional path info... in other words instead of **<http://company.com/myDepartment/myTeam/action/id>**, the routes need to be built to handle paths like **<http://company.com/department/myDepartment/...
First off, you don't need departmentAndTeam2 or departmentAndTeam3. departmentAndTeam1 can handle it because it has the defaults for controller, action and id. Another thing I notice is that none of your example URLs have the controller specified in them. In that case, leave it out of the route and just leave it as th...
447,985
<p>In <a href="https://stackoverflow.com/questions/392657/md5-hashing-in-delphi-2009">this question</a> is mentioned the wcrypt2.</p> <p>What I need is simply calculate the MD5 of a file. It would be perfect if I could calculate it without having to save it because it is a downloaded file in stream format.</p> <p>I w...
[ { "answer_id": 448176, "author": "dummzeuch", "author_id": 49925, "author_profile": "https://Stackoverflow.com/users/49925", "pm_score": 2, "selected": false, "text": "<p>Indy comes with functions for calculating several hashes, MD5 is one of them. Indy is included in all versions of Del...
2009/01/15
[ "https://Stackoverflow.com/questions/447985", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19224/" ]
In [this question](https://stackoverflow.com/questions/392657/md5-hashing-in-delphi-2009) is mentioned the wcrypt2. What I need is simply calculate the MD5 of a file. It would be perfect if I could calculate it without having to save it because it is a downloaded file in stream format. I would like to have the most s...
Here is a working code for Indy 10: ``` function MD5File(const FileName: string): string; var IdMD5: TIdHashMessageDigest5; FS: TFileStream; begin IdMD5 := TIdHashMessageDigest5.Create; FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); try Result := IdMD5.HashStreamAsHex(FS) finally FS....
447,995
<p>I have a big <code>SELECT</code> statement which has many nested selects in it. When I run it, it gives me an <code>ORA-22813</code> error:</p> <blockquote> <p>Ora-22813:- The Collection value from one of the inner sub queries has exceeded the system limits and hence this error.</p> </blockquote> <p>I have given...
[ { "answer_id": 448090, "author": "Tracker1", "author_id": 43906, "author_profile": "https://Stackoverflow.com/users/43906", "pm_score": 0, "selected": false, "text": "<p>How many rows of data are you looking at? there are times when separate queries with programmatic aggregation can wor...
2009/01/15
[ "https://Stackoverflow.com/questions/447995", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a big `SELECT` statement which has many nested selects in it. When I run it, it gives me an `ORA-22813` error: > > Ora-22813:- The Collection value from one of the inner sub queries has exceeded the system limits and hence this error. > > > I have given below some of the nested `select`s which return huge ...
Please post the DDLs, approximate sizes (relative to each other), and the complete query, rather than just an excerpt. Some quick hits that may or may not solve your problem (for better help, I need better information) -- * Are you sure you mean OUTER join? Outer joining students to courses means students who are no...
448,002
<p>First off, according to <a href="http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx</a>, the List.Find method is only listed as throwing ArgumentNullException. However I have the following test code which, when using Find with an an...
[ { "answer_id": 448027, "author": "samael", "author_id": 48527, "author_profile": "https://Stackoverflow.com/users/48527", "pm_score": 6, "selected": true, "text": "<p><code>Find</code> <strong>is</strong> returning null. But then you are dereferencing that result. That is, you're invok...
2009/01/15
[ "https://Stackoverflow.com/questions/448002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13140/" ]
First off, according to <http://msdn.microsoft.com/en-us/library/x0b5b5bc.aspx>, the List.Find method is only listed as throwing ArgumentNullException. However I have the following test code which, when using Find with an anonymous delegate, throws a NullReferenceException when the object being searched for is not foun...
`Find` **is** returning null. But then you are dereferencing that result. That is, you're invoking: `Find(...).value`
448,005
<p>What's an easy way to read random line from a file in a shell script?</p>
[ { "answer_id": 448019, "author": "Tracker1", "author_id": 43906, "author_profile": "https://Stackoverflow.com/users/43906", "pm_score": 4, "selected": false, "text": "<p><a href=\"http://perldoc.perl.org/perlfaq5.html#How-do-I-select-a-random-line-from-a-file%3f\" rel=\"noreferrer\">perl...
2009/01/15
[ "https://Stackoverflow.com/questions/448005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What's an easy way to read random line from a file in a shell script?
You can use `shuf`: ``` shuf -n 1 $FILE ``` There is also a utility called `rl`. In Debian it's in the `randomize-lines` package that does exactly what you want, though not available in all distros. On its home page it actually recommends the use of `shuf` instead (which didn't exist when it was created, I believe)....
448,009
<p>I'm trying to build a makefile and after about 5 seconds, I get this error: "No files names given". what does it mean and how do I fix it?</p> <pre><code>[exec] Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland [exec] Error E2266: No file names given [exec] ** error 1 ** deleting paslib.lib </code></pre...
[ { "answer_id": 448151, "author": "Brian Clapper", "author_id": 53495, "author_profile": "https://Stackoverflow.com/users/53495", "pm_score": 1, "selected": false, "text": "<p>Looks like you're calling the Borland C++ compiler command without passing it any file names to compile. Perhaps ...
2009/01/15
[ "https://Stackoverflow.com/questions/448009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/54790/" ]
I'm trying to build a makefile and after about 5 seconds, I get this error: "No files names given". what does it mean and how do I fix it? ``` [exec] Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland [exec] Error E2266: No file names given [exec] ** error 1 ** deleting paslib.lib ``` This is being run fro...
Turns out that the actual problem is with bcc32.exe, not make. The problem is discussed here: [Why can't the Borland C++ Builder 5 command line compiler find my files?](https://stackoverflow.com/questions/489308/why-cant-the-borland-c-builder-5-command-line-compiler-find-my-files)
448,015
<p>I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's say, 100 pixels sitting on the uppermost part of the div. When the user clicks a certain button, the div will open (it could be a sliding effect like jQuery's show()). When the user clicks back the same button, the div w...
[ { "answer_id": 448028, "author": "zappan", "author_id": 4723, "author_profile": "https://Stackoverflow.com/users/4723", "pm_score": 3, "selected": false, "text": "<p>it could be done by setting div's initial height to 100px and setting its overflow to hidden in CSS. then you can change d...
2009/01/15
[ "https://Stackoverflow.com/questions/448015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55563/" ]
I need to hide a DIV partially, not totally. When page loads, I want it to show the first, let's say, 100 pixels sitting on the uppermost part of the div. When the user clicks a certain button, the div will open (it could be a sliding effect like jQuery's show()). When the user clicks back the same button, the div will...
it could be done by setting div's initial height to 100px and setting its overflow to hidden in CSS. then you can change div's height to auto when you show the full div on javascript button click. example: <http://www.quirksmode.org/css/overflow.html> CSS code: ``` overflow : hidden; ```
448,017
<p>I've been running into a presentation issue with Internet Explorer. The following simple block of code renders as I would expect it to in Safari, FireFox, Chrome, and Opera. However it results in a noticeable <strong>space</strong> between the left and right floated DIV elements in both IE6 and IE7.</p> <p>My que...
[ { "answer_id": 448022, "author": "Brian Kim", "author_id": 5704, "author_profile": "https://Stackoverflow.com/users/5704", "pm_score": -1, "selected": false, "text": "<p>Try adding <code>display: inline</code> to floated divs. I believe this is an IE bug of adding more margins to floated...
2009/01/15
[ "https://Stackoverflow.com/questions/448017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26241/" ]
I've been running into a presentation issue with Internet Explorer. The following simple block of code renders as I would expect it to in Safari, FireFox, Chrome, and Opera. However it results in a noticeable **space** between the left and right floated DIV elements in both IE6 and IE7. My question is: Is there a more...
Float them both left, add the following after both divs: ``` <div class="clear"></div> .clear { clear: both; } ``` That or use padding instead of margins.
448,034
<p>I have threaded code where each thread needs to write to the same file. To prevent concurrency issues, I am using a Lock object.</p> <p>My question is whether I am using the Lock correctly. If I set the lock from within each thread, is that lock global or only specific to that specific thread?</p> <p>Basically, ...
[ { "answer_id": 448065, "author": "nosklo", "author_id": 17160, "author_profile": "https://Stackoverflow.com/users/17160", "pm_score": 3, "selected": true, "text": "<p>Create the lock outside the method.</p>\n\n<pre><code>class Agent(Thread):\n mylock = Lock()\n def write_result(sel...
2009/01/15
[ "https://Stackoverflow.com/questions/448034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16148/" ]
I have threaded code where each thread needs to write to the same file. To prevent concurrency issues, I am using a Lock object. My question is whether I am using the Lock correctly. If I set the lock from within each thread, is that lock global or only specific to that specific thread? Basically, should I create a L...
Create the lock outside the method. ``` class Agent(Thread): mylock = Lock() def write_result(self): self.mylock.acquire() try: ... finally: self.mylock.release() ``` or if using python >= 2.5: ``` class Agent(Thread): mylock = Lock() def write_result(...
448,036
<p>I have some code that produces a set of primary key values that I want to delete from a database table.</p> <pre><code>long[] keysToDelete = { 0, 1, 2, 3 }; </code></pre> <p>and I'd like to use a PreparedStatement to execute the equivalent of</p> <pre><code>DELETE FROM MyTable WHERE myPrimaryKey IN (0, 1, 2, 3); ...
[ { "answer_id": 448049, "author": "duffymo", "author_id": 37213, "author_profile": "https://Stackoverflow.com/users/37213", "pm_score": 4, "selected": true, "text": "<p>Two steps: </p>\n\n<ol>\n<li>Build up the PreparedStatement SQL String with the appropriate # of parameters.</li>\n<li>L...
2009/01/15
[ "https://Stackoverflow.com/questions/448036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20394/" ]
I have some code that produces a set of primary key values that I want to delete from a database table. ``` long[] keysToDelete = { 0, 1, 2, 3 }; ``` and I'd like to use a PreparedStatement to execute the equivalent of ``` DELETE FROM MyTable WHERE myPrimaryKey IN (0, 1, 2, 3); ``` Any idea how?
Two steps: 1. Build up the PreparedStatement SQL String with the appropriate # of parameters. 2. Loop over the array of values and bind each one to its parameter. Unfortunately, there's no good way to bind an array all at once.
448,054
<p>I am using an ASP.NET AJAX-Enabled Web application (ASP.NET 2.0 and AJAX Toolkit 1.0) that contains one button and 2 UpdatePanels (UpdatePanel_1 and UpdatePanel_2)</p> <p>The button is registered with RegisterAsyncPostBackControl in the ScriptManager object UpdatePanel_1 is in "Conditional" update mode and contain...
[ { "answer_id": 592187, "author": "Simes", "author_id": 47878, "author_profile": "https://Stackoverflow.com/users/47878", "pm_score": 2, "selected": false, "text": "<p>The problem is that invisible controls aren't rendered to the client. So then trying to make them visible isn't going to ...
2009/01/15
[ "https://Stackoverflow.com/questions/448054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47132/" ]
I am using an ASP.NET AJAX-Enabled Web application (ASP.NET 2.0 and AJAX Toolkit 1.0) that contains one button and 2 UpdatePanels (UpdatePanel\_1 and UpdatePanel\_2) The button is registered with RegisterAsyncPostBackControl in the ScriptManager object UpdatePanel\_1 is in "Conditional" update mode and contains a Tex...
The problem is that invisible controls aren't rendered to the client. So then trying to make them visible isn't going to work because as far as the client is concerned, they don't exist. Try using style="display:none", or use different CSS classes and styles for visible and invisible panels, rather than setting visibl...
448,077
<p>I'm trying to access a large Oracle database through SQL Server using OPENROWSET in client-side Javascript, and not having much luck. Here are the particulars:</p> <ul> <li>A SQL Server view that accesses the Oracle database using OPENROWSET works perfectly, so I know I have valid connection string parameters. Ho...
[ { "answer_id": 448851, "author": "Ken Paul", "author_id": 26671, "author_profile": "https://Stackoverflow.com/users/26671", "pm_score": 2, "selected": true, "text": "<p>I'm answering this myself. I found the answer, and I'm not happy with the results. The functions that have worked are...
2009/01/15
[ "https://Stackoverflow.com/questions/448077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26671/" ]
I'm trying to access a large Oracle database through SQL Server using OPENROWSET in client-side Javascript, and not having much luck. Here are the particulars: * A SQL Server view that accesses the Oracle database using OPENROWSET works perfectly, so I know I have valid connection string parameters. However, the new r...
I'm answering this myself. I found the answer, and I'm not happy with the results. The functions that have worked are being run under my personal user id, and I have db-owner privileges. For the *ad hoc* access to work, I need to either set the `DisallowAdhocAccess` registry setting to 0, or give db-owner privileges to...
448,087
<p>I have a SQL query where I am going to be transferring a fair amount of response data down the wire, but I want to get the total rowcount as quickly as possible to facilitate binding in the UI. Basically I need to get a snapshot of all of the rows that meet a certain criteria, and then be able to page through all o...
[ { "answer_id": 448098, "author": "Ryan Guill", "author_id": 7186, "author_profile": "https://Stackoverflow.com/users/7186", "pm_score": -1, "selected": false, "text": "<p>Personally I would select out the data in the order you want to eventually have it. So in your first select, have you...
2009/01/15
[ "https://Stackoverflow.com/questions/448087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a SQL query where I am going to be transferring a fair amount of response data down the wire, but I want to get the total rowcount as quickly as possible to facilitate binding in the UI. Basically I need to get a snapshot of all of the rows that meet a certain criteria, and then be able to page through all of th...
Use number 2. Just because you have a primary key on the table does not mean that the result set from select statement will be ordered (even if what you see actually is). There's no need to order the data when putting it in the temp table, so take that one out. You'll get the same @@ROWCOUNT value either way. So do ...
448,115
<p>I recently discovered <a href="http://shoes.heroku.com/" rel="nofollow noreferrer">Ruby Shoes</a>, which sounds rather useful for a beginner like me. The only the problem is that my laptop is x64, while the only Linux package is i686. I tried it anyway and it didn't work for me, I kept getting an error. I didn't exp...
[ { "answer_id": 448588, "author": "Adam Lassek", "author_id": 1249, "author_profile": "https://Stackoverflow.com/users/1249", "pm_score": 2, "selected": false, "text": "<p>There doesn't appear to be a 64-bit package for Linux, so if your distro doesn't package shoes you'll need to compile...
2009/01/15
[ "https://Stackoverflow.com/questions/448115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55577/" ]
I recently discovered [Ruby Shoes](http://shoes.heroku.com/), which sounds rather useful for a beginner like me. The only the problem is that my laptop is x64, while the only Linux package is i686. I tried it anyway and it didn't work for me, I kept getting an error. I didn't expect it to work, of course, but is there ...
There doesn't appear to be a 64-bit package for Linux, so if your distro doesn't package shoes you'll need to compile it yourself. This isn't as scary as it sounds! First, make sure you have the proper development libraries: > > Shoes relies on Cairo, Pango, libungif, libjpeg, GTK+ 2.0, and Ruby, > as well as GCC a...
448,116
<p>I have two tables, <code>DH_MASTER</code> and <code>DH_ALIAS</code>. <code>DH_MASTER</code> contains information about a person, including their name. <code>DH_ALIAS</code> contains AKA records about the person. The tables are linked by the <code>Operator</code> field which is a primary key in <code>DH_MASTER</co...
[ { "answer_id": 449852, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 0, "selected": false, "text": "<p>Linq to sql doesn't specify values directly into the query, it uses parameters. Are you sure it had the contains pa...
2009/01/15
[ "https://Stackoverflow.com/questions/448116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36320/" ]
I have two tables, `DH_MASTER` and `DH_ALIAS`. `DH_MASTER` contains information about a person, including their name. `DH_ALIAS` contains AKA records about the person. The tables are linked by the `Operator` field which is a primary key in `DH_MASTER`. The users want to search by the name stored in `DH_MASTER` as well...
This might not be appropriate, since your problem is different, but I remember a problem in one of my programs: Contains() would not work (in my case it would throw an Exception when evaluating), so maybe the Contains-method is a bit broken. I replaced ``` result.Contains( x ) ``` with ``` result.Any( p => p == x ...
448,120
<p>I'm using google app engine, and am having trouble writing querys to filter ReferenceProperties.</p> <p>eg.</p> <pre><code>class Group(db.Model): name = db.StringProperty(required=True) creator = db.ReferenceProperty(User) class GroupMember(db.Model): group = db.ReferenceProperty(Group) user = db....
[ { "answer_id": 448712, "author": "Nick Johnson", "author_id": 12030, "author_profile": "https://Stackoverflow.com/users/12030", "pm_score": 1, "selected": false, "text": "<p>This would require a join, which isn't possible in App Engine. If you want to filter by a property of another mode...
2009/01/15
[ "https://Stackoverflow.com/questions/448120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55565/" ]
I'm using google app engine, and am having trouble writing querys to filter ReferenceProperties. eg. ``` class Group(db.Model): name = db.StringProperty(required=True) creator = db.ReferenceProperty(User) class GroupMember(db.Model): group = db.ReferenceProperty(Group) user = db.ReferenceProperty(Use...
If what you want is to get the members of a group, ReferenceProperties have that built-in. ``` class GroupMember(db.Model): group = db.ReferenceProperty(Group, collection_name="groupMembers") user = db.ReferenceProperty(User, collection_name="groupMembers") ``` Then you can write: ``` # get the group entit...
448,122
<p>I am trying to compile the following code:</p> <pre><code>private String dataToString(){ Map data = (HashMap&lt;MyClass.Key, String&gt;) getData(); String toString = ""; for( MyClass.Key key: data.keySet() ){ toString += key.toString() + ": " + data.get( key ); return toString; } </code></pr...
[ { "answer_id": 448140, "author": "Craig P. Motlin", "author_id": 23572, "author_profile": "https://Stackoverflow.com/users/23572", "pm_score": 5, "selected": false, "text": "<p>Change:</p>\n\n<pre><code>Map data = (HashMap&lt;MyClass.Key, String&gt;) getData();\n</code></pre>\n\n<p>to</p...
2009/01/15
[ "https://Stackoverflow.com/questions/448122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47923/" ]
I am trying to compile the following code: ``` private String dataToString(){ Map data = (HashMap<MyClass.Key, String>) getData(); String toString = ""; for( MyClass.Key key: data.keySet() ){ toString += key.toString() + ": " + data.get( key ); return toString; } ``` I get an error in the for...
A slightly more efficient way to do this: ``` Map<MyClass.Key, String> data = (HashMap<MyClass.Key, String>) getData(); StringBuffer sb = new StringBuffer(); for (Map.Entry<MyClass.Key,String> entry : data.entrySet()) { sb.append(entry.getKey()); sb.append(": "); sb.append(entry.getValue())...
448,125
<p>I have a UIImage (Cocoa Touch). From that, I'm happy to get a CGImage or anything else you'd like that's available. I'd like to write this function:</p> <pre><code>- (int)getRGBAFromImage:(UIImage *)image atX:(int)xx andY:(int)yy { // [...] // What do I want to read about to help // me fill in this bit, here?...
[ { "answer_id": 448758, "author": "keremk", "author_id": 29475, "author_profile": "https://Stackoverflow.com/users/29475", "pm_score": 6, "selected": false, "text": "<p>One way of doing it is to draw the image to a bitmap context that is backed by a given buffer for a given colorspace (in...
2009/01/15
[ "https://Stackoverflow.com/questions/448125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34820/" ]
I have a UIImage (Cocoa Touch). From that, I'm happy to get a CGImage or anything else you'd like that's available. I'd like to write this function: ``` - (int)getRGBAFromImage:(UIImage *)image atX:(int)xx andY:(int)yy { // [...] // What do I want to read about to help // me fill in this bit, here? // [...] ...
FYI, I combined Keremk's answer with my original outline, cleaned-up the typos, generalized it to return an array of colors and got the whole thing to compile. Here is the result: ``` + (NSArray*)getRGBAsFromImage:(UIImage*)image atX:(int)x andY:(int)y count:(int)count { NSMutableArray *result = [NSMutableArray ar...
448,126
<p>Is there a way to implement/use lambda functions in bash? I'm thinking of something like:</p> <pre><code>$ someCommand | xargs -L1 (lambda function) </code></pre>
[ { "answer_id": 448166, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 6, "selected": true, "text": "<p>I don't know of a way to do this, however you may be able to accomplish what you're trying to do using:</p>\n\n<...
2009/01/15
[ "https://Stackoverflow.com/questions/448126", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38967/" ]
Is there a way to implement/use lambda functions in bash? I'm thinking of something like: ``` $ someCommand | xargs -L1 (lambda function) ```
I don't know of a way to do this, however you may be able to accomplish what you're trying to do using: ``` somecommand | while read -r; do echo "Something with $REPLY"; done ``` This will also be faster, as you won't be creating a new process for each line of text. **[EDIT 2009-07-09]** I've made two changes: 1. ...
448,142
<p>Currently I'm using:</p> <pre><code>Private Sub dgvStock_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvStock.CellEndEdit Select Case Me.dgvStock.Columns(e.ColumnIndex).Name Case "Quantity", "Unit Cost" If Not IsNumeric(Me.dgv...
[ { "answer_id": 448540, "author": "John Conrad", "author_id": 54358, "author_profile": "https://Stackoverflow.com/users/54358", "pm_score": 2, "selected": false, "text": "<p>The solution you have posted might work better if you listened for the KeyPress event rather than the CellEndEdit e...
2009/01/15
[ "https://Stackoverflow.com/questions/448142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20048/" ]
Currently I'm using: ``` Private Sub dgvStock_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvStock.CellEndEdit Select Case Me.dgvStock.Columns(e.ColumnIndex).Name Case "Quantity", "Unit Cost" If Not IsNumeric(Me.dgvStock(e.Column...
The solution you have posted might work better if you listened for the KeyPress event rather than the CellEndEdit event. You could then check for valid values as the user types in the text box and revert to the previous value if the entered value is not valid. Or alternatively, and this is not exactly what you are as...
448,143
<p>I'm trying to recover a table in a MySQL database from Time Machine, however I don't know and can't find where Leopard Server's MySQL stores its data files.</p> <ol> <li>Does anyone know where they are stored?</li> <li>Is there an easy way to run mysqldump on them without restoring them?</li> <li>Is there anything ...
[ { "answer_id": 448686, "author": "pixelcort", "author_id": 55578, "author_profile": "https://Stackoverflow.com/users/55578", "pm_score": 0, "selected": false, "text": "<p>It's in /var/mysql/dbname , where dbname is the name of the database.</p>\n" }, { "answer_id": 448765, "a...
2009/01/15
[ "https://Stackoverflow.com/questions/448143", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55578/" ]
I'm trying to recover a table in a MySQL database from Time Machine, however I don't know and can't find where Leopard Server's MySQL stores its data files. 1. Does anyone know where they are stored? 2. Is there an easy way to run mysqldump on them without restoring them? 3. Is there anything else I should know about ...
Connect to the database and issue ``` SHOW VARIABLES LIKE 'datadir'; ``` Which will tell you the right answer even if it's been changed from the default.
448,158
<p>Code snippet:</p> <pre><code>Dim target As Object ' target gets properly set to something of the desired type Dim field As FieldInfo = target.GetType.GetField("fieldName", _ BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic) field.SetValue(target,newValue) </code></pre> <p>This snippet works...
[ { "answer_id": 448208, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>Well, you haven't shown all your code - in particular, where you're setting <code>target</code> and how you're checki...
2009/01/15
[ "https://Stackoverflow.com/questions/448158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Code snippet: ``` Dim target As Object ' target gets properly set to something of the desired type Dim field As FieldInfo = target.GetType.GetField("fieldName", _ BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic) field.SetValue(target,newValue) ``` This snippet works perfectly IF target is se...
Working with your original sample, I agree that it works in C# but not in VB! If you use Reflector or ILDasm you will see that the call to Field.SetValue(target, ...) is actually compiled (in VB) as: ``` field.SetValue(RuntimeHelpers.GetObjectValue(target), ...) ``` GetObjectValue "Returns a boxed copy of obj if it ...
448,160
<p>I have this Javascript data:</p> <pre><code>[{id:123,type:"test"},{id:154,type:"another"}] </code></pre> <p>How would you transform that into something so that I can pass it as a HTTP post request?</p> <pre><code>menu[0][id] = 123 menu[0][type] = test menu[1][id] = 154 menu[1][type] = another </code></pre> <p>I ...
[ { "answer_id": 448172, "author": "Tracker1", "author_id": 43906, "author_profile": "https://Stackoverflow.com/users/43906", "pm_score": 0, "selected": false, "text": "<pre><code>\"?qsparam=\" + escape(\"[{id:123,type:'test'},{id:154,type:'another'},...]\")\n</code></pre>\n" }, { ...
2009/01/15
[ "https://Stackoverflow.com/questions/448160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50394/" ]
I have this Javascript data: ``` [{id:123,type:"test"},{id:154,type:"another"}] ``` How would you transform that into something so that I can pass it as a HTTP post request? ``` menu[0][id] = 123 menu[0][type] = test menu[1][id] = 154 menu[1][type] = another ``` I dont want to pass the actual JSON data, I want to...
``` var data = [{id:123,type:"test"},{id:154,type:"another"}]; var params = new Array(); for(var x = 0; x < data.length; x++) { params.push("id=[" + x + "]=" + escape(data[x].id)); params.push("type=[" + x + "]=" + escape(data[x].type)); } alert(params.join("&")); // output: id=[0]=123&type=[0]=test&id=[1]=154&...
448,162
<p>Is there a way to determine the device running an application. I want to distinguish between <code>iPhone</code> and <code>iPod Touch</code>, if possible.</p>
[ { "answer_id": 448218, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 9, "selected": true, "text": "<p>You can use the <a href=\"https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/ind...
2009/01/15
[ "https://Stackoverflow.com/questions/448162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55580/" ]
Is there a way to determine the device running an application. I want to distinguish between `iPhone` and `iPod Touch`, if possible.
You can use the [`UIDevice`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/model) class like this: ``` NSString *deviceType = [UIDevice currentDevice].model; if([deviceType isEqualToString:@"iPhone"]) // it's an iPhone ```
448,173
<p>How do you encode and decode a <code>CGPoint</code> struct using <code>NSCoder</code>?</p>
[ { "answer_id": 448202, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 4, "selected": true, "text": "<p><code>CGPoint</code>s and <code>NSPoint</code>s are both structures composed of two <code>CGFloat</code> values, s...
2009/01/15
[ "https://Stackoverflow.com/questions/448173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10232/" ]
How do you encode and decode a `CGPoint` struct using `NSCoder`?
`CGPoint`s and `NSPoint`s are both structures composed of two `CGFloat` values, so you can freely pass them around as each other. The quick and dirty way would be: ``` NSCoder *myNSCoder; CGPoint myPoint; [myNSCoder encodePoint:*(NSPoint *)myPoint]; ``` This will usually work, but it technically breaks the C99 stric...
448,181
<p>Does JPA/EJB3 framework provide standard way to do batch insert operation...? We use hibernate for persistence framework, So I can fall back to Hibernate Session and use combination session.save()/session.flush() achieve batch insert. But would like to know if EJB3 have a support for this...</p>
[ { "answer_id": 448260, "author": "Loki", "author_id": 39057, "author_profile": "https://Stackoverflow.com/users/39057", "pm_score": 3, "selected": false, "text": "<p>For hibernate specifically, the whole <a href=\"http://www.hibernate.org/hib_docs/reference/en/html/batch.html\" rel=\"nof...
2009/01/15
[ "https://Stackoverflow.com/questions/448181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55582/" ]
Does JPA/EJB3 framework provide standard way to do batch insert operation...? We use hibernate for persistence framework, So I can fall back to Hibernate Session and use combination session.save()/session.flush() achieve batch insert. But would like to know if EJB3 have a support for this...
Neither JPA nor Hibernate do provide particular support for batch inserts and the idiom for batch inserts with JPA would be the same as with Hibernate: ``` EntityManager em = ...; EntityTransaction tx = em.getTransaction(); tx.begin(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); ...
448,197
<p>I'm maintaining a web application that has a memory leak.</p> <p>Based on my investigation using Red Gate ANTS memory profiler I'm pretty sure that the memory leak is caused by event handlers in the business layer.</p> <p>There's a collection that registers an event handler on each item that's added so that the co...
[ { "answer_id": 448251, "author": "Simon Hughes", "author_id": 5884, "author_profile": "https://Stackoverflow.com/users/5884", "pm_score": 2, "selected": false, "text": "<p>First off, just to prove the point, try logging the adding and removal of events to a simple text file. Then, check ...
2009/01/15
[ "https://Stackoverflow.com/questions/448197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18102/" ]
I'm maintaining a web application that has a memory leak. Based on my investigation using Red Gate ANTS memory profiler I'm pretty sure that the memory leak is caused by event handlers in the business layer. There's a collection that registers an event handler on each item that's added so that the collection can re-s...
First off, just to prove the point, try logging the adding and removal of events to a simple text file. Then, check how many were added vs removed. It sounds as if there is a bug somewhere in the business logic which is not unregistering the event in all circumstances.
448,203
<p>I have to perform the following SQL query:</p> <pre><code>select answer_nbr, count(distinct user_nbr) from tpoll_answer where poll_nbr = 16 group by answer_nbr </code></pre> <p>The LINQ to SQL query </p> <pre><code>from a in tpoll_answer where a.poll_nbr = 16 select a.answer_nbr, a.user_nbr distinct </code></pr...
[ { "answer_id": 449845, "author": "Frans Bouma", "author_id": 44991, "author_profile": "https://Stackoverflow.com/users/44991", "pm_score": 1, "selected": false, "text": "<p>Linq to sql has no support for Count(Distinct ...). You therefore have to map a .NET method in code onto a Sql serv...
2009/01/15
[ "https://Stackoverflow.com/questions/448203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22695/" ]
I have to perform the following SQL query: ``` select answer_nbr, count(distinct user_nbr) from tpoll_answer where poll_nbr = 16 group by answer_nbr ``` The LINQ to SQL query ``` from a in tpoll_answer where a.poll_nbr = 16 select a.answer_nbr, a.user_nbr distinct ``` maps to the following SQL query: ``` sele...
There isn't direct support for `COUNT(DISTINCT {x}))`, but you can simulate it from an `IGrouping<,>` (i.e. what `group by` returns); I'm afraid I only "do" C#, so you'll have to translate to VB... ``` select new { Foo= grp.Key, Bar= grp.Select(x => x.SomeField).Distinct().Count() }; ``` Here's a Northw...
448,204
<p>I'm having trouble discovering exactly what I need to implement in order to use a custom authentication method with my web application using Spring Security. I have a Grails application with the Spring Security plugin that currently uses the standard user/password authentication with a browser form. This is working ...
[ { "answer_id": 737382, "author": "lsiu", "author_id": 84091, "author_profile": "https://Stackoverflow.com/users/84091", "pm_score": 6, "selected": true, "text": "<ol>\n<li><p>Implement a custom <code>AuthenticationProvider</code> which gets all your authentication information from the <c...
2009/01/15
[ "https://Stackoverflow.com/questions/448204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29995/" ]
I'm having trouble discovering exactly what I need to implement in order to use a custom authentication method with my web application using Spring Security. I have a Grails application with the Spring Security plugin that currently uses the standard user/password authentication with a browser form. This is working cor...
1. Implement a custom `AuthenticationProvider` which gets all your authentication information from the `Authentication`: `getCredentials()`, `getDetails()`, and `getPrincipal()`. Tie it into your Spring Security authentication mechanism using the following configuration snippet: ```xml <bean id="myAuthenticationProvi...
448,206
<p>In C# is there a way to detect if a string is all caps?</p> <p>Most of the strings will be short(ie under 100 characters)</p>
[ { "answer_id": 448215, "author": "Nick", "author_id": 1490, "author_profile": "https://Stackoverflow.com/users/1490", "pm_score": 3, "selected": false, "text": "<p>I would convert the string to all caps (with <code>ToUpper</code>) then compare that to the original (using <code>Equals</co...
2009/01/15
[ "https://Stackoverflow.com/questions/448206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13341/" ]
In C# is there a way to detect if a string is all caps? Most of the strings will be short(ie under 100 characters)
No need to create a new string: ``` bool IsAllUpper(string input) { for (int i = 0; i < input.Length; i++) { if (!Char.IsUpper(input[i])) return false; } return true; } ``` **Edit:** If you want to skip non-alphabetic characters (*The OP's original implementation does not, but h...
448,224
<p>Is the following construct thread-safe, assuming that the elements of foo are aligned and sized properly so that there is no word tearing? If not, why not?</p> <p>Note: The code below is a toy example of what I want to do, not my actual real world scenario. Obviously, there are better ways of coding the observab...
[ { "answer_id": 448248, "author": "Adam Rosenfield", "author_id": 9530, "author_profile": "https://Stackoverflow.com/users/9530", "pm_score": 0, "selected": false, "text": "<p>If reads and writes to each array element are atomic (i.e. they're aligned properly with no word tearing as you m...
2009/01/15
[ "https://Stackoverflow.com/questions/448224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
Is the following construct thread-safe, assuming that the elements of foo are aligned and sized properly so that there is no word tearing? If not, why not? Note: The code below is a toy example of what I want to do, not my actual real world scenario. Obviously, there are better ways of coding the observable behavior i...
On a modern multicore processor your code is NOT threadsafe (at least in most languages) without a memory barrier. Simply put, without explicit barriers each thread can see a different entirely copy of foo from caches. Say that your two threads ran at some point in time, then at some later point in time a third thread...
448,258
<p>I know that calling a virtual method from a base class constructor can be dangerous since the child class might not be in a valid state. (at least in C#)</p> <p>My question is what if the virtual method is the one who initializes the state of the object ? Is it good practice or should it be a two step process, firs...
[ { "answer_id": 448272, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p>(This answer applies to C# and Java. I believe C++ works differently on this matter.)</p>\n\n<p>Calling a virtual meth...
2009/01/15
[ "https://Stackoverflow.com/questions/448258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40007/" ]
I know that calling a virtual method from a base class constructor can be dangerous since the child class might not be in a valid state. (at least in C#) My question is what if the virtual method is the one who initializes the state of the object ? Is it good practice or should it be a two step process, first to creat...
(This answer applies to C# and Java. I believe C++ works differently on this matter.) Calling a virtual method in a constructor is indeed dangerous, but sometimes it can end up with the cleanest code. I would try to avoid it where possible, but without bending the design *hugely*. (For instance, the "initialize late...
448,265
<p>So. I have a problem where I have two versions of GCC on a machine.<br> 3.4.6 and 4.1</p> <p>This is due to some dependency issues with a new piece of software. (requires glibc 4.1)</p> <p>When I go to link this new software with the 4.1 libraries it links fine. However, when it comes to executing the software ...
[ { "answer_id": 448313, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 4, "selected": true, "text": "<p>You mean an absolute path that's used when the program is started and that's favored when looking for lib...
2009/01/15
[ "https://Stackoverflow.com/questions/448265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45581/" ]
So. I have a problem where I have two versions of GCC on a machine. 3.4.6 and 4.1 This is due to some dependency issues with a new piece of software. (requires glibc 4.1) When I go to link this new software with the 4.1 libraries it links fine. However, when it comes to executing the software it can't find the lib...
You mean an absolute path that's used when the program is started and that's favored when looking for libraries? `rpath` is exactly that. It will overwrite the default search path and stuff set in LD\_LIBRARY\_PATH. Just tell gcc to pass it through to the linker: ``` g++ -Wl,-rpath,/usr/lib/my_4.1 -omy_binary *.cpp `...
448,284
<p>I have an XML file with the following line:</p> <pre><code> &lt;VALUE DECIMAL_VALUE="0.2725" UNIT_TYPE="percent"/&gt; </code></pre> <p>I would like to increment this value by .04 and keep the format of the XML in place. I know this is possible with a Perl or awk script, but I am having difficulty with ...
[ { "answer_id": 448369, "author": "Richard Harrison", "author_id": 19624, "author_profile": "https://Stackoverflow.com/users/19624", "pm_score": 0, "selected": false, "text": "<p>Something akin to the following will work. It may need tweaking if there is extra spacing, but that is left as...
2009/01/15
[ "https://Stackoverflow.com/questions/448284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55593/" ]
I have an XML file with the following line: ``` <VALUE DECIMAL_VALUE="0.2725" UNIT_TYPE="percent"/> ``` I would like to increment this value by .04 and keep the format of the XML in place. I know this is possible with a Perl or awk script, but I am having difficulty with the expressions to isolate the nu...
If you're on a box with the xsltproc command in place I would suggest you use XSLT for this. For a Perl solution I'd go for using the DOM. Check this [DOM Processing with Perl](http://www.ibm.com/developerworks/xml/library/x-domprl/) article out. That said. If your XML file is produced in a predictable way something...
448,285
<p>I have a Graph being drawn inside a <code>UIScrollView</code>. It's one large <code>UIView</code> using a custom subclass of <code>CATiledLayer</code> as its layer.</p> <p>When I zoom in and out of the <code>UIScrollView</code>, I want the graph to resize dynamically like it does when I return the graph from <code...
[ { "answer_id": 451629, "author": "Brad Larson", "author_id": 19679, "author_profile": "https://Stackoverflow.com/users/19679", "pm_score": 6, "selected": true, "text": "<p>I can't help you with the crashing, other than tell you to check and make sure you aren't unintentionally autoreleas...
2009/01/15
[ "https://Stackoverflow.com/questions/448285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36007/" ]
I have a Graph being drawn inside a `UIScrollView`. It's one large `UIView` using a custom subclass of `CATiledLayer` as its layer. When I zoom in and out of the `UIScrollView`, I want the graph to resize dynamically like it does when I return the graph from `viewForZoomingInScrollView`. However, the Graph redraws its...
I can't help you with the crashing, other than tell you to check and make sure you aren't unintentionally autoreleasing a view or layer somewhere within your code. I've seen the simulator handle the timing of autoreleases differently than on the device (most often when threads are involved). The view scaling is an iss...
448,320
<p>I'm iterating through a HashMap (see <a href="https://stackoverflow.com/questions/448122/how-do-i-use-a-foreach-loop-in-java-to-loop-through-the-values-in-a-hashmap">my earlier question</a> for more detail) and building a string consisting of the data contained in the Map. For each item, I will have a new line, but...
[ { "answer_id": 448333, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 7, "selected": true, "text": "<p>Change your thought process from \"append a line break all but the last time\" to \"prepend a line break all but the f...
2009/01/15
[ "https://Stackoverflow.com/questions/448320", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47923/" ]
I'm iterating through a HashMap (see [my earlier question](https://stackoverflow.com/questions/448122/how-do-i-use-a-foreach-loop-in-java-to-loop-through-the-values-in-a-hashmap) for more detail) and building a string consisting of the data contained in the Map. For each item, I will have a new line, but for the very l...
Change your thought process from "append a line break all but the last time" to "prepend a line break all but the first time": ``` boolean first = true; StringBuilder builder = new StringBuilder(); for (Map.Entry<MyClass.Key,String> entry : data.entrySet()) { if (first) { first = false; } else { ...
448,327
<p>I can set the minimum version required (for example XP SP3) in Inno-Setup by going</p> <pre><code>MinVersion=0,5.01.2600 </code></pre> <p>However, that leads to the rather unfriendly Message Box:</p> <p><b><code>This program requires Windows NT version 5.1.2600 or later.</code></b></p> <p>Is there any way to hav...
[ { "answer_id": 448941, "author": "jdigital", "author_id": 37231, "author_profile": "https://Stackoverflow.com/users/37231", "pm_score": 5, "selected": true, "text": "<p>This string is named <a href=\"https://github.com/jrsoftware/issrc/blob/master/Files/Default.isl#L59\" rel=\"nofollow n...
2009/01/15
[ "https://Stackoverflow.com/questions/448327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3798/" ]
I can set the minimum version required (for example XP SP3) in Inno-Setup by going ``` MinVersion=0,5.01.2600 ``` However, that leads to the rather unfriendly Message Box: **`This program requires Windows NT version 5.1.2600 or later.`** Is there any way to have this say instead: **`This program requires WindowsX...
This string is named [`WinVersionTooLowError`](https://github.com/jrsoftware/issrc/blob/master/Files/Default.isl#L59) and is defined as ``` This program requires %1 version %2 or later. ``` You can redefine it in the [`[Messages]`](http://jrsoftware.org/ishelp/topic_messagessection.htm) section.
448,337
<p>In many places, like in app.config/web.config files I have to specify types using this verbose fully qualified names, like </p> <p><code>&lt;add name="myListener" type="System.Diagnostics.TextWriterTraceListener, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;</code></p> <p><a h...
[ { "answer_id": 448941, "author": "jdigital", "author_id": 37231, "author_profile": "https://Stackoverflow.com/users/37231", "pm_score": 5, "selected": true, "text": "<p>This string is named <a href=\"https://github.com/jrsoftware/issrc/blob/master/Files/Default.isl#L59\" rel=\"nofollow n...
2009/01/15
[ "https://Stackoverflow.com/questions/448337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13163/" ]
In many places, like in app.config/web.config files I have to specify types using this verbose fully qualified names, like `<add name="myListener" type="System.Diagnostics.TextWriterTraceListener, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />` [This MSDN site](http://msdn.microsoft...
This string is named [`WinVersionTooLowError`](https://github.com/jrsoftware/issrc/blob/master/Files/Default.isl#L59) and is defined as ``` This program requires %1 version %2 or later. ``` You can redefine it in the [`[Messages]`](http://jrsoftware.org/ishelp/topic_messagessection.htm) section.
448,346
<p>Scenario:</p> <ul> <li>I have a text file that has pipe (as in the <code>|</code> character) delimited data.</li> <li>Each field of data in the pipe delimited fields can be of variable length, so counting characters won't work (or using some sort of substring function... if that even exists in Vim).</li> </ul> <p>Is...
[ { "answer_id": 448370, "author": "Brian Carper", "author_id": 23070, "author_profile": "https://Stackoverflow.com/users/23070", "pm_score": 6, "selected": true, "text": "<pre><code>:%s/^\\v([^|]+\\|[^|]+)\\|.*$/\\1/\n</code></pre>\n" }, { "answer_id": 448379, "author": "Sarel...
2009/01/15
[ "https://Stackoverflow.com/questions/448346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9732/" ]
Scenario: * I have a text file that has pipe (as in the `|` character) delimited data. * Each field of data in the pipe delimited fields can be of variable length, so counting characters won't work (or using some sort of substring function... if that even exists in Vim). Is it possible, using Vim to delete all data f...
``` :%s/^\v([^|]+\|[^|]+)\|.*$/\1/ ```
448,363
<p>In my child user control I have a gridview with an OnRowCommand eventhandler that is executed when Edit button is click. I want to set the visibility of an ASP.NET placeholder control in the parent to true when the Edit button is clicked in child control.</p> <p>What would be the best way to accomplish this task?<...
[ { "answer_id": 451704, "author": "criddell", "author_id": 47154, "author_profile": "https://Stackoverflow.com/users/47154", "pm_score": 3, "selected": true, "text": "<p>I think I figured this one out. I opened my vcproj file and searched for ..\\..\\.. and found a couple of references to...
2009/01/15
[ "https://Stackoverflow.com/questions/448363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
In my child user control I have a gridview with an OnRowCommand eventhandler that is executed when Edit button is click. I want to set the visibility of an ASP.NET placeholder control in the parent to true when the Edit button is clicked in child control. What would be the best way to accomplish this task? **Update:*...
I think I figured this one out. I opened my vcproj file and searched for ..\..\.. and found a couple of references to files 5 directories "higher". I removed those references (the files weren't really there) and reopened the project. After doing this, I could rebind the project to SourceSafe.
448,374
<p>I am just starting out with ADO.net Entity Framework I have mapped two tables together and receive the following error:</p> <pre><code>Error 1 Error 11010: Association End 'OperatorAccess' is not mapped. E:\Visual Studio\projects\Brandi II\Brandi II\Hospitals.edmx 390 11 Brandi II </code></pre> <p>Not s...
[ { "answer_id": 448425, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 1, "selected": false, "text": "<p>There's not a lot of information in your question, but, generally speaking, this means that there is an incompletely...
2009/01/15
[ "https://Stackoverflow.com/questions/448374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5578/" ]
I am just starting out with ADO.net Entity Framework I have mapped two tables together and receive the following error: ``` Error 1 Error 11010: Association End 'OperatorAccess' is not mapped. E:\Visual Studio\projects\Brandi II\Brandi II\Hospitals.edmx 390 11 Brandi II ``` Not sure what it is I am doing ...
The Entity Framework designer is terrible - I've had the same problem many times (and your problem too, Craig): **This happens when you have a many-to-one association which is improperly setup.** They could *very easily* fix the designer to make this process simple; but instead, we have to put up with this crap. --- ...
448,376
<p>I'm writing some code that handles logging xml data and I would like to be able to replace the content of certain elements (eg passwords) in the document. I'd rather not serialize and parse the document as my code will be handling a variety of schemas.</p> <p>Sample input documents:</p> <p>doc #1:</p> <pre><code...
[ { "answer_id": 448395, "author": "Welbog", "author_id": 52443, "author_profile": "https://Stackoverflow.com/users/52443", "pm_score": 3, "selected": false, "text": "<p>I'd say you're better off parsing the content with a .NET XmlDocument object and finding password elements using XPath, ...
2009/01/15
[ "https://Stackoverflow.com/questions/448376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26500/" ]
I'm writing some code that handles logging xml data and I would like to be able to replace the content of certain elements (eg passwords) in the document. I'd rather not serialize and parse the document as my code will be handling a variety of schemas. Sample input documents: doc #1: ``` <user> <userid>jsm...
This problem is best solved with XSLT: ``` <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> ...
448,405
<p>I am using NHibernate and Rhinomocks and having trouble testing what I want. I would like to test the following repository method without hitting the database (where _session is injected into the repository as ISession):</p> <pre><code>public class Repository : IRepository { (... code snipped for brevity ...) ...
[ { "answer_id": 448576, "author": "Mark G", "author_id": 34556, "author_profile": "https://Stackoverflow.com/users/34556", "pm_score": 0, "selected": false, "text": "<p>From my point of view is this would be considered Integration Testing. NHibernate has it's own tests that it passes and...
2009/01/15
[ "https://Stackoverflow.com/questions/448405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15971/" ]
I am using NHibernate and Rhinomocks and having trouble testing what I want. I would like to test the following repository method without hitting the database (where \_session is injected into the repository as ISession): ``` public class Repository : IRepository { (... code snipped for brevity ...) public T ...
How I've done this test is to not pass the expression to the repository, instead expose IQueryable giving the repository an interface such as: ``` public interface IRepository<T> { IQueryable<T> All(); // whatever else you want } ``` Easily implemented like so: ``` public IQueryable<T> All() { return se...
448,407
<p>I'm trying to get quoted parameters of a bash script to safely be received by a nested script. Any ideas?</p> <p>test.sh</p> <pre><code>#!/bin/bash echo $* bash myecho.sh $* </code></pre> <p>myecho.sh</p> <pre><code>#!/bin/bash echo $1 echo $2 echo $3 echo $4 </code></pre> <p>Sample:</p> <pre><code>bash te...
[ { "answer_id": 448415, "author": "pixelbeat", "author_id": 4421, "author_profile": "https://Stackoverflow.com/users/4421", "pm_score": 7, "selected": true, "text": "<pre><code>#!/bin/bash\necho $*\nbash myecho.sh \"$@\"\n</code></pre>\n\n<p>Note the \"$@\" construct is not bash specific ...
2009/01/15
[ "https://Stackoverflow.com/questions/448407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28736/" ]
I'm trying to get quoted parameters of a bash script to safely be received by a nested script. Any ideas? test.sh ``` #!/bin/bash echo $* bash myecho.sh $* ``` myecho.sh ``` #!/bin/bash echo $1 echo $2 echo $3 echo $4 ``` Sample: ``` bash test.sh aaa bbb '"ccc ddd"' ``` Result: ``` aaa bbb "ccc ddd" aaa ...
``` #!/bin/bash echo $* bash myecho.sh "$@" ``` Note the "$@" construct is not bash specific and should work with any POSIX shell (it does with dash at least). Note also that given the output you want, you don't need the extra level of quoting at all. I.E. just call the above script like: ``` ./test.sh 1 2 "3 4" ``...
448,439
<p>In the WPF app we are building, we have 3 groups of RadioButtons in individual StackPanels side by side. We are trying to program the following behavior. When tabbing through the form, we don't want to tab through each of the radiobuttons (standard behavior), instead we would like to tab to the "first" radiobutton i...
[ { "answer_id": 584961, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>To change the orientation from left to right use the FlowDirection property to RightToLeft.</p>\n\n<p>RadioButton is used ...
2009/01/15
[ "https://Stackoverflow.com/questions/448439", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
In the WPF app we are building, we have 3 groups of RadioButtons in individual StackPanels side by side. We are trying to program the following behavior. When tabbing through the form, we don't want to tab through each of the radiobuttons (standard behavior), instead we would like to tab to the "first" radiobutton in e...
I think the KeyboardNavigation attached properties will do the trick. I mocked up a quick WPF example in XAML (sorry for the length), using ItemsControls to group the RadioButton elements: ``` <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/200...
448,441
<p>So I have an Application Sandbox HTMLLoader object which I create in <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="nofollow noreferrer">AIR</a> and simply want to call <a href="http://en.wikipedia.org/wiki/ActionScript" rel="nofollow noreferrer">ActionScript</a> methods from <a href="http://en...
[ { "answer_id": 449520, "author": "helifreak", "author_id": 52565, "author_profile": "https://Stackoverflow.com/users/52565", "pm_score": 4, "selected": true, "text": "<p>OK, I am going to answer my own question. I promise this was not a ploy to gain more reputation points, but I was seri...
2009/01/15
[ "https://Stackoverflow.com/questions/448441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52565/" ]
So I have an Application Sandbox HTMLLoader object which I create in [AIR](http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime) and simply want to call [ActionScript](http://en.wikipedia.org/wiki/ActionScript) methods from [JavaScript](http://en.wikipedia.org/wiki/JavaScript). In Flash, this is accomplished through o...
OK, I am going to answer my own question. I promise this was not a ploy to gain more reputation points, but I was seriously confused today but have now found the appropriate answers and documentation - which is usually the main problem to many an engineer's question... Anyway, the answer: The AIR HTMLLoader object co...
448,448
<p>I know about M-x dire, but would like to customize it. I would like to hit one key (for example F2) and get dire buffer open. When I navigate across the directory hierarchy it shouldn't open new buffers.</p> <p>And when I finally open the file it also shouldn't open new buffer for it (not strictly necessary, but st...
[ { "answer_id": 448568, "author": "Joe Casadonte", "author_id": 45978, "author_profile": "https://Stackoverflow.com/users/45978", "pm_score": 2, "selected": false, "text": "<p>Check out <a href=\"http://www.emacswiki.org/emacs/dired-single.el\" rel=\"nofollow noreferrer\">dired-single</a>...
2009/01/15
[ "https://Stackoverflow.com/questions/448448", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403/" ]
I know about M-x dire, but would like to customize it. I would like to hit one key (for example F2) and get dire buffer open. When I navigate across the directory hierarchy it shouldn't open new buffers. And when I finally open the file it also shouldn't open new buffer for it (not strictly necessary, but strongly pre...
Here's what I finally used: ``` (require 'dired) (global-set-key [(f2)] 'my-dired) (defun my-dired () (interactive) (dired (file-name-directory (buffer-file-name)))) (defadvice dired-advertised-find-file (around dired-subst-directory activate) "Replace current buffer if file is a directory." (interactive) (l...
448,458
<p>In Vim emulation mode (viper + vimpulse) &lt;&lt; and >> are working similarly to Vim's. I would just like them to indent with 2 spaces. How do I do that? (I know, trivial. But useful)</p>
[ { "answer_id": 448465, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 0, "selected": false, "text": "<p>I'm guessing that mode probably uses Emacs' <code>tab-width</code> or <code>c-basic-offset</code> settings. Both can be ...
2009/01/15
[ "https://Stackoverflow.com/questions/448458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403/" ]
In Vim emulation mode (viper + vimpulse) << and >> are working similarly to Vim's. I would just like them to indent with 2 spaces. How do I do that? (I know, trivial. But useful)
After reading viper-cmd.el code (and testing), I determined that correct answer is: ``` (setq viper-shift-width 2) ```
448,463
<pre><code> function get_total_adults() { $sql = "SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp"; $result = mysql_query($sql) or die(mysql_error()); $array = mysql_fetch_assoc($result); return $array['number_of_adults']; } </code></pre> <p>I know there is a way to write t...
[ { "answer_id": 448469, "author": "Paweł Hajdan", "author_id": 9403, "author_profile": "https://Stackoverflow.com/users/9403", "pm_score": 0, "selected": false, "text": "<p>You can drop the \"as number_of_adults\" part of the query and use mysql_result.</p>\n" }, { "answer_id": 44...
2009/01/15
[ "https://Stackoverflow.com/questions/448463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55619/" ]
``` function get_total_adults() { $sql = "SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp"; $result = mysql_query($sql) or die(mysql_error()); $array = mysql_fetch_assoc($result); return $array['number_of_adults']; } ``` I know there is a way to write this with less code....
``` function get_total_adults() { $sql = 'SELECT SUM(number_adults_attending) FROM is_nfo_rsvp'; $result = mysql_query($sql) or die(mysql_error()); // I'd throw a catchable exception (see below) rather than die with a MySQl error return mysql_result($result, 0); } ``` As to how I'd rather handle erro...
448,470
<p>Ok this is a little complex. I am creating a plugin, and want to find the category ID from the Post page.</p> <p>That's the easy part.</p> <p>What makes it complex is I am doing it within an ob_start (started in a 'template_redirect' action) as I want to edit the full page before it is returned to the browser. Aga...
[ { "answer_id": 448469, "author": "Paweł Hajdan", "author_id": 9403, "author_profile": "https://Stackoverflow.com/users/9403", "pm_score": 0, "selected": false, "text": "<p>You can drop the \"as number_of_adults\" part of the query and use mysql_result.</p>\n" }, { "answer_id": 44...
2009/01/15
[ "https://Stackoverflow.com/questions/448470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55595/" ]
Ok this is a little complex. I am creating a plugin, and want to find the category ID from the Post page. That's the easy part. What makes it complex is I am doing it within an ob\_start (started in a 'template\_redirect' action) as I want to edit the full page before it is returned to the browser. Again that is easy...
``` function get_total_adults() { $sql = 'SELECT SUM(number_adults_attending) FROM is_nfo_rsvp'; $result = mysql_query($sql) or die(mysql_error()); // I'd throw a catchable exception (see below) rather than die with a MySQl error return mysql_result($result, 0); } ``` As to how I'd rather handle erro...
448,478
<p>I have two tables like this:</p> <pre><code>Table1 (Number column is unique) Number | date 1234 2008-10-06 17:11:00 5678 2005-10-19 16:20:00 9023 2005-12-09 16:20:00 4243 2009-01-06 17:11:00 5234 2009-01-14 17:11:00 Table 2 Number | code 1234 A1 1234 B1 5678 ...
[ { "answer_id": 448491, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": false, "text": "<pre><code>Select Distinct T1.number, T2.code \nFrom Table2 T2 \n Join Table1 T1\n On T1.Number = T2.Numbe...
2009/01/15
[ "https://Stackoverflow.com/questions/448478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41685/" ]
I have two tables like this: ``` Table1 (Number column is unique) Number | date 1234 2008-10-06 17:11:00 5678 2005-10-19 16:20:00 9023 2005-12-09 16:20:00 4243 2009-01-06 17:11:00 5234 2009-01-14 17:11:00 Table 2 Number | code 1234 A1 1234 B1 5678 A1 9023 A1 ...
``` Select Distinct T1.number, T2.code From Table2 T2 Join Table1 T1 On T1.Number = T2.Number And T1.date = (Select Max(Date) From Table1 Where Number = T2.Number) ``` EDIT: to fix issue noted in comment: ``` Select Z.Number, Z.Code From (Select A.number, A.code...
448,514
<p>What is the best way to keep large projects organized with SSMS?</p> <p>I want to do something like:</p> <pre><code>ProjectRoot SchemaObjects Tables Constraints Indexes Keys Functions Views Stored Procedures Scripts DataGeneratio...
[ { "answer_id": 448539, "author": "Paul Nathan", "author_id": 26227, "author_profile": "https://Stackoverflow.com/users/26227", "pm_score": 2, "selected": false, "text": "<p>You'll have to write a PIC simulator and then emulate the IO functionality of the ports. </p>\n\n<p>To be honest, i...
2009/01/15
[ "https://Stackoverflow.com/questions/448514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1394296/" ]
What is the best way to keep large projects organized with SSMS? I want to do something like: ``` ProjectRoot SchemaObjects Tables Constraints Indexes Keys Functions Views Stored Procedures Scripts DataGeneration ``` And so on, bu...
Writing a whole emulator is going to be a real challenge. I've attempted to write an ARM emulator before, and let me tell you, it's not a small project. You're going to either have to emulate the entire CPU core, or find one that's already written. You'll also need to figure out how all the IO works. There may be docs...
448,521
<p>I'm currently re-using a partial on two different views.</p> <blockquote> <p>View A</p> <p>View B</p> </blockquote> <p>The partial belongs to Model A but has an association with Model B so it is applicable to Model B as well.</p> <p>It contains a form and when data is submitted, it always redirects the user to View ...
[ { "answer_id": 448622, "author": "mwilliams", "author_id": 23909, "author_profile": "https://Stackoverflow.com/users/23909", "pm_score": 3, "selected": true, "text": "<p>Solved.</p>\n\n<p>I added a hidden field to my form that contained the controller name of where the partial was render...
2009/01/15
[ "https://Stackoverflow.com/questions/448521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23909/" ]
I'm currently re-using a partial on two different views. > > View A > > > View B > > > The partial belongs to Model A but has an association with Model B so it is applicable to Model B as well. It contains a form and when data is submitted, it always redirects the user to View A. However, when I submit the for...
Solved. I added a hidden field to my form that contained the controller name of where the partial was rendered and then my respond\_to block determined where to send the user. View code: ``` <%= hidden_field_tag 'submitted_from', "#{controller.controller_name}" %> ``` My controller code: ``` if params[:submitted_...
448,550
<p>I've got a web application that controls which web applications get served traffic from our load balancer. The web application runs on each individual server.</p> <p>It keeps track of the "in or out" state for each application in an object in the ASP.NET application state, and the object is serialized to a file on ...
[ { "answer_id": 448560, "author": "Sam Saffron", "author_id": 17174, "author_profile": "https://Stackoverflow.com/users/17174", "pm_score": 5, "selected": true, "text": "<p>You should only be using Mutexes if you need <strong>cross-process synchronization</strong>. </p>\n\n<blockquote>\n ...
2009/01/15
[ "https://Stackoverflow.com/questions/448550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2596/" ]
I've got a web application that controls which web applications get served traffic from our load balancer. The web application runs on each individual server. It keeps track of the "in or out" state for each application in an object in the ASP.NET application state, and the object is serialized to a file on the disk w...
You should only be using Mutexes if you need **cross-process synchronization**. > > Although a mutex can be used for > intra-process thread synchronization, > using Monitor is generally preferred, > because monitors were designed > specifically for the .NET Framework > and therefore make better use of > resour...
448,563
<p>We all know the trouble overflows can cause, and this is why strn* exist - and most of the time they make sense. However, I have seen code which uses strncmp to compare commandline parameters like so:</p> <pre><code>if(... strncmp(argv[i], "--help", 6) == 0 </code></pre> <p>Now, I would have thought that this is u...
[ { "answer_id": 448571, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 5, "selected": true, "text": "<p>yes it is perfectly safe and considered standard practice. String literals are <strong>guaranteed</strong> to be prop...
2009/01/15
[ "https://Stackoverflow.com/questions/448563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26334/" ]
We all know the trouble overflows can cause, and this is why strn\* exist - and most of the time they make sense. However, I have seen code which uses strncmp to compare commandline parameters like so: ``` if(... strncmp(argv[i], "--help", 6) == 0 ``` Now, I would have thought that this is unnecessary and perhaps ev...
yes it is perfectly safe and considered standard practice. String literals are **guaranteed** to be properly null terminated.
448,634
<p>Is there a clean way to format a DateTime value as "Oct. 10, 2008 10:43am CST".</p> <p>I need it with the proper abbreviations and the "am" (or "pm") in lower case etc etc. </p> <p>I've done it myself but it's ugly so I'm looking for a different take on it.</p> <p>Thanks.</p>
[ { "answer_id": 448639, "author": "Trent", "author_id": 35329, "author_profile": "https://Stackoverflow.com/users/35329", "pm_score": 1, "selected": false, "text": "<p>Assuming your server is configured to CST:</p>\n\n<pre><code>string format = dateTime.ToString(\"mmm. dd, YYYY HH:MM tt \...
2009/01/15
[ "https://Stackoverflow.com/questions/448634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there a clean way to format a DateTime value as "Oct. 10, 2008 10:43am CST". I need it with the proper abbreviations and the "am" (or "pm") in lower case etc etc. I've done it myself but it's ugly so I'm looking for a different take on it. Thanks.
Since the "tt" format string specifier only outputs upper case, you'll have to modify that yourself. Also, DateTimes do not store the name of the timezone, only an offset. ``` DateTime dt = DateTime.Now; string ampm = dt.ToString("tt").ToLower(); string output = string.Format("{0:MMM. d, yyyy h:mm}{1}", dt, ampm); ``...
448,637
<p>If you have a recursive structure, say, child tables located inside td cells of parent tables, how best to traverse/select a particular parent table? For example, what if you wanted to find the next table up, or the 2nd table up?</p> <p>One way might be to put something like this in a loop:</p> <pre><code>//Get ...
[ { "answer_id": 448639, "author": "Trent", "author_id": 35329, "author_profile": "https://Stackoverflow.com/users/35329", "pm_score": 1, "selected": false, "text": "<p>Assuming your server is configured to CST:</p>\n\n<pre><code>string format = dateTime.ToString(\"mmm. dd, YYYY HH:MM tt \...
2009/01/15
[ "https://Stackoverflow.com/questions/448637", "https://Stackoverflow.com", "https://Stackoverflow.com/users/785/" ]
If you have a recursive structure, say, child tables located inside td cells of parent tables, how best to traverse/select a particular parent table? For example, what if you wanted to find the next table up, or the 2nd table up? One way might be to put something like this in a loop: ``` //Get the next parent up. $pa...
Since the "tt" format string specifier only outputs upper case, you'll have to modify that yourself. Also, DateTimes do not store the name of the timezone, only an offset. ``` DateTime dt = DateTime.Now; string ampm = dt.ToString("tt").ToLower(); string output = string.Format("{0:MMM. d, yyyy h:mm}{1}", dt, ampm); ``...
448,653
<p>I have an application that requires .Net. I have found out how to check registry values to see if .Net is installed and whether or not it is the proper version. </p> <p>What I want to know is this: Will registry values change based on the Language setting of the OS. That is, if someone in Peru installs .Net and my ...
[ { "answer_id": 448661, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "<p>I'm 99.99% certain that it will always be \"Version\". There's no point in translating registry keys, and it would onl...
2009/01/15
[ "https://Stackoverflow.com/questions/448653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55638/" ]
I have an application that requires .Net. I have found out how to check registry values to see if .Net is installed and whether or not it is the proper version. What I want to know is this: Will registry values change based on the Language setting of the OS. That is, if someone in Peru installs .Net and my applicatio...
I'm 99.99% certain that it will always be "Version". There's no point in translating registry keys, and it would only make things harder for developers everywhere. Having said that, it's obviously best to find a key which is documented by Microsoft.
448,657
<p>I'm having a little trouble getting my head around the conceptual difference between an object and a class. I don't really understand the distinction between the two in any programming language, but currently I'm working with Perl, and Moose, so I'd prefer an explanation using those things.</p> <p>Cheers</p>
[ { "answer_id": 448669, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 3, "selected": false, "text": "<p>A class is a type (like \"SUV\"). An object is an instance of a class (\"David's SUV\").</p>\n" }, { "answer_id...
2009/01/15
[ "https://Stackoverflow.com/questions/448657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36499/" ]
I'm having a little trouble getting my head around the conceptual difference between an object and a class. I don't really understand the distinction between the two in any programming language, but currently I'm working with Perl, and Moose, so I'd prefer an explanation using those things. Cheers
There are lots of "a class is a blueprint, an object is something built from that blueprint", but since you've asked for a specific example using Moose and Perl, I thought I'd provide one. In this following example, we're going have a class named 'Hacker'. The class (like a blueprint) describes what hackers are (their...
448,666
<p>In javascript, what is the best way to parse an INT from a string which starts with a letter (such as "test[123]")? I need something that will work for the example below.</p> <p>My JS:</p> <pre><code>$(document).ready(function() { $(':input').change( function() { id = parseInt($(this).attr("id")); /...
[ { "answer_id": 448679, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 5, "selected": false, "text": "<pre><code>parseInt(input.replace(/[^0-9-]/,\"\"),10)\n</code></pre>\n" }, { "answer_id": 448682, "author"...
2009/01/15
[ "https://Stackoverflow.com/questions/448666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30133/" ]
In javascript, what is the best way to parse an INT from a string which starts with a letter (such as "test[123]")? I need something that will work for the example below. My JS: ``` $(document).ready(function() { $(':input').change( function() { id = parseInt($(this).attr("id")); //fails for the data be...
You could use a regular expression to match the number: ``` $(this).attr("id").match(/\d+/) ```
448,719
<p>Is there any guideline or rule for when the <strong>view state</strong> should be enabled on a server control? And when it should <strong><em>not</em></strong>?</p> <p>I was looking at this <a href="http://quickstarts.asp.net/QuickStartv20/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMasterDetailsInsert.src...
[ { "answer_id": 448746, "author": "willz", "author_id": 50369, "author_profile": "https://Stackoverflow.com/users/50369", "pm_score": 0, "selected": false, "text": "<p>only enableviewstate when you want to preserve the values across http requests, other than that keep it = false. also you...
2009/01/15
[ "https://Stackoverflow.com/questions/448719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
Is there any guideline or rule for when the **view state** should be enabled on a server control? And when it should ***not***? I was looking at this [`SqlDatasource` example](http://quickstarts.asp.net/QuickStartv20/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMasterDetailsInsert.src) and noticed that the vie...
Here's a good rule of thumb: If you (1) change a property's value in the code-behind, and (2) need to know what value you set in a later postback without recalculating the value, then you need to use ViewState. For example. In my page's markup I might have a Label control specified like this: ``` <asp:Label ID="Title...
448,729
<p>I wondering what the "best practice" way (in C#) is to implement this xpath query with LINQ:</p> <pre><code>/topNode/middleNode[@filteringAttribute='filterValue']/penultimateNode[@anotherFilterAttribute='somethingElse']/nodesIWantReturned </code></pre> <p>I would like an IEnumerable list of the 'nodesIWantReturned...
[ { "answer_id": 448773, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 2, "selected": false, "text": "<pre><code>var result = root.Elements(\"topNode\")\n .Elements(\"middleNode\")\n .Where(a =&gt...
2009/01/15
[ "https://Stackoverflow.com/questions/448729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10309/" ]
I wondering what the "best practice" way (in C#) is to implement this xpath query with LINQ: ``` /topNode/middleNode[@filteringAttribute='filterValue']/penultimateNode[@anotherFilterAttribute='somethingElse']/nodesIWantReturned ``` I would like an IEnumerable list of the 'nodesIWantReturned', but only from a certain...
A more *verbal* solution: ``` var nodesIWantReturned = from m in doc.Elements("topNode").Elements("middleNode") from p in m.Elements("penultimateNode") from n in p.Elements("nodesIWantReturned") where m.Attribute("filteringAttribute").Value == "filterValue" where...
448,777
<p>I am trying to use the following code to load styles from an external SWF, but I keep getting an ActionScript error when the URL is invalid:</p> <pre><code>Error: Unable to load style(Error #2036: Load Never Completed. URL: http://localhost/css/styles.swf): ../css/styles.swf. at &lt;anonymous&gt;()[C:\autobuild\3.2...
[ { "answer_id": 448864, "author": "Christian Nunciato", "author_id": 32129, "author_profile": "https://Stackoverflow.com/users/32129", "pm_score": 1, "selected": false, "text": "<p>Interesting problem. Try removing the removeEventListener call, or commenting it out; in my brief tests it ...
2009/01/15
[ "https://Stackoverflow.com/questions/448777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31298/" ]
I am trying to use the following code to load styles from an external SWF, but I keep getting an ActionScript error when the URL is invalid: ``` Error: Unable to load style(Error #2036: Load Never Completed. URL: http://localhost/css/styles.swf): ../css/styles.swf. at <anonymous>()[C:\autobuild\3.2.0\frameworks\projec...
I debugged the source, and found that the ERROR Event *is* being triggered twice. So, I simply set a flag the first time the ERROR event handler is triggered, and check that flag for a value of true before continuing: ``` private var isErrorTriggered:Boolean; // Default is false private function loadStyle_completeHan...
448,821
<p>I have a simple function written in Oracle 9i (version 9.2.0.4.0) to simulate an in-line IF. For those interested, here's the code:</p> <pre><code>create or replace FUNCTION IIF (testExpression NUMBER, trueResult NUMBER, falseResult NUMBER) RETURN NUMBER AS BEGIN /* A simple in-line IF func...
[ { "answer_id": 448841, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 0, "selected": false, "text": "<p>Having never worked with oracle I can't directly offer any sound advice, but looking at the statement it could...
2009/01/15
[ "https://Stackoverflow.com/questions/448821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47580/" ]
I have a simple function written in Oracle 9i (version 9.2.0.4.0) to simulate an in-line IF. For those interested, here's the code: ``` create or replace FUNCTION IIF (testExpression NUMBER, trueResult NUMBER, falseResult NUMBER) RETURN NUMBER AS BEGIN /* A simple in-line IF function for use w...
Maybe you can explain what you are trying to do. I think you are looking for the `CASE` or `DECODE` functions, but I can't be sure. It seems like you are working against the grain of the SQL language for some reason. The error occurs because Oracle doesn't expect a relational operator in the `select` clause of the que...
448,828
<p>I'm currently porting a POSIX C++ application to run on Windows without Cygwin or anything. No problem so far. Now, the application (ZNC, an IRC bouncer, in case you're interested) supports loading modules from .so shared library files on Linux/BSD etc.</p> <p>I ported the main executable without much of a problem,...
[ { "answer_id": 448841, "author": "Quintin Robinson", "author_id": 12707, "author_profile": "https://Stackoverflow.com/users/12707", "pm_score": 0, "selected": false, "text": "<p>Having never worked with oracle I can't directly offer any sound advice, but looking at the statement it could...
2009/01/15
[ "https://Stackoverflow.com/questions/448828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55650/" ]
I'm currently porting a POSIX C++ application to run on Windows without Cygwin or anything. No problem so far. Now, the application (ZNC, an IRC bouncer, in case you're interested) supports loading modules from .so shared library files on Linux/BSD etc. I ported the main executable without much of a problem, all wrapp...
Maybe you can explain what you are trying to do. I think you are looking for the `CASE` or `DECODE` functions, but I can't be sure. It seems like you are working against the grain of the SQL language for some reason. The error occurs because Oracle doesn't expect a relational operator in the `select` clause of the que...
448,830
<p>We have a project where we need to provide search over a collection of Word documents through a web-based interface. The client would like for the search terms to be highlighted when a user opens a document.</p> <p>Is there a way to do this directly in Word when opening a document? The only alternative we can come ...
[ { "answer_id": 448975, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 2, "selected": false, "text": "<p>You could do that using Word's Highlight feature. However, to use the feature you will have to use Word automation...
2009/01/15
[ "https://Stackoverflow.com/questions/448830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13463/" ]
We have a project where we need to provide search over a collection of Word documents through a web-based interface. The client would like for the search terms to be highlighted when a user opens a document. Is there a way to do this directly in Word when opening a document? The only alternative we can come up with is...
You could do that using Word's Highlight feature. However, to use the feature you will have to use Word automation on either server-side or client-side. A script in VBA for highlighting a search term could look like this: ``` Sub Highlight(oDoc As Word.Document, term As String) With oDoc.Range.Find .Cle...
448,837
<p>I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities.</p> <p>I'd like to create a web page served from one of my systems that would merely pr...
[ { "answer_id": 448850, "author": "Daniel Bruce", "author_id": 6456, "author_profile": "https://Stackoverflow.com/users/6456", "pm_score": 2, "selected": false, "text": "<p>All you need is to have it in a directory that is set to execute CGI scripts, then you need to add </p>\n\n<pre><cod...
2009/01/15
[ "https://Stackoverflow.com/questions/448837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23972/" ]
I'm a hobbyist (and fairly new) programmer who has written several useful (to me) scripts in python to handle various system automation tasks that involve copying, renaming, and downloading files amongst other sundry activities. I'd like to create a web page served from one of my systems that would merely present a fe...
[This page](http://docs.python.org/library/cgi.html) on the python site has a good description and example of what you need to do to run a python CGI script. Start out with the simplest case first. Just make a short script that prints html. ``` #!/usr/bin/python #on windows change to your path to th...
448,842
<p>Is it possible to replace exact text with other text after the page has loaded with jquery? </p> <p>For example, my data is being generated dynamically within a php loop. Once it finishes outputting the information, I'd like to do a find and replace, replacing the phrase "test phrase 1" with "test phrase 2" through...
[ { "answer_id": 449015, "author": "Marko Dumic", "author_id": 5817, "author_profile": "https://Stackoverflow.com/users/5817", "pm_score": 0, "selected": false, "text": "<p>I think you will find <a href=\"http://code.google.com/p/jquery-translate/\" rel=\"nofollow noreferrer\">jquery-trans...
2009/01/15
[ "https://Stackoverflow.com/questions/448842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/55655/" ]
Is it possible to replace exact text with other text after the page has loaded with jquery? For example, my data is being generated dynamically within a php loop. Once it finishes outputting the information, I'd like to do a find and replace, replacing the phrase "test phrase 1" with "test phrase 2" throughout the pa...
You don't need yet another plugin for this task. The jQuery function .replace() is just fine for that. You can use it on any attribut or text. Example: ``` var href = $this.attr("href").replace(/param\/.*\//, "param/newparam/"); ``` This - using regex - takes an url and replaces the first occurance of `param/anythi...
448,844
<p>On the discussion of dynamic memory here: <a href="http://theocacao.com/document.page/234" rel="nofollow noreferrer">"Intro to C Pointers and Dynamic Memory"</a></p> <p>The author states:</p> <blockquote> <p>A memory block like this can effectively be used as a more flexible array. This approach is actually much...
[ { "answer_id": 448856, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 5, "selected": true, "text": "<p>If you declare <code>int array[variable]</code> the memory will be allocated on the stack which is not very good for large, ...
2009/01/15
[ "https://Stackoverflow.com/questions/448844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1434/" ]
On the discussion of dynamic memory here: ["Intro to C Pointers and Dynamic Memory"](http://theocacao.com/document.page/234) The author states: > > A memory block like this can effectively be used as a more flexible array. This approach is actually much more common in real-world C programs. It's also more predictabl...
If you declare `int array[variable]` the memory will be allocated on the stack which is not very good for large, relatively permanent data structures (such as one you might want to return). You don't need to free memory manually if you use the array syntax since it's freed when it goes out of scope. `calloc` on the oth...
448,865
<p>I am trying to figure out the best way to parse this comma delimited text file. Here is an excerpt:</p> <pre><code>bldgA, fred, lunch bldgA, sally, supper bldgB, bob, parking lot bldgB, frank, rooftop ... </code></pre> <p>What I am trying to do is read "bldgA" and then I want the person (2nd column), "fred" for ex...
[ { "answer_id": 448881, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 0, "selected": false, "text": "<p>Use a state machine, basically. Have a variable called \"building\", and store the building name in there when you enc...
2009/01/15
[ "https://Stackoverflow.com/questions/448865", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28045/" ]
I am trying to figure out the best way to parse this comma delimited text file. Here is an excerpt: ``` bldgA, fred, lunch bldgA, sally, supper bldgB, bob, parking lot bldgB, frank, rooftop ... ``` What I am trying to do is read "bldgA" and then I want the person (2nd column), "fred" for example. But I don't want to...
If you know that the file will ALWAYS be formatted correctly, you could do something like (using your code, assuming the language is C#): ``` String MyLocation = System.Net.Dns.GetHostName(); string MachineFile = Server.MapPath("buildings.txt"); StreamReader FileStreamReader; FileStreamReader = File.OpenText(Machine...
448,878
<p>I cannot seem to figure out how I can add the 'when' keyword to <a href="http://boo.codehaus.org/" rel="nofollow noreferrer">BOO</a> which should behave as an 'if'. I figure I could make a method, but then I cannot move the when around like I can with if. Any pointers would be appreciated.</p> <p>-Mark</p>
[ { "answer_id": 449263, "author": "Svante", "author_id": 31615, "author_profile": "https://Stackoverflow.com/users/31615", "pm_score": 0, "selected": false, "text": "<p>This would be a job for a macro. From the page you linked to, it seems that Boo has syntactic macros.</p>\n\n<p>As an a...
2009/01/15
[ "https://Stackoverflow.com/questions/448878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I cannot seem to figure out how I can add the 'when' keyword to [BOO](http://boo.codehaus.org/) which should behave as an 'if'. I figure I could make a method, but then I cannot move the when around like I can with if. Any pointers would be appreciated. -Mark
This would do what you want: ``` import Boo.Lang.Compiler.Ast import Boo.Lang.Compiler.MetaProgramming macro when: return [| if $(when.Arguments[0]): $(when.Block) |] x = 1 when x == 1: print "x equals one" when x == 2: print "x equals two" ``` Btw, feel free to (also) ask on th...
448,885
<p>I have an html page populated from a cgi app. Right now when I make a change on my html page through a form </p> <pre><code>&lt;form action="/cgi-bin/Lib.exe" method=POST name="checks" ID="Form2"&gt; </code></pre> <p>It takes me from<br> <a href="http://localhost/index.html" rel="nofollow noreferrer">http://local...
[ { "answer_id": 448896, "author": "Jimmy", "author_id": 4435, "author_profile": "https://Stackoverflow.com/users/4435", "pm_score": 2, "selected": false, "text": "<p>you're basically asking \"how do I use AJAX\". I'd recommend using a library. In JQuery it would look something like:</p>\n...
2009/01/15
[ "https://Stackoverflow.com/questions/448885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/52256/" ]
I have an html page populated from a cgi app. Right now when I make a change on my html page through a form ``` <form action="/cgi-bin/Lib.exe" method=POST name="checks" ID="Form2"> ``` It takes me from <http://localhost/index.html> to <http://localhost/cgi-bin/Lib.exe> where the CGI outputs some debug lin...
You can send a 302 status code from the CGI script, which will redirect the user's browser to `/index.html`. Basically, make the CGI script spit this out: ``` HTTP/1.1 302 Found Location: /index.html ```
448,890
<p>I am accessing a business class using an ObjectDataSource and trying to produce output that makes sense to the user. The return values describe a Class (as in Classroom and teaching, not software). I would like to show the time of the class as a range like this: "9:00 AM - 10:00 AM".</p> <p>This is the Linq Query...
[ { "answer_id": 448928, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "<p>The reason is the query is being used in LINQ to SQL. LINQ to SQL treats queries as expression trees. It has mappings define...
2009/01/15
[ "https://Stackoverflow.com/questions/448890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15592/" ]
I am accessing a business class using an ObjectDataSource and trying to produce output that makes sense to the user. The return values describe a Class (as in Classroom and teaching, not software). I would like to show the time of the class as a range like this: "9:00 AM - 10:00 AM". This is the Linq Query I am using ...
The reason is the query is being used in LINQ to SQL. LINQ to SQL treats queries as expression trees. It has mappings defined for some methods (for instance, `Contains`) but since it doesn't really execute them, it can't work on arbitrary methods. It parses the query and submits it to SQL server. The equivalent of the ...
448,910
<p>Can anybody give a clear explanation of how variable assignment really works in Makefiles. </p> <p>What is the difference between :</p> <pre><code> VARIABLE = value VARIABLE ?= value VARIABLE := value VARIABLE += value </code></pre> <p>I have read the <a href="http://www.gnu.org/software/make/manual/make.html#...
[ { "answer_id": 448939, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 11, "selected": true, "text": "<h3>Lazy Set</h3>\n<pre><code>VARIABLE = value\n</code></pre>\n<p>Normal setting of a variable, but any other variables ment...
2009/01/15
[ "https://Stackoverflow.com/questions/448910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48427/" ]
Can anybody give a clear explanation of how variable assignment really works in Makefiles. What is the difference between : ``` VARIABLE = value VARIABLE ?= value VARIABLE := value VARIABLE += value ``` I have read the [section](http://www.gnu.org/software/make/manual/make.html#Reading-Makefiles) in GNU Make's...
### Lazy Set ``` VARIABLE = value ``` Normal setting of a variable, but any other variables mentioned with the `value` field are recursively expanded with their value at the point at which the variable is used, not the one it had when it was declared ### Immediate Set ``` VARIABLE := value ``` Setting of a varia...
448,911
<p>I have two PowerShell functions, the first of which invokes the second. They both take N arguments, and one of them is defined to simply add a flag and invoke the other. Here are example definitions:</p> <pre><code>function inner { foreach( $arg in $args ) { # do some stuff } } function outer { i...
[ { "answer_id": 450921, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 0, "selected": false, "text": "<p>Well, there may be a better way, but see if this works:</p>\n\n<pre><code>inner --flag [string]::Join(\" \", $args)\n</co...
2009/01/15
[ "https://Stackoverflow.com/questions/448911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18529/" ]
I have two PowerShell functions, the first of which invokes the second. They both take N arguments, and one of them is defined to simply add a flag and invoke the other. Here are example definitions: ``` function inner { foreach( $arg in $args ) { # do some stuff } } function outer { inner --flag $a...
There isn't a good solution to this problem in PowerSHell V1. In V2 we added splatting (though for various reasons, we use @ instead of \* for this purpose). Here's what it looks like: PS (STA-ISS) (2) > function foo ($x,$y,$z) { "x:$x y:$y z:$z" } PS (STA-ISS) (3) > $a = 1,2,3 PS (STA-ISS) (4) > foo $a # passed as ...
448,944
<p>I'm trying to write a program in C (on Linux) that loops until the user presses a key, but shouldn't require a keypress to continue each loop.</p> <p>Is there a simple way to do this? I figure I could possibly do it with <code>select()</code> but that seems like a lot of work.</p> <p>Alternatively, is there a way ...
[ { "answer_id": 448957, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": false, "text": "<p>On UNIX systems, you can use <code>sigaction</code> call to register a signal handler for <code>SIGINT</code> signal which ...
2009/01/15
[ "https://Stackoverflow.com/questions/448944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4924/" ]
I'm trying to write a program in C (on Linux) that loops until the user presses a key, but shouldn't require a keypress to continue each loop. Is there a simple way to do this? I figure I could possibly do it with `select()` but that seems like a lot of work. Alternatively, is there a way to catch a `ctrl`-`c` keypre...
As already stated, you can use `sigaction` to trap ctrl-c, or `select` to trap any standard input. Note however that with the latter method you also need to set the TTY so that it's in character-at-a-time rather than line-at-a-time mode. The latter is the default - if you type in a line of text it doesn't get sent to ...
448,949
<p>What are the minimal client settings i need to do for a streamlined WCF config in the app.config?</p> <p>The default one is this:</p> <pre><code> &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="WSHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" re...
[ { "answer_id": 449109, "author": "Jero", "author_id": 55675, "author_profile": "https://Stackoverflow.com/users/55675", "pm_score": 2, "selected": false, "text": "<p>I think you'll find that <em>all</em> of that is optional. All of those things in that particular binding are the defaults...
2009/01/15
[ "https://Stackoverflow.com/questions/448949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13502/" ]
What are the minimal client settings i need to do for a streamlined WCF config in the app.config? The default one is this: ``` <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout=...
Jerograv is right, given that these are all defaults you can omit all of them. To test this I've created a simple service and created the minimal config required which is pretty much the address, the binding and the contract- ``` <?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> ...
448,981
<p>What characters/symbols are allowed within the <strong>CSS</strong> class selectors?<br> I know that the following characters are <em>invalid</em>, but what characters are <em>valid</em>?</p> <pre><code>~ ! @ $ % ^ &amp; * ( ) + = , . / ' ; : " ? &gt; &lt; [ ] \ { } | ` # </code></pre>
[ { "answer_id": 449000, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 11, "selected": true, "text": "<p>You can check directly at the <a href=\"http://www.w3.org/TR/CSS21/grammar.html#scanner\" rel=\"noreferrer\">CSS gr...
2009/01/15
[ "https://Stackoverflow.com/questions/448981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5441/" ]
What characters/symbols are allowed within the **CSS** class selectors? I know that the following characters are *invalid*, but what characters are *valid*? ``` ~ ! @ $ % ^ & * ( ) + = , . / ' ; : " ? > < [ ] \ { } | ` # ```
You can check directly at the [CSS grammar](http://www.w3.org/TR/CSS21/grammar.html#scanner). *Basically*1, a name must begin with an underscore (`_`), a hyphen (`-`), or a letter(`a`–`z`), followed by any number of hyphens, underscores, letters, or numbers. There is a catch: if the first character is a hyphen, the se...
448,997
<p>I'm trying to use egrep with a regex pattern to match whitespace. </p> <p>I've used RegEx with Perl and C# before and they both support the pattern <code>\s</code> to search for whitespace. egrep (or at least the version I'm using) does not seem to support this pattern.</p> <p>In a few articles online I've come ac...
[ { "answer_id": 449009, "author": "Aif", "author_id": 51760, "author_profile": "https://Stackoverflow.com/users/51760", "pm_score": -1, "selected": false, "text": "<pre><code>$ cat &gt; file\nthis line has whitespace\nthislinedoesnthave\n$ egrep [[:space:]] file \nthis line has whitespace...
2009/01/15
[ "https://Stackoverflow.com/questions/448997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32474/" ]
I'm trying to use egrep with a regex pattern to match whitespace. I've used RegEx with Perl and C# before and they both support the pattern `\s` to search for whitespace. egrep (or at least the version I'm using) does not seem to support this pattern. In a few articles online I've come across a shorthand [[:space:]]...
I see the same issue on SunOS 5.10. `/usr/bin/egrep` does not support extended regular expressions. Try using `/usr/xpg4/bin/egrep`: ``` $ echo 'this line has whitespace thislinedoesnthave' | /usr/xpg4/bin/egrep '[[:space:]]' this line has whitespace ``` Another option might be to just use perl: ``` $ echo 'this l...
448,999
<p>If I load a kernel module and list the loaded modules with <code>lsmod</code>, I can get the "use count" of the module (number of other modules with a reference to the module). Is there a way to figure out <em>what</em> is using a module, though?</p> <p>The issue is that a module I am developing insists its use cou...
[ { "answer_id": 449179, "author": "jedihawk", "author_id": 54322, "author_profile": "https://Stackoverflow.com/users/54322", "pm_score": 2, "selected": false, "text": "<p>You might try <code>lsof</code> or <code>fuser</code>.</p>\n" }, { "answer_id": 449187, "author": "Norman ...
2009/01/15
[ "https://Stackoverflow.com/questions/448999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28804/" ]
If I load a kernel module and list the loaded modules with `lsmod`, I can get the "use count" of the module (number of other modules with a reference to the module). Is there a way to figure out *what* is using a module, though? The issue is that a module I am developing insists its use count is 1 and thus I cannot us...
Actually, there seems to be a way to list processes that claim a module/driver - however, I haven't seen it advertised (outside of Linux kernel documentation), so I'll jot down my notes here: First of all, many thanks for [@haggai\_e](https://stackoverflow.com/a/449856/277826)'s answer; the pointer to the functions `t...
449,002
<p>I have using blocks in each method of my repository. If I want to cross reference methods, it seems it would be against best practices to initialize another Datacontext What am i doing wrong? If I declare a Datacontext in the class instead of using blocks in methods will I not lose power to dispose ??</p> <pre><co...
[ { "answer_id": 449006, "author": "Erik Forbes", "author_id": 16942, "author_profile": "https://Stackoverflow.com/users/16942", "pm_score": 2, "selected": false, "text": "<p>You can call .Dispose() on a class without using a 'using' statement - usually you'll do this in the Dispose method...
2009/01/15
[ "https://Stackoverflow.com/questions/449002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/49632/" ]
I have using blocks in each method of my repository. If I want to cross reference methods, it seems it would be against best practices to initialize another Datacontext What am i doing wrong? If I declare a Datacontext in the class instead of using blocks in methods will I not lose power to dispose ?? ``` public IList...
If you don't use a using statement, you can still dispose explicitly. Even if you don't dispose of the data context though, cross-referencing these methods will still create a new data context. That may or may not be a good thing, depending on your usage. Think about the state management aspect of the data context, and...
449,016
<p>I am trying to use the Office COM components in order to create Word and Excel documents. Unfortunately I can not achieve this because I am getting an error.</p> <blockquote> <p>Cannot find IDispatch for '{00020906-0000-0000-C000-000000000046}' in module '{00020905-0000-0000-C000-000000000046}', v8.3</p>...
[ { "answer_id": 449058, "author": "Dirk Vollmar", "author_id": 40347, "author_profile": "https://Stackoverflow.com/users/40347", "pm_score": 2, "selected": false, "text": "<p>From the error you get I assume that you are using Word 2003. </p>\n\n<p>Have you made sure that the COM brigde se...
2009/01/15
[ "https://Stackoverflow.com/questions/449016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to use the Office COM components in order to create Word and Excel documents. Unfortunately I can not achieve this because I am getting an error. > > Cannot find IDispatch for > '{00020906-0000-0000-C000-000000000046}' > in module > '{00020905-0000-0000-C000-000000000046}', > v8.3 > > > I tried r...
From the error you get I assume that you are using Word 2003. Have you made sure that the COM brigde service is correctly installed and running? ``` combsvc -install combsvc -start ``` will register combsvc as service and then start it. Please also have a look at the example for Word at the bottom of page 150 in ...
449,019
<p>I'm getting the folowing error for below code, "1506-221 (S) Initializer must be a valid constant expression"</p> <pre><code>FILE *fp[] = {stdout, dump_f}; </code></pre> <p>is this acceptable? what is the proper way to achive this?</p>
[ { "answer_id": 449034, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": true, "text": "<p>The error suggests that on your system the <code>stdout</code> variable is in fact a <code>#defined</code> macro which exp...
2009/01/15
[ "https://Stackoverflow.com/questions/449019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51529/" ]
I'm getting the folowing error for below code, "1506-221 (S) Initializer must be a valid constant expression" ``` FILE *fp[] = {stdout, dump_f}; ``` is this acceptable? what is the proper way to achive this?
The error suggests that on your system the `stdout` variable is in fact a `#defined` macro which expands to a function call. Actually, as others have suggested, it's probably just that `stdout` is an extern declared variable whose value is not known at compile time and therefore can't be supplied in a static initializ...
449,020
<p>In XML, how should a list be represented?</p> <p>With an enclosing list entity:</p> <pre><code>&lt;person&gt; &lt;firstname&gt;Joe&lt;/firstname&gt; &lt;lastname&gt;Bloggs&lt;/lastname&gt; &lt;children&gt; &lt;child .../&gt; &lt;child .../&gt; &lt;child .../&gt; &lt;chi...
[ { "answer_id": 449028, "author": "Daniel A. White", "author_id": 23528, "author_profile": "https://Stackoverflow.com/users/23528", "pm_score": 3, "selected": false, "text": "<p>I would enclose it in an entity to distinguish it from the other elements.</p>\n" }, { "answer_id": 449...
2009/01/15
[ "https://Stackoverflow.com/questions/449020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
In XML, how should a list be represented? With an enclosing list entity: ``` <person> <firstname>Joe</firstname> <lastname>Bloggs</lastname> <children> <child .../> <child .../> <child .../> <child .../> <child .../> </children> </person> ``` Or without: ```...
For extensibility, I would use the first solution (the one with the *children* node). If you ever wish to store any data about all of the children then you have a convenient node on which to place attributes.
449,036
<p><strong>Update!</strong></p> <p>Binding works. The issue is that the XpsDocumentWriter doesn't properly write the first page of the first document of a FixedDocumentSequence. This seems to be an issue encountered by lots of people doing this sort of thing (i.e., five developers worldwide). The solution is slight...
[ { "answer_id": 449375, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 0, "selected": false, "text": "<p>One reason that you lose a binding is that you throw an exception somewhere - unfortunately, this exception is silently...
2009/01/15
[ "https://Stackoverflow.com/questions/449036", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
**Update!** Binding works. The issue is that the XpsDocumentWriter doesn't properly write the first page of the first document of a FixedDocumentSequence. This seems to be an issue encountered by lots of people doing this sort of thing (i.e., five developers worldwide). The solution is slightly odd. I include it as an...
The cause of this bug is that the FixedPage's layout isn't being updated prior to writing. This causes the first FixedPage in the first FixedDocument in the FixedDocumentSequence to be written incorrectly. This affects **NO OTHER PAGES IN THE RESULTING DOCUMENT**, which made this bug/edge case harder to nail down. The...
449,055
<p>I want to get a simple Python "hello world" web page script to run on Windows Vista/ Apache but hit different walls. I'm using WAMP. I've installed <code>mod_python</code> and the module shows, but I'm not quite sure what I'm supposed to do in e.g. http.conf (things like AddHandler mod_python .py either bring me to ...
[ { "answer_id": 449120, "author": "Daniel Bruce", "author_id": 6456, "author_profile": "https://Stackoverflow.com/users/6456", "pm_score": 2, "selected": false, "text": "<p>You do not NEED mod_python to run Python code on the web, you could use simple CGI programming to run your python co...
2009/01/16
[ "https://Stackoverflow.com/questions/449055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34170/" ]
I want to get a simple Python "hello world" web page script to run on Windows Vista/ Apache but hit different walls. I'm using WAMP. I've installed `mod_python` and the module shows, but I'm not quite sure what I'm supposed to do in e.g. http.conf (things like AddHandler mod\_python .py either bring me to a file not fo...
Stay away from `mod_python`. One common misleading idea is that `mod_python` is like `mod_php`, but for python. That is not true. [Wsgi](http://wsgi.org) is the standard to run python web applications, defined by [PEP 333](http://www.python.org/dev/peps/pep-0333/). So use [`mod_wsgi`](http://code.google.com/p/modwsgi/)...
449,089
<p>I'd like to have something that looks and behaves as hyperlink inside larger rectangle (full page wide) which is also hyperlink. Below there is ASCII-art representation of what it should look like:</p> <pre> |-------------------------------------------| | Some text [_link_] | |----------...
[ { "answer_id": 449094, "author": "Sampson", "author_id": 54680, "author_profile": "https://Stackoverflow.com/users/54680", "pm_score": 0, "selected": false, "text": "<p>What I have done in the past is use Javascript to attach the proper functionality to the div (assuming that is the pare...
2009/01/16
[ "https://Stackoverflow.com/questions/449089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46058/" ]
I'd like to have something that looks and behaves as hyperlink inside larger rectangle (full page wide) which is also hyperlink. Below there is ASCII-art representation of what it should look like: ``` |-------------------------------------------| | Some text [_link_] | |------------------...
You could try something like this: ```css div.a { position: relative; background-color: #F88; z-index: 0; } a.b { position: relative; z-index: 2; } a.b:hover { background-color: #8F8; } a.c { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; } a.c:h...
449,099
<p>So I came across some code this morning that looked like this:</p> <pre><code>try { x = SomeThingDangerous(); return x; } catch (Exception ex) { throw new DangerousException(ex); } finally { CleanUpDangerousStuff(); } </code></pre> <p>Now this code compiles fine and works as it should, but it just ...
[ { "answer_id": 449102, "author": "Spencer Ruport", "author_id": 52551, "author_profile": "https://Stackoverflow.com/users/52551", "pm_score": 4, "selected": false, "text": "<p>This may answer your question</p>\n\n<p><a href=\"https://stackoverflow.com/questions/421797/what-really-happens...
2009/01/16
[ "https://Stackoverflow.com/questions/449099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/493/" ]
So I came across some code this morning that looked like this: ``` try { x = SomeThingDangerous(); return x; } catch (Exception ex) { throw new DangerousException(ex); } finally { CleanUpDangerousStuff(); } ``` Now this code compiles fine and works as it should, but it just doesn't feel right to retu...
No, it's not a bad practice. Putting `return` where it makes sense improves readability and maintainability and makes your code simpler to understand. You shouldn't care as `finally` block will get executed if a `return` statement is encountered.
449,103
<p>I have a legacy class that the class itself is not a generic but one of its methods return type uses generics:</p> <pre><code>public class Thing { public Collection&lt;String&gt; getStuff() { ... } } </code></pre> <p><code>getStuff()</code> uses generics to return a collection of strings. Therefore I can itera...
[ { "answer_id": 449115, "author": "cletus", "author_id": 18393, "author_profile": "https://Stackoverflow.com/users/18393", "pm_score": 4, "selected": true, "text": "<p>Ok, take two, I misunderstood your question.</p>\n\n<p>When you delcare <code>Thing</code> (this is called a <strong>raw ...
2009/01/16
[ "https://Stackoverflow.com/questions/449103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
I have a legacy class that the class itself is not a generic but one of its methods return type uses generics: ``` public class Thing { public Collection<String> getStuff() { ... } } ``` `getStuff()` uses generics to return a collection of strings. Therefore I can iterate over `getStuff()` and there's no need to...
Ok, take two, I misunderstood your question. When you delcare `Thing` (this is called a **raw type**) instead of `Thing<?>` (**parameterized type**) the Java compiler strips out all generic arguments, even thogh (as in your case) the generic type of the method has nothing to do with the generic type of the class. Fro...