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
264,278
<p>I am developing an Intranet Application in ASP.NET that uses Windows Authentication. I have created an AD class that gets information from the Active Directory Domain Controller. This is what I use to get things like User Groups that the currently logged user is in. The problem is in the ASP.NET Roles that the user ...
[ { "answer_id": 264435, "author": "CPU_BUSY", "author_id": 27688, "author_profile": "https://Stackoverflow.com/users/27688", "pm_score": 0, "selected": false, "text": "<p>You might need to assign the website permissions specifically to the groups you want to enumerate.</p>\n" }, { ...
2008/11/05
[ "https://Stackoverflow.com/questions/264278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am developing an Intranet Application in ASP.NET that uses Windows Authentication. I have created an AD class that gets information from the Active Directory Domain Controller. This is what I use to get things like User Groups that the currently logged user is in. The problem is in the ASP.NET Roles that the user is ...
Part of your result is because some of the groups the user belongs to are members of other groups. The full list of a user's groups will include all groups the user belongs to, both directly and via membership in other groups who are also members. The list will also include built-in groups that are normally hidden fr...
264,281
<p>Is there a way (in C#) to access the systray? I am not talking about making a notify icon. I want to iterate through the items in the tray (I would guess through the processes but I don't know how to determine what is actually in the tray and what is just a process) and also represent the items with their icons in m...
[ { "answer_id": 264341, "author": "Hugh Allen", "author_id": 15069, "author_profile": "https://Stackoverflow.com/users/15069", "pm_score": 1, "selected": false, "text": "<p>Mathias Rauen's madCollection (for Delphi not c#) can list <a href=\"http://help.madshi.net/TrayIcons.htm\" rel=\"no...
2008/11/05
[ "https://Stackoverflow.com/questions/264281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34514/" ]
Is there a way (in C#) to access the systray? I am not talking about making a notify icon. I want to iterate through the items in the tray (I would guess through the processes but I don't know how to determine what is actually in the tray and what is just a process) and also represent the items with their icons in my o...
How do you feel about Win32 interop? I found [C/Win32 code](http://skyscraper.fortunecity.com/gigo/311/winprog/shellico.txt "this C/Win32 code") that might do the trick for you. (Actually, it looks like an interesting problem so I might try to tackle it myself, just not now). The magic appears to be that he gets a han...
264,309
<p>There is a similar question going around, but it just got the same old answers that people always give about Regex syntax, but that's not the point here, so please try to not knee jerk the same old answers about regex syntax. Try to be a little more original and personal about it this time.</p> <p>Regex syntax is v...
[ { "answer_id": 264314, "author": "Frederic Morin", "author_id": 4064, "author_profile": "https://Stackoverflow.com/users/4064", "pm_score": 3, "selected": false, "text": "<p>Another problem with regex is that there are many flavours of it. .Net regex vs php regex vs other regex, all look...
2008/11/05
[ "https://Stackoverflow.com/questions/264309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15124/" ]
There is a similar question going around, but it just got the same old answers that people always give about Regex syntax, but that's not the point here, so please try to not knee jerk the same old answers about regex syntax. Try to be a little more original and personal about it this time. Regex syntax is very VERY c...
Most of what I have to say were addressed by Adam and DGM, but I don't think they cover your second point very well. "how about all the very easy to understand, non compact, non cryptic and dare I say pretty domain languages out there like SQL or LINQ?" I think a good way to express an answer to this is to ask, how w...
264,312
<p>I'm trying to squeeze some more performance out of my rendering pipeline. The (by far) slowest part is performing a java.awt.imaging.LookupOp on a large image. </p> <p>The image size is about 2048x2048.</p> <p>I have figured out that having the filter done along with the drawing operation is much faster than cal...
[ { "answer_id": 272256, "author": "Ryan Boucher", "author_id": 27818, "author_profile": "https://Stackoverflow.com/users/27818", "pm_score": 1, "selected": false, "text": "<p>I've not used java in close to eight years so some of the syntax may be irrelevant.</p>\n\n<p>The key to any kind ...
2008/11/05
[ "https://Stackoverflow.com/questions/264312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25920/" ]
I'm trying to squeeze some more performance out of my rendering pipeline. The (by far) slowest part is performing a java.awt.imaging.LookupOp on a large image. The image size is about 2048x2048. I have figured out that having the filter done along with the drawing operation is much faster than calling the filter met...
I've not used java in close to eight years so some of the syntax may be irrelevant. The key to any kind of performance regarding a loop is to push as many things as possible outside the loop. If you can't then only perform calculations when they change. Often it is better to wait until the last minute to recalculate s...
264,318
<p>I am calling an unmanaged C++ dll that expects a char* as one of its parameters and I want to push a byte[] into it. The project is written in VB.NET. </p> <p>What type of marshalling will work for this?</p>
[ { "answer_id": 264365, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I'm not a .net expert, but I've needed to do something similar recently.</p>\n\n<p>It is not just a matter of serialization...
2008/11/05
[ "https://Stackoverflow.com/questions/264318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34550/" ]
I am calling an unmanaged C++ dll that expects a char\* as one of its parameters and I want to push a byte[] into it. The project is written in VB.NET. What type of marshalling will work for this?
If you need to pin a managed structure in order to pass it as a parameter you can use the following code. ``` // (c) 2007 Marc Clifton /// <summary> /// A helper class for pinning a managed structure so that it is suitable for /// unmanaged calls. A pinned object will not be collected and will not be m...
264,323
<p>Is there a way to delete a folder, lets call it FolderX from an SVN trunk recursively? A quick search on google only tells me how to recursively delete all .svn folders and this is not what I want to do</p>
[ { "answer_id": 264345, "author": "Dana the Sane", "author_id": 2567, "author_profile": "https://Stackoverflow.com/users/2567", "pm_score": 6, "selected": true, "text": "<p>Try something like the following on a posix system:</p>\n\n<pre><code>find ./ -name \"FolderX\" | xargs svn delete -...
2008/11/05
[ "https://Stackoverflow.com/questions/264323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
Is there a way to delete a folder, lets call it FolderX from an SVN trunk recursively? A quick search on google only tells me how to recursively delete all .svn folders and this is not what I want to do
Try something like the following on a posix system: ``` find ./ -name "FolderX" | xargs svn delete --force ``` This will find all matching files/folders starting in the current directory and perform the action on them i.e. svn delete. I'm not sure how to do this in windows though without cygwin. For win32, the comm...
264,339
<p>I'm not sure how to describe this problem, so I think an example is the best way to ask my question:</p> <p>I have two tables with a manyToMany relationship:</p> <p>DriversLicence &lt;-> LicenceClass</p> <p>LicenceClass is things like "Car", "Motorbike", and "Medium Rigid".</p> <p>Using Hibernate Criteria, how c...
[ { "answer_id": 264420, "author": "Nick", "author_id": 34558, "author_profile": "https://Stackoverflow.com/users/34558", "pm_score": 0, "selected": false, "text": "<p>You can still use dot notation to work across the relations. For example, assuming you have a DriversLicence.licenceClass...
2008/11/05
[ "https://Stackoverflow.com/questions/264339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34553/" ]
I'm not sure how to describe this problem, so I think an example is the best way to ask my question: I have two tables with a manyToMany relationship: DriversLicence <-> LicenceClass LicenceClass is things like "Car", "Motorbike", and "Medium Rigid". Using Hibernate Criteria, how can I find all licences that have b...
Here's how I finally achieved it using HQL: ``` public List<DriversLicence> findDriversLicencesWith(List<LicenceClass> licenceClasses) { String hqlString = "select dl from DriversLicenceImpl dl where 1=1 "; for (int i = 0; i < licenceClasses.size(); i++) { hqlString += " and :licenceClass" + i + " = so...
264,350
<p>In traditional embedded programming, we will give a delay function like so:</p> <pre><code>for(i=0;i&lt;255;i++) for(j=0;j&lt;255;j++); </code></pre> <p>In the microprocessor's view, is this how the sleep() function works?</p> <p>Is there an alternative for the sleep() function in C?</p>
[ { "answer_id": 264353, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 5, "selected": false, "text": "<p>The kind of loop you describe is called a \"busy wait\". In real operating systems, sleeping does not cause a busy wait; ...
2008/11/05
[ "https://Stackoverflow.com/questions/264350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
In traditional embedded programming, we will give a delay function like so: ``` for(i=0;i<255;i++) for(j=0;j<255;j++); ``` In the microprocessor's view, is this how the sleep() function works? Is there an alternative for the sleep() function in C?
Alternatives depend in what you are trying to do and what OS you are on. If you just want to waste time, then these might help: On most unix-type systems you'll find a 'usleep' function, which is more or less like sleep with greater resolution. Be careful with that one because it usually can not sleep for just one mi...
264,358
<p>let us have a situation in which the following program prints some 10 lines of #</p> <pre><code>for(i=0;i&lt;10;i++) prinf("\n#"); </code></pre> <p>now how to go back to 5 th line and edit that # and change the color of it without clearing the screen or clearing the below 5 lines? <p>I have tried </p> <pre><code>...
[ { "answer_id": 264371, "author": "shoosh", "author_id": 9611, "author_profile": "https://Stackoverflow.com/users/9611", "pm_score": 0, "selected": false, "text": "<p>maybe- </p>\n\n<pre><code>cprintf(\"\\b#\");\n</code></pre>\n\n<p>'b' is for backspace</p>\n" }, { "answer_id": 2...
2008/11/05
[ "https://Stackoverflow.com/questions/264358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31116/" ]
let us have a situation in which the following program prints some 10 lines of # ``` for(i=0;i<10;i++) prinf("\n#"); ``` now how to go back to 5 th line and edit that # and change the color of it without clearing the screen or clearing the below 5 lines? I have tried ``` window(5,0,20,20); textcolor(GREEN); cprint...
window function will generally create a window from the 1st two coordinates pixel i.e, in your example (5,0) to the pixel pointed by next 2 coordinates. so your program should work try it out or else use gotoxy()
264,381
<p>I'm doing some searching of tags, and some users like "cat" while others like "Cat" Go figure...</p> <p>Anyways, is there a way to force a particular find to be case sensitive? Such as:</p> <pre><code>Tag.find(:some-special-option-here) </code></pre> <p>Any ideas?</p>
[ { "answer_id": 264389, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>In the mysql database, set your text's data type to utf_collate_bin. For example:</p>\n\n<pre><code>ALTER TABLE `sets` CHAN...
2008/11/05
[ "https://Stackoverflow.com/questions/264381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19964/" ]
I'm doing some searching of tags, and some users like "cat" while others like "Cat" Go figure... Anyways, is there a way to force a particular find to be case sensitive? Such as: ``` Tag.find(:some-special-option-here) ``` Any ideas?
You can also do a case-sensitive search without changing your column properties. ``` SELECT * FROM mytable WHERE myfield='Value' ``` This query matches: * Value * value * VALUE * vAlUe * *and so on* While... ``` SELECT * FROM mytable WHERE BINARY myfield='Value' ``` Matches only: * Value
264,395
<p>I've found the "open" command in Mac OS X very handy in the command line. From "man open":</p> <blockquote> <p>The <code>open</code> command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determin...
[ { "answer_id": 264401, "author": "number5", "author_id": 29489, "author_profile": "https://Stackoverflow.com/users/29489", "pm_score": 9, "selected": true, "text": "<p>You could try <code>xdg-open</code>, most Linux distros have it. It will open default associated app for your file.</p>\...
2008/11/05
[ "https://Stackoverflow.com/questions/264395", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've found the "open" command in Mac OS X very handy in the command line. From "man open": > > The `open` command opens a file (or a directory or URL), just as if you had > double-clicked the file's icon. If no application name is specified, the > default application as determined via LaunchServices is used to open...
You could try `xdg-open`, most Linux distros have it. It will open default associated app for your file. FYI <https://portland.freedesktop.org/doc/xdg-open.html>
264,400
<p>I am trying to do the following in ASP.NET 3.5. Basically, I am binding a LINQDataSource to a DataList. There is a property called "Deleted" and if it is true, I want to display different markup. The following code throws errors:</p> <pre><code>&lt;asp:DataList runat="server"&gt; &lt;ItemTemplate&gt; ...
[ { "answer_id": 264427, "author": "Ta01", "author_id": 7280, "author_profile": "https://Stackoverflow.com/users/7280", "pm_score": 2, "selected": true, "text": "<p>Why not just use the RowDataBound event and check the value of your fields then? RowDatabound is ideal for these situations w...
2008/11/05
[ "https://Stackoverflow.com/questions/264400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40/" ]
I am trying to do the following in ASP.NET 3.5. Basically, I am binding a LINQDataSource to a DataList. There is a property called "Deleted" and if it is true, I want to display different markup. The following code throws errors: ``` <asp:DataList runat="server"> <ItemTemplate> <% If CBool(Eval("Deleted"))...
Why not just use the RowDataBound event and check the value of your fields then? RowDatabound is ideal for these situations where you want to alter data in a gridview based on values in the result set. [RowDataBound Event from MSDN](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdataboun...
264,402
<p>I have used this in my HTML:</p> <pre><code>&lt;q&gt; Hai How r u &lt;/q&gt; </code></pre> <p>Which shows the text in quotes, like "Hai How r u", for example.</p> <p>This is working fine in FF but not in IE 6.0.</p> <p>Please let me know why this happens, and any solutions you might know of. </p> <p>I don't wan...
[ { "answer_id": 264405, "author": "Karan", "author_id": 11110, "author_profile": "https://Stackoverflow.com/users/11110", "pm_score": 0, "selected": false, "text": "<p>Why don't you just use the <code>\"</code> characters? Unlike <code>&lt;b&gt;</code> and <code>&lt;i&gt;</code> which sho...
2008/11/05
[ "https://Stackoverflow.com/questions/264402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I have used this in my HTML: ``` <q> Hai How r u </q> ``` Which shows the text in quotes, like "Hai How r u", for example. This is working fine in FF but not in IE 6.0. Please let me know why this happens, and any solutions you might know of. I don't want to use the quote (") character in my HTML or a separate c...
A List Apart had a whole article devoted to the `<q>` tag: [Long Live The Q Tag](http://www.alistapart.com/articles/qtag) The summary is to add CSS to *remove* the quotes from Firefox and other browsers and then manually encode them in yourself. It's a bit of a pain, but at least it levels the playing field and you...
264,414
<p>I've got a Repeater and its SqlDatasource nested inside a Gridview TemplatedField.<br> The Repeater's datasource SelectCommand is set using the FormatString of an Eval from the Gridview.<br> The SelectCommand has a WHERE clause which is to compare a string.<br> Because I have already used the single and double quote...
[ { "answer_id": 264426, "author": "Ty.", "author_id": 16948, "author_profile": "https://Stackoverflow.com/users/16948", "pm_score": 0, "selected": false, "text": "<p>Have you tried escaping the single quote characters?</p>\n\n<pre><code>... WHERE (StringField = \\'{0}\\') ...\n</code></pr...
2008/11/05
[ "https://Stackoverflow.com/questions/264414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/242/" ]
I've got a Repeater and its SqlDatasource nested inside a Gridview TemplatedField. The Repeater's datasource SelectCommand is set using the FormatString of an Eval from the Gridview. The SelectCommand has a WHERE clause which is to compare a string. Because I have already used the single and double quotes, I a...
Don't forget that a .aspx page is simply XML. You just escape the quotes as you normally would. For example: ``` <asp:Repeater ID="repeatTheLabel" runat="server"> <ItemTemplate> <asp:Label ID="Label1" Text="<%# Eval(&quot;Id&quot;, &quot;This is item '{0}'.&quot;) %>" runat="server" /> </ItemTemplate>...
264,428
<p>I am using BSD style pty/tty pairs to implement running a sub shell. When the user exits the sub shell, how do I detect in the master process that this has occurred? I am using select(nfds, &amp;read_fds, NULL, NULL, &amp;timeout); with the master pty file descriptor set in the read_fds on the master side.</p>
[ { "answer_id": 264449, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 2, "selected": false, "text": "<p>The subshell is typically created by a <code>fork()</code> of some sort. The PID of the child is returned to the mas...
2008/11/05
[ "https://Stackoverflow.com/questions/264428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20889/" ]
I am using BSD style pty/tty pairs to implement running a sub shell. When the user exits the sub shell, how do I detect in the master process that this has occurred? I am using select(nfds, &read\_fds, NULL, NULL, &timeout); with the master pty file descriptor set in the read\_fds on the master side.
I've found the answer to this question by examining the telnetd source code found in the GNU inetutils package. In telnetd, they use a SIGCHLD handler like this: ``` int status; pid_t pid = waitpid((pid_t)-1, &status, WNOHANG); syslog (LOG_INFO, "child process %ld exited: %d", (long) pid, WEXITSTATUS(status)); // ...
264,441
<pre><code>function array_value_from_key($array,$key) { return !empty($array[$key]) ? $array[$key] : null; } </code></pre> <p>The reason I ask is because I have a class function that returns an array.</p> <p>Instead of having to do</p> <pre><code>$myArray = myClass::giveMeArray(); $myValue = $myArray[$myKey]; <...
[ { "answer_id": 264465, "author": "Jason", "author_id": 33975, "author_profile": "https://Stackoverflow.com/users/33975", "pm_score": 1, "selected": false, "text": "<p>I haven't tried it, but:</p>\n\n<pre><code>$myValue = @$myArray[$myKey];\n</code></pre>\n\n<p>might work, though i honest...
2008/11/05
[ "https://Stackoverflow.com/questions/264441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34561/" ]
``` function array_value_from_key($array,$key) { return !empty($array[$key]) ? $array[$key] : null; } ``` The reason I ask is because I have a class function that returns an array. Instead of having to do ``` $myArray = myClass::giveMeArray(); $myValue = $myArray[$myKey]; ``` I'd like to do something along t...
I haven't tried it, but: ``` $myValue = @$myArray[$myKey]; ``` might work, though i honestly think you would be better off using ``` $myValue = (array_key_exists($myKey, $myArray)) ? $myArray[$myKey] : null; ```
264,480
<p>My php is weak and I'm trying to change this string:</p> <pre><code>http://www.example.com/backend.php?/c=crud&amp;m=index&amp;t=care ^ </code></pre> <p>to be:</p> <pre><code>http://www.example.com/backend.php?c=crud&amp;m=index&amp;t=care ^ </c...
[ { "answer_id": 264485, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 3, "selected": false, "text": "<pre><code>$str = preg_replace('/\\?\\//', '?', $str);\n</code></pre>\n\n<p>Edit: See CMS' answer. It's late, I sho...
2008/11/05
[ "https://Stackoverflow.com/questions/264480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34571/" ]
My php is weak and I'm trying to change this string: ``` http://www.example.com/backend.php?/c=crud&m=index&t=care ^ ``` to be: ``` http://www.example.com/backend.php?c=crud&m=index&t=care ^ ``` removing the `/` after the `backend.php?`. Any ide...
I think that it's better to use simply [str\_replace](http://www.php.net/str_replace), like the manual says: > > If you don't need fancy replacing > rules (like regular expressions), you > should always use this function > instead of ereg\_replace() or > preg\_replace(). > > > ``` <? $badUrl = "http://www.sit...
264,482
<p>I am not able to access localhost https pages in firefox3. It gave the error </p> <blockquote> <p>'Can't connect securely because the SSL protocol has been disabled. (Error code: ssl_error_ssl_disabled)'</p> </blockquote> <p>I enabled all the SSL2 related preferences through about:config and the error changed ...
[ { "answer_id": 264485, "author": "eyelidlessness", "author_id": 17964, "author_profile": "https://Stackoverflow.com/users/17964", "pm_score": 3, "selected": false, "text": "<pre><code>$str = preg_replace('/\\?\\//', '?', $str);\n</code></pre>\n\n<p>Edit: See CMS' answer. It's late, I sho...
2008/11/05
[ "https://Stackoverflow.com/questions/264482", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16488/" ]
I am not able to access localhost https pages in firefox3. It gave the error > > 'Can't connect securely because the SSL protocol has been disabled. > (Error code: ssl\_error\_ssl\_disabled)' > > > I enabled all the SSL2 related preferences through about:config and the error changed to > > 'Data Transfer Err...
I think that it's better to use simply [str\_replace](http://www.php.net/str_replace), like the manual says: > > If you don't need fancy replacing > rules (like regular expressions), you > should always use this function > instead of ereg\_replace() or > preg\_replace(). > > > ``` <? $badUrl = "http://www.sit...
264,530
<p>I need to find two adjacent repeating digits in a string and replace with a single one. How to do this in Java. Some examples:</p> <p>123345 should be 12345 77433211 should be 74321</p>
[ { "answer_id": 264543, "author": "Jake", "author_id": 24730, "author_profile": "https://Stackoverflow.com/users/24730", "pm_score": 0, "selected": false, "text": "<p>using a regex:</p>\n\n<pre><code>var myString='123345'\nmyString.replace(/([0-9])\\1/g,'$1')\n</code></pre>\n\n<p>that wil...
2008/11/05
[ "https://Stackoverflow.com/questions/264530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
I need to find two adjacent repeating digits in a string and replace with a single one. How to do this in Java. Some examples: 123345 should be 12345 77433211 should be 74321
Probably a `replaceAll("(\\d)\\1+", "$1")` * `$` plays a special role in a replacing string, designating the first capturing group. * `+` allows for replacing as many identical number as possible `(\\d)\\1` would only replace them by pair: `777xx` => `77xx` (thank you [Ben Doom](https://stackoverflow.com/users/12267/b...
264,541
<p>Is there such a thing? </p> <p>I'm talking about something like a C++ <code>new</code> command i.e. allocation of memory which necessitates explicit releasing of the memory (or risk memory leaks).</p> <p>I ask because I remember having to solve some GDI leak problems previously by setting forms/controls/other obje...
[ { "answer_id": 264608, "author": "Martin", "author_id": 1529, "author_profile": "https://Stackoverflow.com/users/1529", "pm_score": 2, "selected": false, "text": "<p>I'd like to say you never have to worry about memory management, but it's not quite true. It depends to some extent on th...
2008/11/05
[ "https://Stackoverflow.com/questions/264541", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4368/" ]
Is there such a thing? I'm talking about something like a C++ `new` command i.e. allocation of memory which necessitates explicit releasing of the memory (or risk memory leaks). I ask because I remember having to solve some GDI leak problems previously by setting forms/controls/other objects to `Nothing` but can't r...
There are several areas of concern as far as Memory management in VB6. The first are circular references where a child class points back to a parent and vice versa. Without explicitly setting the reference to Nothing, This is sometimes true of forms as well especially a dialog that is an editor for a Target object. Ag...
264,552
<p>I have a big lump of binary data in a char[] array which I need to interpret as an array of packed 6-bit values.</p> <p>I <em>could</em> sit down and write some code to do this but I'm thinking there has to be a good extant class or function somebody has written already.</p> <p>What I need is something like:</p> ...
[ { "answer_id": 264574, "author": "Igor Semenov", "author_id": 11401, "author_profile": "https://Stackoverflow.com/users/11401", "pm_score": 3, "selected": false, "text": "<p><a href=\"http://www.boost.org/doc/libs/release/libs/dynamic_bitset/dynamic_bitset.html\" rel=\"nofollow noreferre...
2008/11/05
[ "https://Stackoverflow.com/questions/264552", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2994/" ]
I have a big lump of binary data in a char[] array which I need to interpret as an array of packed 6-bit values. I *could* sit down and write some code to do this but I'm thinking there has to be a good extant class or function somebody has written already. What I need is something like: ``` int get_bits(char* data,...
This may not work for sizes greater than 8, depending on endian system. It's basically what Marco posted, though I'm not entirely sure why he'd gather one bit at a time. ``` int get_bits(char* data, unsigned int bitOffset, unsigned int numBits) { numBits = pow(2,numBits) - 1; //this will only work up to 32 bits, o...
264,575
<p>Here is my sample code. It is meant to be an iterative procedure for gauss seidel (matrix solver). Essentially when the error is small enough it breaks out of the while loop.</p> <pre><code>i=1 while (i&gt;0): x_past = x_present j=0 while(j&lt;3): value=0 k=0 while(k&lt;3): ...
[ { "answer_id": 264579, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>What are x_past and x_present? I don't know much Python, but from a .NET/Java perspective, if they're references to s...
2008/11/05
[ "https://Stackoverflow.com/questions/264575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/338360/" ]
Here is my sample code. It is meant to be an iterative procedure for gauss seidel (matrix solver). Essentially when the error is small enough it breaks out of the while loop. ``` i=1 while (i>0): x_past = x_present j=0 while(j<3): value=0 k=0 while(k<3): if(k!=j): ...
Yes, I think the answers here show your problem. Just to try and clarify a little bit. You're referencing a list, so when the list changes any reference to that list will reflect that change. To demonstrate: ``` >>> x_present = [4,5,6] >>> >>> x_past = x_present >>> >>> x_past [4, 5, 6] >>> >>> x_present.append(7) >>...
264,596
<p>I'm trying to deserialize an xml structure that looks like this:</p> <pre><code>&lt;somecontainer&gt; &lt;key1&gt;Value1&lt;/key1&gt; &lt;key1&gt;Value2&lt;/key1&gt; &lt;key2&gt;Value3&lt;/key2&gt; &lt;key2&gt;Value4&lt;/key2&gt; &lt;/somecontainer&gt; </code></pre> <p>I can basically choose what k...
[ { "answer_id": 264591, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 6, "selected": true, "text": "<p>Edit (Aug. 2012):</p>\n<p>It turns out that currently the best solution are probably Guava 13.0's <code>Cache</code> classes,...
2008/11/05
[ "https://Stackoverflow.com/questions/264596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23691/" ]
I'm trying to deserialize an xml structure that looks like this: ``` <somecontainer> <key1>Value1</key1> <key1>Value2</key1> <key2>Value3</key2> <key2>Value4</key2> </somecontainer> ``` I can basically choose what kind if element to deserialize to, maybe something like a List of Pair or something. Th...
Edit (Aug. 2012): It turns out that currently the best solution are probably Guava 13.0's `Cache` classes, explained on [Guava's Wiki](https://github.com/google/guava/wiki/CachesExplained) - that's what I'm going to use. It even supports building a `SoftHashMap` (see `CacheBuilder.newBuilder().softKeys()`), but it is ...
264,623
<p>Throughout or C# sourcecode we have a lot of comments that miss the actual content such like this:</p> <pre><code>/// &lt;summary&gt; /// &lt;/summary&gt; </code></pre> <p>or this:</p> <pre><code>/// &lt;summary&gt; /// /// &lt;/summary&gt; </code></pre> <p>or this:</p> <pre><code>/// &lt;param Name="flag"&gt;&...
[ { "answer_id": 264630, "author": "bob", "author_id": 23805, "author_profile": "https://Stackoverflow.com/users/23805", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://en.wikipedia.org/wiki/FxCop\" rel=\"nofollow noreferrer\">FxCop</a> and a custom rule?</p>\n" }, { ...
2008/11/05
[ "https://Stackoverflow.com/questions/264623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4227/" ]
Throughout or C# sourcecode we have a lot of comments that miss the actual content such like this: ``` /// <summary> /// </summary> ``` or this: ``` /// <summary> /// /// </summary> ``` or this: ``` /// <param Name="flag"></param> ``` Unfortunately Visual Studio does not generate warnings for this type of miss...
ReSharper is the answer to this (as many other) shortcoming of Visual Studio. I have nothing but pity for anyone who does not use it. ;)
264,626
<p>I can't seem to get Javascript debugging working for my ASP.NET MVC application even though I can for a traditional ASP.NET WebForm app.</p> <p>I have followed the steps for unchecking the 'Disable Script Debugging' boxes for both IE and other.</p> <p>when I add a simple function to display an alert in both the si...
[ { "answer_id": 265170, "author": "user34280", "author_id": 34280, "author_profile": "https://Stackoverflow.com/users/34280", "pm_score": -1, "selected": false, "text": "<p>I don't use VS.Net Express, but in VS.Net Standard you can go to the Debug menu in your solution and choose \"Attach...
2008/11/05
[ "https://Stackoverflow.com/questions/264626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5132/" ]
I can't seem to get Javascript debugging working for my ASP.NET MVC application even though I can for a traditional ASP.NET WebForm app. I have followed the steps for unchecking the 'Disable Script Debugging' boxes for both IE and other. when I add a simple function to display an alert in both the site.master and any...
``` function test() { debugger; alert("hi"); } ``` I don't know if it will work with express, but when IE hits the "debugger" instruction, it asks me if I want to debug, and with wich tool. Visual studio is present in the list of options presented to me. I don't know if express will be present for you though. "...
264,642
<p>Is it possible to fork a users session (or do something similar) in a Internet Explorer plugin?</p> <p>I want to process the page the user is on when they click a button in the toolbar. To avoid interrupting the users browsing, I'd like to &quot;copy&quot; everything so I can parse and process the page in the backgr...
[ { "answer_id": 287080, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 0, "selected": false, "text": "<p>Interesting thought. Could you copy the DOM holus-bolus and then replace a new window's DOM with the copy. It's just a gu...
2008/11/05
[ "https://Stackoverflow.com/questions/264642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1555170/" ]
Is it possible to fork a users session (or do something similar) in a Internet Explorer plugin? I want to process the page the user is on when they click a button in the toolbar. To avoid interrupting the users browsing, I'd like to "copy" everything so I can parse and process the page in the background. The processin...
A BHO or plugin would work. There are so many options to get the source, it's kinda. pick your poising. Look up IDocHostUIHandler to alter behaviour. IHTMLElementCollection to parse the page in browser. The easiest thing I can think of at the moment is.... Save the current contents to a stream. same as get/view sourc...
264,656
<p><code>getopt()</code> is not behaving as I expect for short options.</p> <p>eg: Invoking the below program with a missing parameter:</p> <p>Valid Case: <code>testopt -d dir -a action -b build</code></p> <p>Error Case: <code>testopt -d -a action -b build</code></p> <p>This did not throw any error as I was expecti...
[ { "answer_id": 264665, "author": "unwind", "author_id": 28169, "author_profile": "https://Stackoverflow.com/users/28169", "pm_score": 0, "selected": false, "text": "<p>According to <a href=\"http://www.gnu.org/software/libtool/manual/libc/Using-Getopt.html#Using-Getopt\" rel=\"nofollow n...
2008/11/05
[ "https://Stackoverflow.com/questions/264656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18657/" ]
`getopt()` is not behaving as I expect for short options. eg: Invoking the below program with a missing parameter: Valid Case: `testopt -d dir -a action -b build` Error Case: `testopt -d -a action -b build` This did not throw any error as I was expecting an error message operand missing for `-d` * Is this a known ...
`getopt()` thinks `-a` is an argument for `-d`, not an option. Try `testopt -a action -b build -d` - it should complain about missing argument. You need to check for `-d` option (and all other options) that `optarg` has valid value - the one without dash in the beginning.
264,676
<p>Is this possible? I had troubles with SVN clients not being able to access the repository with the following error message:</p> <blockquote> <p>Repository moved permanently to '<a href="http://svn.example.com/test/" rel="noreferrer">http://svn.example.com/test/</a>'; please relocate</p> </blockquote> <p>If I add...
[ { "answer_id": 266987, "author": "Matthew Scharley", "author_id": 15537, "author_profile": "https://Stackoverflow.com/users/15537", "pm_score": 1, "selected": false, "text": "<p>I ended up using mod_rewrite succesfully to rewrite all access to the root directory into <code>/svn</code>, h...
2008/11/05
[ "https://Stackoverflow.com/questions/264676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15537/" ]
Is this possible? I had troubles with SVN clients not being able to access the repository with the following error message: > > Repository moved permanently to '<http://svn.example.com/test/>'; please relocate > > > If I added the '/' to the end of the path I was trying to access, it just strips it off again, and...
The problem is that you are using the document root also as the repository root (I'm not blaming you, this should just work, but it doesn't). Try pointing the `DocumentRoot` and `SVNParentPath` directives to different physical locations, so the resulting config file should look like this (abbreviated): ``` <VirtualHo...
264,680
<p>I have a bunch of JUnit 3 classes which extend TestCase and would like to automatically migrate them to be JUnit4 tests with annotations such as <code>@Before</code>, <code>@After</code>, <code>@Test</code>, etc.<br> Any tool out there to do this in a big batch run?</p>
[ { "answer_id": 264749, "author": "Gary", "author_id": 396747, "author_profile": "https://Stackoverflow.com/users/396747", "pm_score": 2, "selected": false, "text": "<p>I don't know of a tool that would do this at the moment - I'd expect Eclipse to provide some plugin fairly shortly - but...
2008/11/05
[ "https://Stackoverflow.com/questions/264680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6583/" ]
I have a bunch of JUnit 3 classes which extend TestCase and would like to automatically migrate them to be JUnit4 tests with annotations such as `@Before`, `@After`, `@Test`, etc. Any tool out there to do this in a big batch run?
In my opinion, it cannot be that hard. So let's try it: 0. Imports ---------- You need to import three annotations: ``` import org.junit.After; import org.junit.Before; import org.junit.Test;` ``` After you've made the next few changes, you won't need `import junit.framework.TestCase;`. 1. Annotate `test*` Method...
264,685
<p>In CSS, with:</p> <pre><code>@page { @top-right { content: "Page " counter(page) " of " counter(pages); } } </code></pre> <p>I can have page numbers displayed at the top of every page when the page is printed. This works great. But now, how can I make it so the page number starts with 2 instead of 1? Can I do that...
[ { "answer_id": 264706, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": -1, "selected": false, "text": "<p>Don't know if this works, but why don't you try <code>counter(page+1)</code>?</p>\n" }, { "answer_id": 275099, ...
2008/11/05
[ "https://Stackoverflow.com/questions/264685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5295/" ]
In CSS, with: ``` @page { @top-right { content: "Page " counter(page) " of " counter(pages); } } ``` I can have page numbers displayed at the top of every page when the page is printed. This works great. But now, how can I make it so the page number starts with 2 instead of 1? Can I do that by modifying the CSS rule...
If you are using Flying Saucer (which was my case), use the following CSS: > > table { -fs-table-paginate: paginate; } > > > It works like a charm. And Flying Saucer rocks :). Really highly recommended.
264,689
<p>So I want to trigger an event (pausing/unpausing some media) whenever the user presses spacebar anywhere in the my Swing app.</p> <p>Since there are so many controls and panels that could have focus, its not really possible to add keyevents to them all(not to mention gross).</p> <p>So I found </p> <pre><code>Key...
[ { "answer_id": 264703, "author": "Michael Neale", "author_id": 699, "author_profile": "https://Stackoverflow.com/users/699", "pm_score": 3, "selected": true, "text": "<p>I think you answered that yourself - yes I think you can find out the current element that has focus, and if it is an ...
2008/11/05
[ "https://Stackoverflow.com/questions/264689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16925/" ]
So I want to trigger an event (pausing/unpausing some media) whenever the user presses spacebar anywhere in the my Swing app. Since there are so many controls and panels that could have focus, its not really possible to add keyevents to them all(not to mention gross). So I found ``` KeyboardFocusManager.getCurrentK...
I think you answered that yourself - yes I think you can find out the current element that has focus, and if it is an instanceof a certain field class, you ignore the space for the purpose of pause event. If it seams heavy handed, don't worry, instanceof is VERY fast for the JVM (and in any cause you are talking human ...
264,714
<p>I am trying to use a business object that I am passing to the report.rdlc. The properties in my object are not directly exposed. The properties I require are embedded within another object inside the top level object. As this is a WCF project I can't control what goes on at the server end. I am just able to request ...
[ { "answer_id": 265685, "author": "jezell", "author_id": 27453, "author_profile": "https://Stackoverflow.com/users/27453", "pm_score": 0, "selected": false, "text": "<p>If you set the data source to the CustomerInfo instance (or list) returned from the service it should work. The ReportVi...
2008/11/05
[ "https://Stackoverflow.com/questions/264714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34628/" ]
I am trying to use a business object that I am passing to the report.rdlc. The properties in my object are not directly exposed. The properties I require are embedded within another object inside the top level object. As this is a WCF project I can't control what goes on at the server end. I am just able to request the...
The problem was that the info wasn't at the root level. I worked it out though. ``` =First(Fields!ClientName.Value.StringValue, "BusinessObject_CustomerInfo") ``` I've got a pretty good grip of the ReportViewer component now cheers.
264,720
<p>I am using a GDI+ Graphic to draw a 4000*3000 image to screen, but it is really slow. It takes about 300ms. I wish it just occupy less than 10ms.</p> <pre><code>Bitmap *bitmap = Bitmap::FromFile("XXXX",...); </code></pre> <p>//-------------------------------------------- // this part takes about 300ms, terrible!</...
[ { "answer_id": 264818, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 3, "selected": true, "text": "<p>You have a screen of 4000 x 3000 resolution? Wow!</p>\n\n<p>If not, you should draw only the visible part of the image, i...
2008/11/05
[ "https://Stackoverflow.com/questions/264720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
I am using a GDI+ Graphic to draw a 4000\*3000 image to screen, but it is really slow. It takes about 300ms. I wish it just occupy less than 10ms. ``` Bitmap *bitmap = Bitmap::FromFile("XXXX",...); ``` //-------------------------------------------- // this part takes about 300ms, terrible! ``` int width = bitmap->G...
You have a screen of 4000 x 3000 resolution? Wow! If not, you should draw only the visible part of the image, it would be much faster... [EDIT after first comment] My remark is indeed a bit stupid, I suppose DrawImage will mask/skip unneeded pixels. After your edit (showing StretchDIBits), I guess a possible source ...
264,745
<p>Imagine the following</p> <p>A type T has a field Company. When executing the following method it works perfectly:</p> <pre><code>Type t = typeof(T); t.GetProperty("Company") </code></pre> <p>Whith the following call I get null though</p> <pre><code>Type t = typeof(T); t.GetProperty("company", BindingFlags.Ignor...
[ { "answer_id": 264748, "author": "leppie", "author_id": 15541, "author_profile": "https://Stackoverflow.com/users/15541", "pm_score": 6, "selected": false, "text": "<p>You need to add <code>BindingFlags.Public | BindingFlags.Instance</code></p>\n" }, { "answer_id": 264752, "a...
2008/11/05
[ "https://Stackoverflow.com/questions/264745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11333/" ]
Imagine the following A type T has a field Company. When executing the following method it works perfectly: ``` Type t = typeof(T); t.GetProperty("Company") ``` Whith the following call I get null though ``` Type t = typeof(T); t.GetProperty("company", BindingFlags.IgnoreCase) ``` Anybody got an idea?
You've overwritten the default look-up flags, if you specify new flags you need to provide all the info so that the property can be found. For example: `BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance`
264,763
<p>I am using msbuild to build a C++ project and I want to suppress the 'Post-Build Event'. I have tried the following properties with no success:</p> <pre><code>/property:PostBuildEvent= /property:VCPostBuildEventTool= </code></pre> <p>Neither will make any difference and the post build events are still executed.</...
[ { "answer_id": 264851, "author": "Paul Fedory", "author_id": 30023, "author_profile": "https://Stackoverflow.com/users/30023", "pm_score": 0, "selected": false, "text": "<p>Have you tried setting the build event to something other than blank? If you overwrite it with something superfluo...
2008/11/05
[ "https://Stackoverflow.com/questions/264763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9236/" ]
I am using msbuild to build a C++ project and I want to suppress the 'Post-Build Event'. I have tried the following properties with no success: ``` /property:PostBuildEvent= /property:VCPostBuildEventTool= ``` Neither will make any difference and the post build events are still executed. Does anyone know how to sup...
I just figured out how to do this. There's 2 steps involved: First, if you're not starting the msbuild process using a batch file already, create a batch file that calls the msbuild process. Then add a variable in the batch file before you call the msbuild process. Something like this: ``` set ISFULLBUILD=True msbuil...
264,764
<p>I'm currently working on a WebSphere 6.1 Web Project.</p> <p>In my java code, how can i get the current running application port?</p>
[ { "answer_id": 265080, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 3, "selected": true, "text": "<p>The servlet API gives you the local port in HttpServletRequest.</p>\n\n<pre><code>protected void doGet(HttpServletRequest r...
2008/11/05
[ "https://Stackoverflow.com/questions/264764", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2937/" ]
I'm currently working on a WebSphere 6.1 Web Project. In my java code, how can i get the current running application port?
The servlet API gives you the local port in HttpServletRequest. ``` protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter writer = response.getWriter(); writer.write("" + request.getLocalPort()); writer.close(); } ``` The...
264,766
<p>My code works great in IE8, Firefox and Safari. But it doesn't work properly in Opera. What happens is that the DIV is hidden but the space occupied by the DIV remains to appear in my web-page.</p> <pre><code>&lt;div style=" z-index:-1;height :380; width:760; position:relative; text-align:center" id="new-add"&gt; ...
[ { "answer_id": 264774, "author": "Romain Linsolas", "author_id": 26457, "author_profile": "https://Stackoverflow.com/users/26457", "pm_score": 0, "selected": false, "text": "<p>I don't know if it will solve your problem, but you can try to use :</p>\n\n<pre><code>document.getElementById(...
2008/11/05
[ "https://Stackoverflow.com/questions/264766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2019426/" ]
My code works great in IE8, Firefox and Safari. But it doesn't work properly in Opera. What happens is that the DIV is hidden but the space occupied by the DIV remains to appear in my web-page. ``` <div style=" z-index:-1;height :380; width:760; position:relative; text-align:center" id="new-add"> <object id="bann...
You might try the style.display property: > > Hide > > > document.getElementById('YourElem').style.display = 'none'; > > > Show > > > document.getElementById('YourElem').style.display = ''; > > > **EDIT:** Took PorneL comment into acocunt in this answer
264,817
<p>I have code similar to the following in many places:</p> <pre><code>var dbParams = db.ReadParams(memberID, product, GetSubscriptionFields()); Debug.Assert(dbParams.Count == 4); _memberCode = dbParams[0]; _password = dbParams[1]; _userName = dbParams[2]; _reasonCode = dbParams[3]; </code></pre> <p>ReadParams() ret...
[ { "answer_id": 264849, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 2, "selected": true, "text": "<p>Why not use constants instead?</p>\n\n<p>Then in your code you could have</p>\n\n<pre><code>dbParams[MEMBER_CODE]\ndbPa...
2008/11/05
[ "https://Stackoverflow.com/questions/264817", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31793/" ]
I have code similar to the following in many places: ``` var dbParams = db.ReadParams(memberID, product, GetSubscriptionFields()); Debug.Assert(dbParams.Count == 4); _memberCode = dbParams[0]; _password = dbParams[1]; _userName = dbParams[2]; _reasonCode = dbParams[3]; ``` ReadParams() returns an array of strings, ...
Why not use constants instead? Then in your code you could have ``` dbParams[MEMBER_CODE] dbParams[PASSWORD] dbParams[USERNAME] dbParams[REASON_CODE] ``` which meets your goal of meaningful names without changing the way the method works.
264,823
<p>Pretty simple question: When i have a persistable object, it usually has a property called ID (for abstract classes).</p> <p>So .. is the naming convention ID or Id?</p> <p>eg.</p> <pre><code>public int ID { get; set; } </code></pre> <p>or</p> <pre><code>public int Id { get; set; } </code></pre> <p>cheers :)</...
[ { "answer_id": 264831, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 1, "selected": false, "text": "<p>I prefer ID, also in combination with other words (e.g. CustomerID), but strictly speaking that is against the regular nam...
2008/11/05
[ "https://Stackoverflow.com/questions/264823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
Pretty simple question: When i have a persistable object, it usually has a property called ID (for abstract classes). So .. is the naming convention ID or Id? eg. ``` public int ID { get; set; } ``` or ``` public int Id { get; set; } ``` cheers :) PS. This is for .NET btw. FXCop conformat would be a bonus.
I usually go with *Identifier*. If I really want to keep it short (as part of a longer identifier, for example), I use Id, unless it's a parameter or private member. The [.NET Framework Naming Guidelines](http://msdn.microsoft.com/en-us/library/ms229043.aspx) say this: > > An acronym is a word that is formed from th...
264,825
<p>There is a console Java application which is supposed to run until it is stopped by <kbd>Ctrl</kbd>+<kbd>C</kbd> or closing the console window. How that application can be programmed to execute a clean up code before exit?</p>
[ { "answer_id": 264833, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>You could use a <a href=\"http://www.onjava.com/pub/a/onjava/2003/03/26/shutdownhook.html\" rel=\"noreferrer\">Shutdown Hook...
2008/11/05
[ "https://Stackoverflow.com/questions/264825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31993/" ]
There is a console Java application which is supposed to run until it is stopped by `Ctrl`+`C` or closing the console window. How that application can be programmed to execute a clean up code before exit?
You could use a [Shutdown Hook](http://www.onjava.com/pub/a/onjava/2003/03/26/shutdownhook.html). Basically you need to create a Thread which will perform your shutdown actions, and then [add it as a shutdown hook](http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)). For exa...
264,832
<p>I am using attribute_fu to render a nice block of rows for a particular table.</p> <pre><code>&lt;%= f.render_associated_form(@foo.bars, :new =&gt; 5) %&gt; </code></pre> <p>I would like to have the <code>bar</code> partial have some notion of a bit of state. (Because the notion is specific to the view, I do not ...
[ { "answer_id": 271059, "author": "Patrick McKenzie", "author_id": 15046, "author_profile": "https://Stackoverflow.com/users/15046", "pm_score": 1, "selected": false, "text": "<p>I ended up solving this in a thoroughly Rails fashion -- patching :attribute_fu to meet my needs. Hopefully I...
2008/11/05
[ "https://Stackoverflow.com/questions/264832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15046/" ]
I am using attribute\_fu to render a nice block of rows for a particular table. ``` <%= f.render_associated_form(@foo.bars, :new => 5) %> ``` I would like to have the `bar` partial have some notion of a bit of state. (Because the notion is specific to the view, I do not want to externalize this to the `Bar` model it...
I ended up solving this in a thoroughly Rails fashion -- patching :attribute\_fu to meet my needs. Hopefully I'll be able to release my patches to the community fairly soon.
264,857
<p>I have a simple database:</p> <pre><code>ARTICLE ---------- ArticleId (PK), ArticleTitle ..other stuff... USER-ARTICLE ------------ ArchiveId (PK), UserId, ArticleId ..other stuff... </code></pre> <p>The <code>articleId</code>'s are foreign keys. </p> <p>I want to be able to delete a user article row by <code>Us...
[ { "answer_id": 718301, "author": "Rony", "author_id": 51326, "author_profile": "https://Stackoverflow.com/users/51326", "pm_score": 0, "selected": false, "text": "<p>try setting ON CASCADE DELETE for <code>ArticleId</code></p>\n" }, { "answer_id": 947931, "author": "Jim Count...
2008/11/05
[ "https://Stackoverflow.com/questions/264857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3193/" ]
I have a simple database: ``` ARTICLE ---------- ArticleId (PK), ArticleTitle ..other stuff... USER-ARTICLE ------------ ArchiveId (PK), UserId, ArticleId ..other stuff... ``` The `articleId`'s are foreign keys. I want to be able to delete a user article row by `UserArticleId` using the following code, ``` UserA...
This may be an example of this [bug](http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=351358), which Microsoft says is fixed in .NET 4.0.
264,907
<p>I am running a Solr instance on Jetty and when I search using the Solr admin panel, it returns the entire document. What should I do to get only specified fields from each Solr document returned by the search?</p>
[ { "answer_id": 289882, "author": "Andrew Ingram", "author_id": 15687, "author_profile": "https://Stackoverflow.com/users/15687", "pm_score": 8, "selected": true, "text": "<pre><code>/?q=query&amp;fl=field1,field2,field3\n</code></pre>\n" }, { "answer_id": 345024, "author": "K...
2008/11/05
[ "https://Stackoverflow.com/questions/264907", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]
I am running a Solr instance on Jetty and when I search using the Solr admin panel, it returns the entire document. What should I do to get only specified fields from each Solr document returned by the search?
``` /?q=query&fl=field1,field2,field3 ```
264,909
<p>do you have idea, if there would be some nice way to browse/log JMS queues? (I'm using OpenJMS)</p> <p>For topics I can just add one consumer more and that's about it but with queues I haven't finished with a solution yet. I would like to log all the messages in certain queues and topics without "popping" them from...
[ { "answer_id": 289882, "author": "Andrew Ingram", "author_id": 15687, "author_profile": "https://Stackoverflow.com/users/15687", "pm_score": 8, "selected": true, "text": "<pre><code>/?q=query&amp;fl=field1,field2,field3\n</code></pre>\n" }, { "answer_id": 345024, "author": "K...
2008/11/05
[ "https://Stackoverflow.com/questions/264909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28482/" ]
do you have idea, if there would be some nice way to browse/log JMS queues? (I'm using OpenJMS) For topics I can just add one consumer more and that's about it but with queues I haven't finished with a solution yet. I would like to log all the messages in certain queues and topics without "popping" them from the queue...
``` /?q=query&fl=field1,field2,field3 ```
264,914
<p>Being used to (and potentially spoiled by) <code>MSSQL</code>, I'm wondering how I can get at tables size in <code>Oracle</code> 10g. I have googled it so I'm now aware that I may not have as easy an option as <code>sp_spaceused</code>. Still the potential answers I got are most of the time outdated or don't work. P...
[ { "answer_id": 264928, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 3, "selected": false, "text": "<p>IIRC the tables you need are DBA_TABLES, DBA_EXTENTS or DBA_SEGMENTS and DBA_DATA_FILES. There are a...
2008/11/05
[ "https://Stackoverflow.com/questions/264914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11477/" ]
Being used to (and potentially spoiled by) `MSSQL`, I'm wondering how I can get at tables size in `Oracle` 10g. I have googled it so I'm now aware that I may not have as easy an option as `sp_spaceused`. Still the potential answers I got are most of the time outdated or don't work. Probably because I'm no DBA on the sc...
You might be interested in this query. It tells you how much space is allocated for each table taking into account the indexes and any LOBs on the table. Often you are interested to know "How much spaces the the Purchase Order table take, including any indexes" rather than just the table itself. You can always delve in...
264,917
<p>I want to create own header.jsp file instead of the one included in the JBoss Portal 2.6 but have to support the locale set by the user.</p> <p>The original header.jsp does not contain any i18n and I don't know how to do it, especially how to get the actual locale.</p>
[ { "answer_id": 264940, "author": "Lurtz", "author_id": 34367, "author_profile": "https://Stackoverflow.com/users/34367", "pm_score": 0, "selected": false, "text": "<p>You can look to Thread.currenThread method to see the user's lang.</p>\n\n<p>After that you have to a framework to implem...
2008/11/05
[ "https://Stackoverflow.com/questions/264917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25326/" ]
I want to create own header.jsp file instead of the one included in the JBoss Portal 2.6 but have to support the locale set by the user. The original header.jsp does not contain any i18n and I don't know how to do it, especially how to get the actual locale.
In header.jsp, use a scriptlet: ``` <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <% locale = request.getLocale() // get the user's locale from the HttpServletRequest %> ``` and then set the property bundle: ``` <fmt:setLocale value="<%= locale %>" /> <fmt:setBundle basename="header" /> ...
264,924
<p>We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a few angles for this, we can't seem to make it work. We're not averse to using JavaScript, it just feels that a CSS based solution ought to be possible. Is there a way of using just CSS (and possibly extra markup if necessary) ...
[ { "answer_id": 264980, "author": "philnash", "author_id": 28376, "author_profile": "https://Stackoverflow.com/users/28376", "pm_score": 4, "selected": true, "text": "<p>There is a pure css solution, however it won't work in versions of IE less than 7 because it won't understand the sibli...
2008/11/05
[ "https://Stackoverflow.com/questions/264924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2977/" ]
We have a page that ordinarily has two elements arranged side-by-side. Despite exploring a few angles for this, we can't seem to make it work. We're not averse to using JavaScript, it just feels that a CSS based solution ought to be possible. Is there a way of using just CSS (and possibly extra markup if necessary) to ...
There is a pure css solution, however it won't work in versions of IE less than 7 because it won't understand the sibling selector (+), for that you may want to consider a JavaScript solution (perhaps Dean Edwards' [IE7](http://dean.edwards.name/IE7/)). Anyway, some example css: ``` div#element2{ width:100px; marg...
264,930
<p>I'm still working with this huge list of URLs, all the help I have received has been great.</p> <p>At the moment I have the list looking like this (17000 URLs though):</p> <ul> <li><code>http://www.example.com/page?CONTENT_ITEM_ID=1</code></li> <li><code>http://www.example.com/page?CONTENT_ITEM_ID=3</code></li> <li>...
[ { "answer_id": 264936, "author": "Vinko Vrsalovic", "author_id": 5190, "author_profile": "https://Stackoverflow.com/users/5190", "pm_score": 3, "selected": false, "text": "<p>This is probably as fast as you can get without writing code.</p>\n<pre>\n $ cat foo.txt\n http://www.examp...
2008/11/05
[ "https://Stackoverflow.com/questions/264930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30786/" ]
I'm still working with this huge list of URLs, all the help I have received has been great. At the moment I have the list looking like this (17000 URLs though): * `http://www.example.com/page?CONTENT_ITEM_ID=1` * `http://www.example.com/page?CONTENT_ITEM_ID=3` * `http://www.example.com/page?CONTENT_ITEM_ID=2` * `http...
Are you're going to do this over and over again? If not, then "fastest" as in fastest to implement is probably ``` sort </file/of/urls | uniq --count | awk '{ print $2, " | ", $1}' ``` (not tested, I'm not near a UNIX command line)
264,937
<p>Currently i have this method:</p> <pre><code>static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return true; double multiplier = Math.pow(10, decimalPlaces); double check = d * multiplier; check = Math.round(check); check = check/multiplier; return (d==check...
[ { "answer_id": 264947, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 2, "selected": false, "text": "<p>As with all floating point arithmetic, you should not check for equality, but rather that the error (epsilon) is suff...
2008/11/05
[ "https://Stackoverflow.com/questions/264937", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5271/" ]
Currently i have this method: ``` static boolean checkDecimalPlaces(double d, int decimalPlaces){ if (d==0) return true; double multiplier = Math.pow(10, decimalPlaces); double check = d * multiplier; check = Math.round(check); check = check/multiplier; return (d==check); } ``...
The test fails, because you have reached the accuracy of the binary floating point representation, which is approximately 16 digits with [IEEE754 double precision](http://en.wikipedia.org/wiki/Double_precision). Multiplying by 649632196443.4279 by 10000 will truncate the binary representation, leading to errors when ro...
264,950
<p>I am using a machine on which I do not have root access and would like to access files on a Samba server in random access mode. I know I can transfer the files in their entirety using smbclient but the files are very large (>1GB) and I would rather just treat them as remote files on which I can do random access.</p>...
[ { "answer_id": 264963, "author": "xsl", "author_id": 11387, "author_profile": "https://Stackoverflow.com/users/11387", "pm_score": 0, "selected": false, "text": "<p>Try to use <code>smbmount</code> to mount the filesystem without root permissions:</p>\n\n<pre><code>mkdir ~/temp\nsmbmount...
2008/11/05
[ "https://Stackoverflow.com/questions/264950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15379/" ]
I am using a machine on which I do not have root access and would like to access files on a Samba server in random access mode. I know I can transfer the files in their entirety using smbclient but the files are very large (>1GB) and I would rather just treat them as remote files on which I can do random access. The p...
To answer my own question after digging around in the Samba source: there is a client library libsmbclient which includes all the usual file handling stuff: smbc\_open, smbc\_fstat, smbc\_lseek, smbc\_read etc. For instance, here is a snippet I just wrote which reads a file backwards (just to check it was doing a true ...
264,962
<p>I need to search a string in the string array. I dont want to use any for looping in it</p> <pre><code>string [] arr = {"One","Two","Three"}; string theString = "One" </code></pre> <p>I need to check whether theString variable is present in arr.</p>
[ { "answer_id": 264970, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": false, "text": "<p>Well, something is going to have to look, and looping is more efficient than recursion (since tail-end recursion i...
2008/11/05
[ "https://Stackoverflow.com/questions/264962", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22162/" ]
I need to search a string in the string array. I dont want to use any for looping in it ``` string [] arr = {"One","Two","Three"}; string theString = "One" ``` I need to check whether theString variable is present in arr.
Every method, mentioned earlier does looping either internally or externally, so it is not really important how to implement it. Here another example of finding all references of target string ``` string [] arr = {"One","Two","Three"}; var target = "One"; var results = Array.FindAll(arr, s => s.Eq...
264,984
<p>We are in the process of upgrading our VS2008 to the new SP1, but noticed a change in the csproj files for something that we can't find information on. Seems that the ProductVersion in the csproj file is changed from:</p> <pre><code>&lt;ProductVersion&gt;9.0.21022&lt;/ProductVersion&gt; </code></pre> <p>to</p> <p...
[ { "answer_id": 265031, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": true, "text": "<p>I think it's more likely to be the product version that <em>produced</em> the file rather than saying what it can be c...
2008/11/05
[ "https://Stackoverflow.com/questions/264984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9222/" ]
We are in the process of upgrading our VS2008 to the new SP1, but noticed a change in the csproj files for something that we can't find information on. Seems that the ProductVersion in the csproj file is changed from: ``` <ProductVersion>9.0.21022</ProductVersion> ``` to ``` <ProductVersion>9.0.30729</ProductVersio...
I think it's more likely to be the product version that *produced* the file rather than saying what it can be consumed by. I'd be very surprised to see the build version make any tangible difference.
265,018
<p>How can I create unicode console application with Delphi 2009?</p> <p>If I do like this:</p> <pre><code>{$APPTYPE CONSOLE} uses SysUtils; begin writeln('öüğşç سيمانتت'); end. </code></pre> <p>I get the following:</p> <pre><code>ougsc ??????? </code></pre>
[ { "answer_id": 265034, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 3, "selected": false, "text": "<p>You can't (At least not with the standard library). The console functions are the only non Unicode functions in De...
2008/11/05
[ "https://Stackoverflow.com/questions/265018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I create unicode console application with Delphi 2009? If I do like this: ``` {$APPTYPE CONSOLE} uses SysUtils; begin writeln('öüğşç سيمانتت'); end. ``` I get the following: ``` ougsc ??????? ```
I'm not sure that is what you're after, but you can create Unicode console applications in all 32-bit Delphi versions by using the Windows API functions. I just tried with Delphi 4: ``` program test; {$APPTYPE CONSOLE} uses Windows; var s: WideString; i: integer; Written: Cardinal; begin SetLength(s, 80);...
265,062
<p>I'm looking for an example of how to load an image from file and print it on a page using WPF. I'm having a hard time finding good information about WPF printing.</p>
[ { "answer_id": 265127, "author": "MojoFilter", "author_id": 93, "author_profile": "https://Stackoverflow.com/users/93", "pm_score": 0, "selected": false, "text": "<p>Just load the image and apply it to a visual. Then use the PrintDialog to do the work.</p>\n\n<pre><code>...\nPrintDialog...
2008/11/05
[ "https://Stackoverflow.com/questions/265062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18153/" ]
I'm looking for an example of how to load an image from file and print it on a page using WPF. I'm having a hard time finding good information about WPF printing.
``` var bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.UriSource = new Uri(""); bi.EndInit(); var vis = new DrawingVisual(); using (var dc = vis.RenderOpen()) { dc.DrawImage(bi, new Rect { Width = bi.Width, Height = bi.Height }); } var pdialog = new PrintDialog(); if (pdialo...
265,073
<p>I'm trying to make a PHP script, I have the script finished but it takes like 10 minutes to finish the process it is designed to do. This is not a problem, however I presume I have to keep the page loaded all this time which is annoying. Can I have it so that I start the process and then come back 10mins later and j...
[ { "answer_id": 265085, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "<p>I think shell_exec command is what you are looking for.</p>\n\n<p>However, it is disables in safe mode.</p>\n\n<p>The PHP m...
2008/11/05
[ "https://Stackoverflow.com/questions/265073", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26823/" ]
I'm trying to make a PHP script, I have the script finished but it takes like 10 minutes to finish the process it is designed to do. This is not a problem, however I presume I have to keep the page loaded all this time which is annoying. Can I have it so that I start the process and then come back 10mins later and just...
Well, you can use "[ignore\_user\_abort](http://de2.php.net/manual/en/function.ignore-user-abort.php)(true)" So the script will continue to work (keep an eye on script duration, perhaps add "[set\_time\_limit](http://de2.php.net/manual/en/function.set-time-limit.php)(0)") But a warning here: You will not be able to s...
265,081
<p>when installing SQLServer2005 developer edition (not express) I created a named instance:</p> <pre><code>MYSERVERNAME/MYINSTANCENAME </code></pre> <p>Is it possible to </p> <p>1) change the name of my named instance to default:</p> <pre><code>MYSERVERNAME </code></pre> <p>OR</p> <p>2) create a new default inst...
[ { "answer_id": 265110, "author": "Alan", "author_id": 31223, "author_profile": "https://Stackoverflow.com/users/31223", "pm_score": 4, "selected": true, "text": "<p>Hm, when I use the \"Change\" button in Add/Remove Programs, SQL Server 2005 setup offers me the instance selection screen,...
2008/11/05
[ "https://Stackoverflow.com/questions/265081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1311500/" ]
when installing SQLServer2005 developer edition (not express) I created a named instance: ``` MYSERVERNAME/MYINSTANCENAME ``` Is it possible to 1) change the name of my named instance to default: ``` MYSERVERNAME ``` OR 2) create a new default instance (MYSERVERNAME as above). any help would be appreciated!
Hm, when I use the "Change" button in Add/Remove Programs, SQL Server 2005 setup offers me the instance selection screen, and even allows me to list the existing instances. (I'm running XP SP2, by the way.) I selected the "To install a new component, click here" link in the setup program, then selected SQL Server Data...
265,096
<p>I'm trying to use <code>System.DirectoryServices</code> in a web site project and I'm getting this error:</p> <blockquote> <p>The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?)</p> </blockquote> <p>My project has a reference to <code>S...
[ { "answer_id": 265104, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>Is this a web <em>site</em> project, or a web <em>application</em> project. With the latter, references are handle...
2008/11/05
[ "https://Stackoverflow.com/questions/265096", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12111/" ]
I'm trying to use `System.DirectoryServices` in a web site project and I'm getting this error: > > The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?) > > > My project has a reference to `System.DirectoryServices` in `web.config`: ``` ...
Is the web-server (IIS or whatever) configured to run the folder as an application (i.e. shows as a cog), and is it using the correct version of ASP.NET? If it is running as 1.1, bits of it might work - but it would fail to find that 2.0 assembly in the 1.1 GAC.
265,117
<p>OK, I have just been reading and trying for the last hour to import a CSV file from access into MySQL, but I can not get it to do it correctly, no matter what I try.</p> <p>My table is like so:</p> <pre><code>+-----------------+------------- | Field | Type +-----------------+------------- | ARTICLE_NO ...
[ { "answer_id": 265150, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 1, "selected": true, "text": "<p>The error can be caused by corrupt data in your DB, by the query to retrieve it from the DB, or in the way you output it. Y...
2008/11/05
[ "https://Stackoverflow.com/questions/265117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
OK, I have just been reading and trying for the last hour to import a CSV file from access into MySQL, but I can not get it to do it correctly, no matter what I try. My table is like so: ``` +-----------------+------------- | Field | Type +-----------------+------------- | ARTICLE_NO | varchar(20) | AR...
The error can be caused by corrupt data in your DB, by the query to retrieve it from the DB, or in the way you output it. You need to narrow it down to one of those causes. 1. Have a direct look at the table you are selecting from. I suggest [phpMyAdmin](http://www.phpmyadmin.net/) for this. 2. Directly print the resu...
265,140
<p><a href="http://www.springsource.org/extensions/se-workflow" rel="noreferrer">Spring Workflow</a> has now been published.</p> <ul> <li>Have you tried it yet? For what kind of scenario?</li> <li>What is your impression? How do you find it stacks up against other workflow libs?</li> <li>Found any good docs or tutoria...
[ { "answer_id": 453212, "author": "SenoCtar", "author_id": 56174, "author_profile": "https://Stackoverflow.com/users/56174", "pm_score": 0, "selected": false, "text": "<p>I don't think it's a good idea to try it yet, it's just a release to proove the concept. First of all you have to manu...
2008/11/05
[ "https://Stackoverflow.com/questions/265140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20065/" ]
[Spring Workflow](http://www.springsource.org/extensions/se-workflow) has now been published. * Have you tried it yet? For what kind of scenario? * What is your impression? How do you find it stacks up against other workflow libs? * Found any good docs or tutorials?
OK, ignoring my beliefs shown in my previous post I did try spring workflow, only to find out that I was right. Getting the sources and building is not that hard, they use svn, ant and ivy as repository manager. Making it work is another story. I took the sample sources, an placed them in a new project. At this poit I...
265,146
<p>I currently have a 32 bit dll that was created with Visual Studio 2003 in C++ using <a href="http://en.wikipedia.org/wiki/Managed_Extensions_for_C%2B%2B" rel="nofollow noreferrer">Managed Extensions</a>. I'm now trying to compile a 64 bit version without having to upgrade to C++/CLI. I've been following the tutorial...
[ { "answer_id": 265167, "author": "UberJumper", "author_id": 34395, "author_profile": "https://Stackoverflow.com/users/34395", "pm_score": 1, "selected": false, "text": "<p>Do you manually call the .dll file in the code? Like in this?</p>\n\n<pre><code>#using \"C:\\Windows\\Microsoft.NET\...
2008/11/05
[ "https://Stackoverflow.com/questions/265146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9539/" ]
I currently have a 32 bit dll that was created with Visual Studio 2003 in C++ using [Managed Extensions](http://en.wikipedia.org/wiki/Managed_Extensions_for_C%2B%2B). I'm now trying to compile a 64 bit version without having to upgrade to C++/CLI. I've been following the tutorial at [this location](http://www.eggheadca...
Do you manually call the .dll file in the code? Like in this? ``` #using "C:\Windows\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll ``` If so, you can change this line to just: ``` #using "mscorlib.dll" ```
265,166
<p>I need to pause for maybe 500 miliseconds before I submit a form. Here is what I have so far:</p> <pre><code> $(".rowqty input").bind("keyup", function() { $("#ViewCartPage form").animate({ opacity: 1.0 }, 3000).submit() }); </code></pre> <p>so when someone changes the quantity of the input field it submits the f...
[ { "answer_id": 265172, "author": "Chris Van Opstal", "author_id": 7264, "author_profile": "https://Stackoverflow.com/users/7264", "pm_score": 3, "selected": true, "text": "<p>Give this a shot:</p>\n\n<pre><code>$(\".rowqty input\").bind(\"keyup\", function() { setTimeout(\"$('#ViewCartPa...
2008/11/05
[ "https://Stackoverflow.com/questions/265166", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I need to pause for maybe 500 miliseconds before I submit a form. Here is what I have so far: ``` $(".rowqty input").bind("keyup", function() { $("#ViewCartPage form").animate({ opacity: 1.0 }, 3000).submit() }); ``` so when someone changes the quantity of the input field it submits the form, but I want it to wait ...
Give this a shot: ``` $(".rowqty input").bind("keyup", function() { setTimeout("$('#ViewCartPage form').submit()", 500 }); ```
265,175
<p>Any idea anyone? Is it possible that we specify the name of the form input field? How to go about doing that?</p>
[ { "answer_id": 265191, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>It's generated as formId:fieldId</p>\n\n<p>So, if you had the following:</p>\n\n<pre><code>&lt;h:form id=\"searchForm\"&gt;...
2008/11/05
[ "https://Stackoverflow.com/questions/265175", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Any idea anyone? Is it possible that we specify the name of the form input field? How to go about doing that?
More generally, all JSF components have an ID. If you don't provide one, JSF will create an automatic ID, using the format j`_`idXXX (*XXX* is a incremented number). Some components implement the javax.faces.component.NamingContainer interface, in particular `<h:form>`. This means that all children of this component w...
265,180
<p>Is there any security issue if let say in one application we do a hidden post to another application to make use of that application functionality?</p>
[ { "answer_id": 265191, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>It's generated as formId:fieldId</p>\n\n<p>So, if you had the following:</p>\n\n<pre><code>&lt;h:form id=\"searchForm\"&gt;...
2008/11/05
[ "https://Stackoverflow.com/questions/265180", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there any security issue if let say in one application we do a hidden post to another application to make use of that application functionality?
More generally, all JSF components have an ID. If you don't provide one, JSF will create an automatic ID, using the format j`_`idXXX (*XXX* is a incremented number). Some components implement the javax.faces.component.NamingContainer interface, in particular `<h:form>`. This means that all children of this component w...
265,192
<p>I have the following code:</p> <pre><code>Using cmd As SqlCommand = Connection.CreateCommand cmd.CommandText = "UPDATE someTable SET Value = @Value" cmd.CommandText &amp;= " WHERE Id = @Id" cmd.Parameters.AddWithValue("@Id", 1234) cmd.Parameters.AddWithValue("@Value", "myValue") cmd.ExecuteNonQu...
[ { "answer_id": 265241, "author": "Rockcoder", "author_id": 5290, "author_profile": "https://Stackoverflow.com/users/5290", "pm_score": 3, "selected": false, "text": "<p>If you're using SQL Server, you could use SQL Server Profiler (if you have it) to view the command string that is actua...
2008/11/05
[ "https://Stackoverflow.com/questions/265192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6297/" ]
I have the following code: ``` Using cmd As SqlCommand = Connection.CreateCommand cmd.CommandText = "UPDATE someTable SET Value = @Value" cmd.CommandText &= " WHERE Id = @Id" cmd.Parameters.AddWithValue("@Id", 1234) cmd.Parameters.AddWithValue("@Value", "myValue") cmd.ExecuteNonQuery End Using ```...
Whilst not perfect, here's something I knocked up for TSQL - could be easily tweaked for other flavors... If nothing else it will give you a start point for your own improvements :) This does an OK job on data types and output parameters etc similar to using "execute stored procedure" in SSMS. We mostly used SPs so th...
265,208
<p>I have a list of integers in C#. I wish to remove duplicates. In C++ I would run it through the std::sort and then std::unique algorithms for a very efficient way of obtaining the unique list.</p> <p>What's the best way to do the same thing in C#? In other words, I'm looking for a more elegant way to do the follow...
[ { "answer_id": 265214, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>What version of .NET are you using?</p>\n\n<p>In .NET 3.5 that's as simple as calling the <a href=\"http://msdn.micros...
2008/11/05
[ "https://Stackoverflow.com/questions/265208", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34685/" ]
I have a list of integers in C#. I wish to remove duplicates. In C++ I would run it through the std::sort and then std::unique algorithms for a very efficient way of obtaining the unique list. What's the best way to do the same thing in C#? In other words, I'm looking for a more elegant way to do the following code: ...
What version of .NET are you using? In .NET 3.5 that's as simple as calling the [Distinct()](http://msdn.microsoft.com/en-us/library/system.linq.enumerable.distinct.aspx) extension method and then [ToArray()](http://msdn.microsoft.com/en-us/library/bb298736.aspx) if you really need an array again. For example: ``` i...
265,228
<p>I have some function to find a value:</p> <pre><code>struct FindPredicate { FindPredicate(const SomeType&amp; t) : _t(t) { } bool operator()(SomeType&amp; t) { return t == _t; } private: const SomeType&amp; _t; }; bool ContainsValue(std::vector&lt;SomeType&gt;&amp; v, SomeType&amp; valu...
[ { "answer_id": 265307, "author": "Luc Touraille", "author_id": 20984, "author_profile": "https://Stackoverflow.com/users/20984", "pm_score": 5, "selected": true, "text": "<p>The best solution is to use the <a href=\"http://www.keithschwarz.com/cs106l/fall2007/handouts/200_STL_Functional_...
2008/11/05
[ "https://Stackoverflow.com/questions/265228", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17650/" ]
I have some function to find a value: ``` struct FindPredicate { FindPredicate(const SomeType& t) : _t(t) { } bool operator()(SomeType& t) { return t == _t; } private: const SomeType& _t; }; bool ContainsValue(std::vector<SomeType>& v, SomeType& valueToFind) { return find_if(v.begin(),...
The best solution is to use the [STL functional library](http://www.keithschwarz.com/cs106l/fall2007/handouts/200_STL_Functional_Library.pdf). By deriving your predicate from `unary_function<SomeType, bool>` , you'll then be able to use the `not1` function, which does precisely what you need (i.e. negating a unary pred...
265,258
<p>I am doing 2^1000 and I am getting this:</p> <p>1.07151e+301</p> <p>Is there any way to actually turn this into a proper number without the e+301, or at least can anyone show me where I can see how to turn this in to a real number, by some way working with the e+301 part?</p>
[ { "answer_id": 265272, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "<p>You need to use a number class specifically designed for long numbers.</p>\n\n<p>To represent 2^1000 as an exact number t...
2008/11/05
[ "https://Stackoverflow.com/questions/265258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8715/" ]
I am doing 2^1000 and I am getting this: 1.07151e+301 Is there any way to actually turn this into a proper number without the e+301, or at least can anyone show me where I can see how to turn this in to a real number, by some way working with the e+301 part?
So, I'm thinking that what you really want is just the ability to print it without scientific notation. If you're using `printf`, what you want is: ``` printf( "%f1000.0", value ); // note that 1000 is way larger than need be, // I'm just too lazy to count the digits ``` With `cout`, try something like: ``` cout.se...
265,293
<p>I have an ASP.Net MVC Ajax.BeginForm that submits and updates my page properly when I click the submit button. </p> <p>The problem is I need additional events to do the same thing, like when they change the text of an input. The additonal events do properly submit the form but they circumvent the onsubmit javascr...
[ { "answer_id": 265473, "author": "Andrew Stanton-Nurse", "author_id": 29813, "author_profile": "https://Stackoverflow.com/users/29813", "pm_score": 0, "selected": false, "text": "<p>This is a bit of a tricky issue in the current Beta of MVC. You can't use the \"submit()\" function becau...
2008/11/05
[ "https://Stackoverflow.com/questions/265293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34548/" ]
I have an ASP.Net MVC Ajax.BeginForm that submits and updates my page properly when I click the submit button. The problem is I need additional events to do the same thing, like when they change the text of an input. The additonal events do properly submit the form but they circumvent the onsubmit javascript generate...
Decided to just use a regular form and then the jQuery.Form plugin and this worked in 2 seconds! Wish i would have just went this route orginally. ``` var options = { target: '#updatedContent', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback succe...
265,302
<p>First some background. I am trying to run <a href="http://www.communityengine.org/" rel="nofollow noreferrer">Community Engine</a> on a fresh install of Ubuntu. CE is a open src social networking plugin running on Rails. I was able to get CE up and running on my windows box w/o issue. I have decided to use Ubuntu 8....
[ { "answer_id": 266520, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 3, "selected": false, "text": "<p>The \"problem\" is not coming from CommunityEngine itself, but with the underlying 'engines' plugin (<a href=\"http:/...
2008/11/05
[ "https://Stackoverflow.com/questions/265302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23458/" ]
First some background. I am trying to run [Community Engine](http://www.communityengine.org/) on a fresh install of Ubuntu. CE is a open src social networking plugin running on Rails. I was able to get CE up and running on my windows box w/o issue. I have decided to use Ubuntu 8.10 as my development environment now, an...
This issue ended up being due to not usind sudo to install rails. I ended up blowing away ruby completely and reinstalling it. I also paid closer attention to the output of the various gems i needed to install to make sure they downloaded and ran. I was surprised to see that many of them would fail to download and had ...
265,335
<p>My table has the following schema:</p> <p>id, parent_id, text</p> <p>Given the following data I would like to return an xml hierarchy:</p> <p>Data: (1,null,'x'), (2,1,'y'), (3,1,'z'), (4,2,'a')</p> <p>XML:<br> [row text="x"]<br> [row text="y"]<br> [row text="a"/]<br> [/row]<br> [row text="z"/]<br> [/row] <...
[ { "answer_id": 265359, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": -1, "selected": false, "text": "<p>This requires a \"transitive closure\". You need to process the data recursively to find all children under a given pa...
2008/11/05
[ "https://Stackoverflow.com/questions/265335", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2133/" ]
My table has the following schema: id, parent\_id, text Given the following data I would like to return an xml hierarchy: Data: (1,null,'x'), (2,1,'y'), (3,1,'z'), (4,2,'a') XML: [row text="x"] [row text="y"] [row text="a"/] [/row] [row text="z"/] [/row] --- Added: the hierachy has no maxim...
If you have a finite depth the there's a quickie that looks like this: ``` SELECT T.*, T2.*, T3.* /*, ...*/ FROM myTable T INNER JOIN myTable T2 ON T2.parent_id=T.id INNER JOIN myTable T3 ON T3.parent_id=T2.id /* ... */ WHERE T.parent_id IS NULL FOR XML AUTO ``` I'm not sure but it might be possible to devise a sim...
265,339
<p>I'd like to automate the FTP download of a database backup file using PowerShell. The file name includes the date so I can't just run the same FTP script every day. Is there a clean way to do this built into PowerShell or using the .NET framework?</p> <p>I want to use a secure FTP session.</p>
[ { "answer_id": 265397, "author": "EBGreen", "author_id": 1358, "author_profile": "https://Stackoverflow.com/users/1358", "pm_score": 0, "selected": false, "text": "<p>This isn't as simple as I wish it would be. There are three options that I know of.</p>\n<ol>\n<li><p>.NET - You can use ...
2008/11/05
[ "https://Stackoverflow.com/questions/265339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18891/" ]
I'd like to automate the FTP download of a database backup file using PowerShell. The file name includes the date so I can't just run the same FTP script every day. Is there a clean way to do this built into PowerShell or using the .NET framework? I want to use a secure FTP session.
After some experimentation I came up with this way to automate a secure FTP download in PowerShell. This script runs off the [public test FTP server](http://www.secureftp-test.com/) administered by Chilkat Software. So you can copy and paste this code and it will run without modification. ``` $sourceuri = "ftp://ftp.s...
265,361
<p>I am trying to get a simple demo started with ActiveMQ that will demonstrate a TCP to TCP route. I am coding the endpoints and routes in a camel context in my activemq.xml configuration file.</p> <pre><code>&lt;camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"&gt; &lt;package&gt;or...
[ { "answer_id": 265539, "author": "James Strachan", "author_id": 2068211, "author_profile": "https://Stackoverflow.com/users/2068211", "pm_score": 2, "selected": true, "text": "<p>I'm a bit confused by your configuration file. What exactly are you trying to do? </p>\n\n<p>You've defined 2...
2008/11/05
[ "https://Stackoverflow.com/questions/265361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
I am trying to get a simple demo started with ActiveMQ that will demonstrate a TCP to TCP route. I am coding the endpoints and routes in a camel context in my activemq.xml configuration file. ``` <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <package>org.myorg.codec</package> ...
I'm a bit confused by your configuration file. What exactly are you trying to do? You've defined 2 endpoints for using MINA (which won't use ActiveMQ at all); then you are using a route from an ActievMQ queue listener\_A to listener\_B then listener\_B to listener\_A (which is a recursive loop). Maybe if you start d...
265,362
<p>Is there any way to create - manipulate calendar events in Exchange Server 2003 ? I'm using VB.NET 2005. I don't want to use MAPI because everytime I will have to type user name and passwords. Is there any other way ? I used redemption.dll but everytime I want to add for eg. a calendar event it displays the login sc...
[ { "answer_id": 265539, "author": "James Strachan", "author_id": 2068211, "author_profile": "https://Stackoverflow.com/users/2068211", "pm_score": 2, "selected": true, "text": "<p>I'm a bit confused by your configuration file. What exactly are you trying to do? </p>\n\n<p>You've defined 2...
2008/11/05
[ "https://Stackoverflow.com/questions/265362", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is there any way to create - manipulate calendar events in Exchange Server 2003 ? I'm using VB.NET 2005. I don't want to use MAPI because everytime I will have to type user name and passwords. Is there any other way ? I used redemption.dll but everytime I want to add for eg. a calendar event it displays the login scree...
I'm a bit confused by your configuration file. What exactly are you trying to do? You've defined 2 endpoints for using MINA (which won't use ActiveMQ at all); then you are using a route from an ActievMQ queue listener\_A to listener\_B then listener\_B to listener\_A (which is a recursive loop). Maybe if you start d...
265,370
<p>what is the best way to convert a UTF-16 files to UTF-8? I need to use this in a cmd script.</p>
[ { "answer_id": 265381, "author": "Tor Haugen", "author_id": 32050, "author_profile": "https://Stackoverflow.com/users/32050", "pm_score": 3, "selected": false, "text": "<p>Certainly, the <strong>easiest</strong> way is to load the script into notepad, then save it again with the UTF-8 en...
2008/11/05
[ "https://Stackoverflow.com/questions/265370", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5363/" ]
what is the best way to convert a UTF-16 files to UTF-8? I need to use this in a cmd script.
There is a GNU tool [recode](http://www.gnu.org/software/recode/recode.html) which you can also use on Windows. E.g. ``` recode utf16..utf8 text.txt ```
265,371
<p>I'm working on an app that takes data from our DB and outputs an xml file using the FOR XML AUTO, ELEMENTS on the end of the generated query, followed by an XSLT to transform it the way we want. However in a particular case where we are generating some data using an sql scalar function, it always puts that element ...
[ { "answer_id": 265640, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 1, "selected": false, "text": "<p>I would try to get rid of the sub query parts \"(SELECT...\" and do regular joins, like:</p>\n\n<pre><code>SELECT table1...
2008/11/05
[ "https://Stackoverflow.com/questions/265371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3326/" ]
I'm working on an app that takes data from our DB and outputs an xml file using the FOR XML AUTO, ELEMENTS on the end of the generated query, followed by an XSLT to transform it the way we want. However in a particular case where we are generating some data using an sql scalar function, it always puts that element into...
Doing some further reserach, as of now it appears running a db in 2000 compat mode while on a 2005 sql server this problem is created, will not pin this until confirmed.
265,398
<p>I have an application that uses <code>window.open()</code> to generate dynamic popups. Unfortunately, I've had trouble creating the content of the new windows using the standard DOM functions (<code>createElement</code>, <code>appendChild</code>), and I've gone to using <code>document.write()</code> to generate the ...
[ { "answer_id": 265409, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": true, "text": "<p>Why not use a library function such as <a href=\"http://plugins.jquery.com/project/modaldialog\" rel=\"nofollow nore...
2008/11/05
[ "https://Stackoverflow.com/questions/265398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32771/" ]
I have an application that uses `window.open()` to generate dynamic popups. Unfortunately, I've had trouble creating the content of the new windows using the standard DOM functions (`createElement`, `appendChild`), and I've gone to using `document.write()` to generate the page. Concretely, how can I go from this: ```...
Why not use a library function such as <http://plugins.jquery.com/project/modaldialog> instead of reinventing the wheel? [EDIT] OR ``` function writePopup(){ var popup = window.open("", "_blank", "height=400px, width=400px"); var doc = popup.document; doc.title = 'Written Popup'; var p = doc.createEl...
265,403
<p>I'm using jQuery to handle all my ajax needs for an ASP.NET site coded in VB. When I use the built in $.ajax function to POST to a code-behind function and there is an exception, it simply exits the function, and shows an error on the client side.</p> <p>Besides making debugging difficult when coding, the bigger is...
[ { "answer_id": 265792, "author": "Martin", "author_id": 11481, "author_profile": "https://Stackoverflow.com/users/11481", "pm_score": 0, "selected": false, "text": "<p>With .Net 3.5 you can pull in the <a href=\"http://www.asp.net/Ajax/Documentation/Live/overview/ScriptManagerOverview.as...
2008/11/05
[ "https://Stackoverflow.com/questions/265403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12322/" ]
I'm using jQuery to handle all my ajax needs for an ASP.NET site coded in VB. When I use the built in $.ajax function to POST to a code-behind function and there is an exception, it simply exits the function, and shows an error on the client side. Besides making debugging difficult when coding, the bigger issue is tha...
I figured out a work around. Although I did not find a way to directly get the error to fire the Application\_Error event, I discovered a property on the jQuery XMLHttpRequest object that contains the actual exception text. Here is an example that will show the error in an alert: ``` error: function(XMLHttpRequest, t...
265,410
<p>This is a generic way to select data from a table and show the results in an HTML table using JSP taglibs. What is the generic way to do this in Grails? That is, take a few lines of SQL and generate an HTML table from scratch in Grails, including the column names as headers.</p> <pre> &lt;sql:query var="results" ...
[ { "answer_id": 265848, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 0, "selected": false, "text": "<p>You could use the taglib as described. You just need to make Grails aware of it.</p>\n" }, { "answer_id": 266...
2008/11/05
[ "https://Stackoverflow.com/questions/265410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This is a generic way to select data from a table and show the results in an HTML table using JSP taglibs. What is the generic way to do this in Grails? That is, take a few lines of SQL and generate an HTML table from scratch in Grails, including the column names as headers. ``` <sql:query var="results" dataSource="$...
This question could be rephrased as, how do I write code like a naive ASP.NET developer? (Not all ASP.NET developers are naive, some can be quite good) 1. Any static method is available to you in a gsp page. You can use any MyDomain.findBy, list(), count you want from page scope. 2. You could also use a criteria query...
265,423
<p>I have to build an HTML table that shows data for users versus pages visited. It seems klunky to use for and/or foreach loops, but I can't think of anything better. I'm using PHP, but I would assume that this is language agnostic.</p>
[ { "answer_id": 265437, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 2, "selected": false, "text": "<p>Well, if you have multiple rows, with data formatted similarly in each row, I can't think of a way to create a tab...
2008/11/05
[ "https://Stackoverflow.com/questions/265423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
I have to build an HTML table that shows data for users versus pages visited. It seems klunky to use for and/or foreach loops, but I can't think of anything better. I'm using PHP, but I would assume that this is language agnostic.
Avoiding loops is probably not possible, if not in implementation, then it will still happen at machine level. However, if you want to try stay 'pure' without nasty code, you can at least do: ``` $tableformat = '<table><thead>%s</thead><tbody>%s</tbody></table>'; $rowformat = '<tr>%s</tr>'; $cellformat = '<td>%...
265,449
<p>I've got a minidump file from a crash in one of our apps. It's a 32-bit native app, and it was running on 64-bit Windows.</p> <p>If I load the minidump file into WinDbg, WinDbg won't load the symbols for the system DLLs. I've got my symbol paths configured correctly:</p> <pre><code>_NT_SYMBOL_PATH=SRV*C:\WebSymbol...
[ { "answer_id": 265488, "author": "Cory Foy", "author_id": 4083, "author_profile": "https://Stackoverflow.com/users/4083", "pm_score": 3, "selected": false, "text": "<p>Are you debugging on a 32-bit or 64-bit system, and with the 32 or 64-bit version of WinDBG? You typically have to debug...
2008/11/05
[ "https://Stackoverflow.com/questions/265449", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446/" ]
I've got a minidump file from a crash in one of our apps. It's a 32-bit native app, and it was running on 64-bit Windows. If I load the minidump file into WinDbg, WinDbg won't load the symbols for the system DLLs. I've got my symbol paths configured correctly: ``` _NT_SYMBOL_PATH=SRV*C:\WebSymbols*http://msdl.microso...
Are you debugging on a 32-bit or 64-bit system, and with the 32 or 64-bit version of WinDBG? You typically have to debug on the same architecture package you took the dump from: [<http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx>](http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx) > > ...
265,478
<p>I have some HTML and jQuery that slides a <code>div</code> up and down to show or hide` it when a link is clicked:</p> <pre class="lang-html prettyprint-override"><code>&lt;ul class="product-info"&gt; &lt;li&gt; &lt;a href="#"&gt;YOU CLICK THIS TO SHOW/HIDE&lt;/a&gt; &lt;div class="toggle"&gt; &lt;p...
[ { "answer_id": 265499, "author": "Davide Gualano", "author_id": 28582, "author_profile": "https://Stackoverflow.com/users/28582", "pm_score": 9, "selected": true, "text": "<p>Try something like:</p>\n\n<pre><code>$('div.toggle').hide();\n$('ul.product-info li a').click(function(event) {\...
2008/11/05
[ "https://Stackoverflow.com/questions/265478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
I have some HTML and jQuery that slides a `div` up and down to show or hide` it when a link is clicked: ```html <ul class="product-info"> <li> <a href="#">YOU CLICK THIS TO SHOW/HIDE</a> <div class="toggle"> <p>CONTENT TO SHOW/HIDE</p> </div> </li> </ul> ``` ```js $('div.toggle').hide(); $('ul....
Try something like: ``` $('div.toggle').hide(); $('ul.product-info li a').click(function(event) { event.preventDefault(); $(this).next('div').slideToggle(200); }); ``` Here is the page about that in the [jQuery documentation](http://learn.jquery.com/events/event-basics/#preventdefault)
265,481
<p>We moved our Visual C++ 2003 solution to Visual 2005 and now we have problems deploying to clean XP machines.</p> <p>Our solution has a DLL project and a command line executable which uses this DLL. Both projects create and embed manifest files.</p> <p>Our installer also copies the VC8 CRT runtimes from the C:\Pro...
[ { "answer_id": 265520, "author": "Vinay", "author_id": 28641, "author_profile": "https://Stackoverflow.com/users/28641", "pm_score": 2, "selected": false, "text": "<p>Select Visual Studio 2005 Merge modules in the installer.\nThis can also occur if you have built the exe/dll using visual...
2008/11/05
[ "https://Stackoverflow.com/questions/265481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23000/" ]
We moved our Visual C++ 2003 solution to Visual 2005 and now we have problems deploying to clean XP machines. Our solution has a DLL project and a command line executable which uses this DLL. Both projects create and embed manifest files. Our installer also copies the VC8 CRT runtimes from the C:\Programme\Microsoft ...
Copying the CRT dlls around is not recommended. As Vinay says you should use the correct merge modules. You can also use the redist install exe's if merge modules don't work with your installer technology: * [VS2005 CRT](http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&dis...
265,494
<p>I have a website which uses themes. Depending on the url (if it is A.something.com or B.something.com, where A and B represent clients), I will load a different theme. The intention is to use one codebase for different clients. I have an app_themes folder, several themes inside, for different clients, and different ...
[ { "answer_id": 265513, "author": "DOK", "author_id": 27637, "author_profile": "https://Stackoverflow.com/users/27637", "pm_score": 2, "selected": false, "text": "<p>Is this occurring only when you run the code from within Visual Studio? </p>\n\n<p>When running in ASP.Net Development Serv...
2008/11/05
[ "https://Stackoverflow.com/questions/265494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
I have a website which uses themes. Depending on the url (if it is A.something.com or B.something.com, where A and B represent clients), I will load a different theme. The intention is to use one codebase for different clients. I have an app\_themes folder, several themes inside, for different clients, and different CS...
Is this occurring only when you run the code from within Visual Studio? When running in ASP.Net Development Server, the styles in App\_Themes won't be used on any unauthenticated page (such as Login.aspx or ForgotPassword.aspx). That's because the user doesn't have browse permissions on that folder yet, or the App\_T...
265,508
<p>I need a dropdown list on my page that will allow a user to select their state. Since this is probably a control that will be used elsewhere, I thought it would be a good idea to create an MVC View User Control that could be reused.</p> <p>I was thinking the control would look something like this:</p> <pre><code>...
[ { "answer_id": 265543, "author": "Corey Gaudin", "author_id": 31195, "author_profile": "https://Stackoverflow.com/users/31195", "pm_score": 2, "selected": false, "text": "<p>Well you can pass object data to the RenderPartial method in conjunction to the User Control to render, so you cou...
2008/11/05
[ "https://Stackoverflow.com/questions/265508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34720/" ]
I need a dropdown list on my page that will allow a user to select their state. Since this is probably a control that will be used elsewhere, I thought it would be a good idea to create an MVC View User Control that could be reused. I was thinking the control would look something like this: ``` <select name="" id="">...
Corey is on to the right solution. I think declaring specific Model objects for your view makes the views VERY simple and as a side bonus makes them dirt easy to test. So instead of just passing the ID as the object, you'd probably want to create your own Model object to pass in. It could look something like this: `...
265,524
<p>We have a few applications that use the same Linq 2 SQL DataContext. One of those Apps wil do massive inserts (it's a convertor from an old system). Is it possible to change the UpdateCheck of the TimeStamp column of each table at runtime ? Only for this one app we'd like to set it to Never, all the other apps sh...
[ { "answer_id": 265582, "author": "Panos", "author_id": 8049, "author_profile": "https://Stackoverflow.com/users/8049", "pm_score": 1, "selected": false, "text": "<p>AFAIK you can not change it (at least with simple means) at runtime, because it is auto-generated as attribute in the prope...
2008/11/05
[ "https://Stackoverflow.com/questions/265524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34723/" ]
We have a few applications that use the same Linq 2 SQL DataContext. One of those Apps wil do massive inserts (it's a convertor from an old system). Is it possible to change the UpdateCheck of the TimeStamp column of each table at runtime ? Only for this one app we'd like to set it to Never, all the other apps should h...
AFAIK you can not change it (at least with simple means) at runtime, because it is auto-generated as attribute in the properties of the domain classes. E.g. ``` [Column(Name="ITM_CREATE_DATE", Storage="_ITM_CREATE_DATE", DbType="DateTime NOT NULL", UpdateCheck=UpdateCheck.Never)] public System.DateTime CreationDate `...
265,528
<p>Many web sites support folksonomy tags. You may have heard of <a href="http://microformats.org/wiki/reltag" rel="nofollow noreferrer">rel-tag</a>, where it says that "The last path component of the URL is the text of the tag".</p> <p>I am looking for a bookmarklet or greasemonkey script (javascript) to get the "la...
[ { "answer_id": 321492, "author": "Jan Goyvaerts", "author_id": 33358, "author_profile": "https://Stackoverflow.com/users/33358", "pm_score": 0, "selected": false, "text": "<p>If you can assume both your URLs to be valid, you can get the tag from the first URL with this regex:</p>\n\n<pre...
2008/11/05
[ "https://Stackoverflow.com/questions/265528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31241/" ]
Many web sites support folksonomy tags. You may have heard of [rel-tag](http://microformats.org/wiki/reltag), where it says that "The last path component of the URL is the text of the tag". I am looking for a bookmarklet or greasemonkey script (javascript) to get the "last path component" for the URL currently being v...
Since you're using JavaScript, there's no need to worry about hostnames, querystrings, etc - just use `location.pathname` to get at the important bit. For example: ``` var NewUrl = 'http://technorati.com/tag/'; var LastPart = location.pathname.match( /[^\/]+\/?$/ ); window.open( NewUrl + LastPart ); ``` That allows...
265,559
<p>When @RadioServiceGroup is set to NULL, I want to return all the records from the sbi_l_radioservicecodes table which has about 120 records. However, when I execute the following procedure and set the @RadioServiceGroup to NULL, it returns no records. Here is the stored proc:</p> <pre><code>CREATE PROCEDURE [dbo]...
[ { "answer_id": 265565, "author": "Corey Trager", "author_id": 9328, "author_profile": "https://Stackoverflow.com/users/9328", "pm_score": 5, "selected": true, "text": "<p>Try \"IS NULL\" instead of \"= NULL\"</p>\n" }, { "answer_id": 265569, "author": "Joel Coehoorn", "au...
2008/11/05
[ "https://Stackoverflow.com/questions/265559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
When @RadioServiceGroup is set to NULL, I want to return all the records from the sbi\_l\_radioservicecodes table which has about 120 records. However, when I execute the following procedure and set the @RadioServiceGroup to NULL, it returns no records. Here is the stored proc: ``` CREATE PROCEDURE [dbo].[GetRadioServ...
Try "IS NULL" instead of "= NULL"
265,563
<p>I'm using Windows CE Platform Builder and my code is written in C++ . For each of the folders in the project I'm creating a lib ( the code is statically linked ) . However , there are about 20 libs so far . Is there a way to reduce their number ? I was thinking of creating a lib from other libs , but I don't know if...
[ { "answer_id": 265580, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 3, "selected": true, "text": "<p>I haven't tried it in a while, but traditionally you could use the librarian tool (LIB.EXE) to do this sort of thing.</p...
2008/11/05
[ "https://Stackoverflow.com/questions/265563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31610/" ]
I'm using Windows CE Platform Builder and my code is written in C++ . For each of the folders in the project I'm creating a lib ( the code is statically linked ) . However , there are about 20 libs so far . Is there a way to reduce their number ? I was thinking of creating a lib from other libs , but I don't know if th...
I haven't tried it in a while, but traditionally you could use the librarian tool (LIB.EXE) to do this sort of thing. ``` $ lib /? Microsoft (R) Library Manager Version 8.00.50727.762 Copyright (C) Microsoft Corporation. All rights reserved. usage: LIB [options] [files] options: /DEF[:filename] /ER...
265,585
<p>For example:</p> <pre><code>public class A : A.B { public class B { } } </code></pre> <p>Which generates this error from the compiler:</p> <blockquote> <p>Circular base class dependency involving 'A' and 'A.B'</p> </blockquote> <p>I always figured a nested class behaved just like a regular class except w...
[ { "answer_id": 265599, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": true, "text": "<p>There's no implicit inheritance involved as far as I can tell. I would have expected this to be okay - although I can ...
2008/11/05
[ "https://Stackoverflow.com/questions/265585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34715/" ]
For example: ``` public class A : A.B { public class B { } } ``` Which generates this error from the compiler: > > Circular base class dependency > involving 'A' and 'A.B' > > > I always figured a nested class behaved just like a regular class except with special rules concerning accessing the outer class...
There's no implicit inheritance involved as far as I can tell. I would have expected this to be okay - although I can imagine weirdness if A and B were generic. It's specified in section 10.1.4 of the spec: > > When a class B derives from a class A, > it is a compile-time error for A to > depend on B. A class dire...
265,602
<p>I'm trying to create a simple Java application that displays a frame containing a JButton. I'm using JNI to add transparency to the window. The window is transparent but the button is not. Also, when I move the window the button doesn't move with the window. The same thing happens with a JLabel. If I use a Button in...
[ { "answer_id": 265630, "author": "johnstok", "author_id": 27929, "author_profile": "https://Stackoverflow.com/users/27929", "pm_score": 0, "selected": false, "text": "<p>You may have more success with <a href=\"https://github.com/twall/jna/\" rel=\"nofollow noreferrer\">JNA</a>, and in p...
2008/11/05
[ "https://Stackoverflow.com/questions/265602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22386/" ]
I'm trying to create a simple Java application that displays a frame containing a JButton. I'm using JNI to add transparency to the window. The window is transparent but the button is not. Also, when I move the window the button doesn't move with the window. The same thing happens with a JLabel. If I use a Button inste...
6u10 supports [transparent windows](http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/) through an unofficial API. 6u10 is available for download through java.com and previous JDK versions will update to it or a later update soon.
265,605
<p>I have a stored procedure that creates and opens some cursors. It closes them at the end, but if it hits an error those cursors are left open! Then subsequent runs fail when it tries to create cursors since a cursor with the name already exists.</p> <p>Is there a way I can query which cursors exists and if they a...
[ { "answer_id": 265634, "author": "StingyJack", "author_id": 16391, "author_profile": "https://Stackoverflow.com/users/16391", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa172595(SQL.80).aspx\" rel=\"nofollow noreferrer\">Look here</a> ...
2008/11/05
[ "https://Stackoverflow.com/questions/265605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26197/" ]
I have a stored procedure that creates and opens some cursors. It closes them at the end, but if it hits an error those cursors are left open! Then subsequent runs fail when it tries to create cursors since a cursor with the name already exists. Is there a way I can query which cursors exists and if they are open or n...
This seems to work for me: ``` CREATE PROCEDURE dbo.p_cleanUpCursor @cursorName varchar(255) AS BEGIN DECLARE @cursorStatus int SET @cursorStatus = (SELECT cursor_status('global',@cursorName)) DECLARE @sql varchar(255) SET @sql = '' IF @cursorStatus > 0 SET @sql = 'CLOSE '+@cursorName ...
265,628
<p>I added the columns in the select list to the order by list, but it is still giving me the error:</p> <p>ORDER BY items must appear in the select list if SELECT DISTINCT is specified.</p> <p>Here is the stored proc:</p> <pre><code>CREATE PROCEDURE [dbo].[GetRadioServiceCodesINGroup] @RadioServiceGroup nvarchar(1...
[ { "answer_id": 265637, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 6, "selected": false, "text": "<p>While they are not the same thing, in one sense <code>DISTINCT</code> implies a <code>GROUP BY</code>, because ever...
2008/11/05
[ "https://Stackoverflow.com/questions/265628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I added the columns in the select list to the order by list, but it is still giving me the error: ORDER BY items must appear in the select list if SELECT DISTINCT is specified. Here is the stored proc: ``` CREATE PROCEDURE [dbo].[GetRadioServiceCodesINGroup] @RadioServiceGroup nvarchar(1000) = NULL AS BEGIN SET NOC...
Try this: ``` ORDER BY 1, 2 ``` OR ``` ORDER BY rsc.RadioServiceCodeId, rsc.RadioServiceCode + ' - ' + rsc.RadioService ```
265,639
<p>I've got a text file that contains several 'records' inside of it. Each record contains a name and a collection of numbers as data. </p> <p>I'm trying to build a class that will read through the file, present only the names of all the records, and then allow the user to select which record data he/she wants. </p> ...
[ { "answer_id": 265654, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 3, "selected": false, "text": "<p>You can use a System.IO.FileStream instead of StreamReader. If you know exactly, what file contains ( the encoding for exa...
2008/11/05
[ "https://Stackoverflow.com/questions/265639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've got a text file that contains several 'records' inside of it. Each record contains a name and a collection of numbers as data. I'm trying to build a class that will read through the file, present only the names of all the records, and then allow the user to select which record data he/she wants. The first time...
There are some good answers provided, but I couldn't find some source code that would work in my very simplistic case. Here it is, with the hope that it'll save someone else the hour that I spent searching around. The "very simplistic case" that I refer to is: the text encoding is fixed-width, and the line ending cha...
265,650
<p>I have a question regarding a symptom of my misuse of CreateProcess. I'm using the lpcommandline parameter to feed the path to my executable and parameters. My misuse is that I have not surrounded the path to the exe with quotes. </p> <p>My question is, why does the CreateProcess work just fine on most computers ...
[ { "answer_id": 265847, "author": "Martin York", "author_id": 14065, "author_profile": "https://Stackoverflow.com/users/14065", "pm_score": 2, "selected": false, "text": "<p>You should read this page:<br>\n<a href=\"http://msdn.microsoft.com/en-us/library/ms682425.aspx\" rel=\"nofollow no...
2008/11/05
[ "https://Stackoverflow.com/questions/265650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24979/" ]
I have a question regarding a symptom of my misuse of CreateProcess. I'm using the lpcommandline parameter to feed the path to my executable and parameters. My misuse is that I have not surrounded the path to the exe with quotes. My question is, why does the CreateProcess work just fine on most computers and not othe...
As the document Martin York linked to hinted, CreateProcess() has some behaviour for back-compat with pre-long-name programs. "c:\program files\sub dir\program name arg1 arg2" will look for: > > > ``` > "c:\program.exe" files\sub dir\program name arg1 arg2 > "c:\program files\sub.exe" dir\program name arg1 arg2 > "...
265,669
<p>I have some code that opens a word document using VBScript on an ASP.net page:</p> <pre><code>set objWord = CreateObject("Word.Application") objWord.Visible = True objWord.Documents.Open "c:\inetpub\wwwroot\JSWordTest\test.doc", False, False, False </code></pre> <p>This works great but opens the word doc in anot...
[ { "answer_id": 267116, "author": "unrealtrip", "author_id": 11130, "author_profile": "https://Stackoverflow.com/users/11130", "pm_score": 2, "selected": false, "text": "<p>You can use this technique to get the contents of the Word document without displaying any windows at all. </p>\n\n<...
2008/11/05
[ "https://Stackoverflow.com/questions/265669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23066/" ]
I have some code that opens a word document using VBScript on an ASP.net page: ``` set objWord = CreateObject("Word.Application") objWord.Visible = True objWord.Documents.Open "c:\inetpub\wwwroot\JSWordTest\test.doc", False, False, False ``` This works great but opens the word doc in another window. Ideally I woul...
You can use this technique to get the contents of the Word document without displaying any windows at all. ``` ' Declare an object for the word application ' Set objWord = CreateObject("Word.Application") objWord.Visible = False ' Don''t show word ' objWord.Documents.open("C:\test.doc") ' Open docu...
265,679
<p>I want to do something like this from within Eclipse: <a href="http://svn.collab.net/viewvc/svn?view=rev&amp;revision=33845" rel="nofollow noreferrer">http://svn.collab.net/viewvc/svn?view=rev&amp;revision=33845</a></p> <p>I use Subversive 0.7.5 with the Native JavaHL 1.5.3 (r33570) Connector.</p> <p>I tried to chan...
[ { "answer_id": 265697, "author": "masi", "author_id": 12398, "author_profile": "https://Stackoverflow.com/users/12398", "pm_score": 2, "selected": false, "text": "<p>Found the command line answer myself: \n<a href=\"http://svnbook.red-bean.com/en/1.4/svn.branchmerge.tags.html\" rel=\"nof...
2008/11/05
[ "https://Stackoverflow.com/questions/265679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12398/" ]
I want to do something like this from within Eclipse: <http://svn.collab.net/viewvc/svn?view=rev&revision=33845> I use Subversive 0.7.5 with the Native JavaHL 1.5.3 (r33570) Connector. I tried to change something in a my working copy of a branch i'd like to tag and creating a Tag with Team -> Tag... But I got the err...
Found the command line answer myself: <http://svnbook.red-bean.com/en/1.4/svn.branchmerge.tags.html> ``` svn copy some_branch http://server:8080/svn/tags/TagWithChange -m"TagWithChange" ```
265,680
<p>I'm using AspectJ to advice all the public methods which do have an argument of a chosen class. I tried the following:</p> <pre><code>pointcut permissionCheckMethods(Session sess) : (execution(public * *(.., Session)) &amp;&amp; args(*, sess)); </code></pre> <p>This is working wonderfully for methods with at ...
[ { "answer_id": 320404, "author": "Manrico Corazzi", "author_id": 4690, "author_profile": "https://Stackoverflow.com/users/4690", "pm_score": 4, "selected": true, "text": "<p>Oh well... I worked that around with this nasty trick. Still waiting for someone to show up with an \"official\" p...
2008/11/05
[ "https://Stackoverflow.com/questions/265680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4690/" ]
I'm using AspectJ to advice all the public methods which do have an argument of a chosen class. I tried the following: ``` pointcut permissionCheckMethods(Session sess) : (execution(public * *(.., Session)) && args(*, sess)); ``` This is working wonderfully for methods with at least 2 arguments: ``` public voi...
Oh well... I worked that around with this nasty trick. Still waiting for someone to show up with an "official" pointcut definition. ``` pointcut permissionCheckMethods(EhealthSession eheSess) : (execution(public * *(.., EhealthSession)) && args(*, eheSess)) && !within(it.___.security.PermissionsCheck); point...
265,708
<p>A fairly basic question, but I don't see it asked anywhere.</p> <p>Let's say we have a global struct (in C) like so:</p> <pre><code>struct foo { int written_frequently1; int read_only; int written_frequently2; }; </code></pre> <p>It seems clear to me that if we have lots of threads reading and writing, we n...
[ { "answer_id": 265721, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 1, "selected": false, "text": "<p>If all the threads are only reading, you don't need a semaphore.</p>\n" }, { "answer_id": 265723, "auth...
2008/11/05
[ "https://Stackoverflow.com/questions/265708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15456/" ]
A fairly basic question, but I don't see it asked anywhere. Let's say we have a global struct (in C) like so: ``` struct foo { int written_frequently1; int read_only; int written_frequently2; }; ``` It seems clear to me that if we have lots of threads reading and writing, we need a semaphore (or other lock) o...
Many thanks to all the great answerers (and for all the great answers). To sum up: If there is a read-only member of a struct (in our case, if the value is set once, long before any thread might want to read it), then threads reading this member do not need locks, mutexes, semaphores, or any other concurrency protec...
265,720
<p>In Python 2.6, a new "timeout" parameter was added to the httplib.HTTPConnection class: <a href="http://docs.python.org/library/httplib.html#httplib.HTTPConnection" rel="nofollow noreferrer">http://docs.python.org/library/httplib.html#httplib.HTTPConnection</a></p> <p>However, this is only a timeout for the connect...
[ { "answer_id": 265741, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "<p>You can set a global socket timeout <sup>(*)</sup>:</p>\n\n<pre><code>import socket\n\ntimeout = 10\nsocket.setdefaultti...
2008/11/05
[ "https://Stackoverflow.com/questions/265720", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16148/" ]
In Python 2.6, a new "timeout" parameter was added to the httplib.HTTPConnection class: <http://docs.python.org/library/httplib.html#httplib.HTTPConnection> However, this is only a timeout for the connection to a server. I am looking to set a timeout value for the **request**, not the connection. This doesn't seem to ...
You can set a global socket timeout (\*): ``` import socket timeout = 10 socket.setdefaulttimeout(timeout) ``` --- (\*) **EDIT**: As people in the comments correctly point out: This is technically true, but it only has predictable results for tasks that involve a single socket operation. An HTTP request consists o...
265,725
<p>I have some constants that represent the valid options in one of my model's fields. What's the best way to handle these constants in Ruby?</p>
[ { "answer_id": 265767, "author": "Micah", "author_id": 19964, "author_profile": "https://Stackoverflow.com/users/19964", "pm_score": 4, "selected": false, "text": "<p>I put them directly in the model class, like so:</p>\n\n<pre><code>class MyClass &lt; ActiveRecord::Base\n ACTIVE_STATUS...
2008/11/05
[ "https://Stackoverflow.com/questions/265725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34746/" ]
I have some constants that represent the valid options in one of my model's fields. What's the best way to handle these constants in Ruby?
You can use an array or hash for this purpose (in your environment.rb): ``` OPTIONS = ['one', 'two', 'three'] OPTIONS = {:one => 1, :two => 2, :three => 3} ``` or alternatively an enumeration class, which allows you to enumerate over your constants as well as the keys used to associate them: ``` class Enumeration ...