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 |
|---|---|---|---|---|---|---|
378,786 | <p>When writing an abstract class, or a class that doesn't get instantiated directly... do you tend to write a dealloc method in the abstract class and release where appropriate, and then allow for children to call [super dealloc] and then worry about only instance variables they add which aren't part of the super clas... | [
{
"answer_id": 378868,
"author": "Stephan Eggermont",
"author_id": 35306,
"author_profile": "https://Stackoverflow.com/users/35306",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, you take responsibility for yourself, not for super or subclasses. </p>\n"
},
{
"answer_id": 3790... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | When writing an abstract class, or a class that doesn't get instantiated directly... do you tend to write a dealloc method in the abstract class and release where appropriate, and then allow for children to call [super dealloc] and then worry about only instance variables they add which aren't part of the super class?
... | Yes, you take responsibility for yourself, not for super or subclasses. |
378,801 | <p>Here is the basic situation.</p>
<pre><code>Public Class MyEnumClass(of T)
Public MyValue as T
End Class
</code></pre>
<p>This is vast oversimplification of the actual class, but basically I know that T is an enumeration (if it is not then there will be many other problems, and is a logical error made by the pr... | [
{
"answer_id": 378824,
"author": "Ross Goddard",
"author_id": 4779,
"author_profile": "https://Stackoverflow.com/users/4779",
"pm_score": 3,
"selected": false,
"text": "<p>I tried this and it worked:</p>\n\n<pre><code>String.Format(\"{0:d}\", MyValue)\n</code></pre>\n"
},
{
"answ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4779/"
] | Here is the basic situation.
```
Public Class MyEnumClass(of T)
Public MyValue as T
End Class
```
This is vast oversimplification of the actual class, but basically I know that T is an enumeration (if it is not then there will be many other problems, and is a logical error made by the programmer)
Basically I wan... | I was going to use a cool piece of reflection code but just a simple [`Convert.ToInt32`](https://msdn.microsoft.com/en-us/library/system.convert.toint32(v=vs.110).aspx) works great... Forgive my VB I'm a C# guy
```
Public Function GetEnumInt(Of T)(enumVal As T) As Integer
Return Convert.ToInt32(enumVal)
End Functi... |
378,811 | <p>I'm trying to get Python scripts, called from a web browser, to work. I keep getting the error: </p>
<pre><code>500 Internal Server Error
</code></pre>
<p>When I check my error logs I see the message </p>
<pre><code>Premature end of script headers
</code></pre>
<p>The only documentation of this error online says... | [
{
"answer_id": 378822,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 3,
"selected": false,
"text": "<p>Two things spring immediately to mind. </p>\n\n<ol>\n<li>Make sure you are outputting the <code>Content-Type: text... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47514/"
] | I'm trying to get Python scripts, called from a web browser, to work. I keep getting the error:
```
500 Internal Server Error
```
When I check my error logs I see the message
```
Premature end of script headers
```
The only documentation of this error online says that it can be the result of having improper lin... | This is the exact behavior you would get if your Python script does not have the executable permission set.
Try:
```
chmod a+x foo.py
```
(where foo.py is your script name).
See the [Apache tutorial](http://httpd.apache.org/docs/1.3/howto/cgi.html#filepermissions) for more information. |
378,829 | <p>In a UNIX shell script, what can I use to convert decimal numbers into hexadecimal? I thought od would do the trick, but it's not realizing I'm feeding it ASCII representations of numbers.</p>
<p>printf? Gross! Using it for now, but what else is available?</p>
| [
{
"answer_id": 378839,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 8,
"selected": false,
"text": "<p>Tried <code>printf(1)</code>?</p>\n\n<pre><code>printf \"%x\\n\" 34\n22\n</code></pre>\n\n<p>There are probably ways of ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | In a UNIX shell script, what can I use to convert decimal numbers into hexadecimal? I thought od would do the trick, but it's not realizing I'm feeding it ASCII representations of numbers.
printf? Gross! Using it for now, but what else is available? | ```
echo "obase=16; 34" | bc
```
If you want to filter a whole file of integers, one per line:
```
( echo "obase=16" ; cat file_of_integers ) | bc
``` |
378,832 | <p>i have sql statement like this </p>
<pre><code>SELECT DISTINCT results_sp_08.material_number FROM results_sp_08
INNER JOIN courses ON results_sp_08.material_number = courses.material_number
INNER JOIN users ON results_sp_08.id = users.id
AND results_sp_08.doctor = 'xx260'
</code></pre>
<p>i... | [
{
"answer_id": 378838,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 0,
"selected": false,
"text": "<p>I usually use a double-join strategy on these:</p>\n\n<pre><code>JOIN tablex AS x1 ON whatever \nLEFT JOIN tablex AS x2... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47507/"
] | i have sql statement like this
```
SELECT DISTINCT results_sp_08.material_number FROM results_sp_08
INNER JOIN courses ON results_sp_08.material_number = courses.material_number
INNER JOIN users ON results_sp_08.id = users.id
AND results_sp_08.doctor = 'xx260'
```
i need alternative way to D... | Like Joel, your best bet is to add the GROUP BY clause. In your case
```
GROUP BY results_sp_08.material_number
``` |
378,847 | <p><code>CGI.escapeHTML</code> is pretty bad, but <code>CGI.unescapeHTML</code> is completely borked. For example:</p>
<pre><code>require 'cgi'
CGI.unescapeHTML('&#8230;')
# => "…" # correct - an ellipsis
CGI.unescapeHTML('&hellip;')
# => "&hellip;" # should be "…"
... | [
{
"answer_id": 379680,
"author": "Chris Lloyd",
"author_id": 42413,
"author_profile": "https://Stackoverflow.com/users/42413",
"pm_score": 2,
"selected": false,
"text": "<pre><code>require 'rubygems'\nrequire 'hpricot'\n\nHpricot('&#8230;', :xhtml_strict => true).to_plain_text\n</... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | `CGI.escapeHTML` is pretty bad, but `CGI.unescapeHTML` is completely borked. For example:
```
require 'cgi'
CGI.unescapeHTML('…')
# => "…" # correct - an ellipsis
CGI.unescapeHTML('…')
# => "…" # should be "…"
CGI.unescapeHTML('¢')
# => "\242" ... | The htmlentities gem should do the trick:
```
require 'rubygems'
require 'htmlentities'
coder = HTMLEntities.new
coder.decode('…') # => "…"
coder.decode('…') # => "…"
coder.decode('¢') # => "¢"
coder.decode('¢') # => "¢"
coder.encode("…", :named) # => "…"
coder.encode("…", :decimal) # =... |
378,848 | <p>I'm wanting to capture my search terms and pass them to a JavaScript variable, but I don't know how to handle quotes that might come through.</p>
<p>Here's what I have currently:</p>
<pre><code>var searchTerms = "<!--#echo var="terms"-->";
var pattern = / /g;
newSearchTerms = searchTerms.replace(/[^a-zA-Z 0-... | [
{
"answer_id": 378874,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 2,
"selected": false,
"text": "<p>If <code>terms</code> contains quotation marks, by the time you have done <code>var searchTerms = \"<!--#echo var... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378848",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] | I'm wanting to capture my search terms and pass them to a JavaScript variable, but I don't know how to handle quotes that might come through.
Here's what I have currently:
```
var searchTerms = "<!--#echo var="terms"-->";
var pattern = / /g;
newSearchTerms = searchTerms.replace(/[^a-zA-Z 0-9]+/g,'');
var searchStr=ne... | If `terms` contains quotation marks, by the time you have done `var searchTerms = "<!--#echo var="terms"-->";` it is already too late to replace any quotation marks, your JavaScript will be invalid. For example, if `terms` contains **These are the "terms"** your JavaScript would appear as follows (and produce a syntax ... |
378,862 | <p>I need to update a field (which is currently empty) based on a match with another table. This should be simple, but my syntax is wrong.</p>
<p>In SQLServer 2005, the syntax would be </p>
<pre><code>UPDATE Facilities-NOID
SET Facilities-NOID.ID = Facilities-ID.ID
FROM Facilities-NOID, Facilities-ID
WHERE [Faciliti... | [
{
"answer_id": 378986,
"author": "BIBD",
"author_id": 685,
"author_profile": "https://Stackoverflow.com/users/685",
"pm_score": 0,
"selected": false,
"text": "<p>Remove the FROM clause completely</p>\n\n<pre><code>UPDATE Facilities-NOID\nSET Facilities-NOID.ID = Facilities-ID.ID\nWHERE [... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22523/"
] | I need to update a field (which is currently empty) based on a match with another table. This should be simple, but my syntax is wrong.
In SQLServer 2005, the syntax would be
```
UPDATE Facilities-NOID
SET Facilities-NOID.ID = Facilities-ID.ID
FROM Facilities-NOID, Facilities-ID
WHERE [Facilities-ID].[Structure ID] ... | I think this is what you want:
```
UPDATE Facilities-NOID
INNER JOIN Facilities-ID ON Facilities-NOID.[Structure ID]
= Facilities-ID.[Structure ID]
SET Facilities-NOID.ID= Facilities-ID.ID
```
You are updating Facilities-NOID based on a match on Structure ID occurring in Facilities-ID. |
378,864 | <p>I need to convert a name in the format Parisi, Kenneth into the format kparisi.</p>
<p>Does anyone know how to do this in Perl?<br></p>
<p>Here is some sample data that is abnormal:</p>
<p>Zelleb, Charles F.,,IV<br>
Eilt, John,, IV<br>
Wods, Charles R.,,III<br>
Welkt, Craig P.,,Jr.<br></p>
<p>These specific name... | [
{
"answer_id": 378878,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>$name =~ s/(\\w+),\\s(\\w)/$2$1/;\n$name = lc $name;\n</code></pre>\n\n<p><code>\\w</code> ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42229/"
] | I need to convert a name in the format Parisi, Kenneth into the format kparisi.
Does anyone know how to do this in Perl?
Here is some sample data that is abnormal:
Zelleb, Charles F.,,IV
Eilt, John,, IV
Wods, Charles R.,,III
Welkt, Craig P.,,Jr.
These specific names should end up as czelleb, jeilt, cwo... | ```
vinko@parrot:~$ cat genlogname.pl
```
```
use strict;
use warnings;
my @list;
push @list, "Zelleb, Charles F.,,IV";
push @list, "Eilt, John,, IV";
push @list, "Woods, Charles R.,,III";
push @list, "Welkt, Craig P.,,Jr.";
for my $name (@list) {
print gen_logname($name)."\n";
}
sub gen_logname {
... |
378,876 | <p>Consider the following example. It consists of two header files, declaring two different namespaces:</p>
<pre><code>// a1.h
#pragma once
#include "a2.h"
namespace a1
{
const int x = 10;
typedef a2::C B;
}
</code></pre>
<p>and the second one is</p>
<pre><code>// a2.h
#pragma once
#include "a1.h"
nam... | [
{
"answer_id": 378903,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 2,
"selected": false,
"text": "<p>Just a guess, but your include reference is circular. Meaning the compiler can't figure out which header to compil... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13543/"
] | Consider the following example. It consists of two header files, declaring two different namespaces:
```
// a1.h
#pragma once
#include "a2.h"
namespace a1
{
const int x = 10;
typedef a2::C B;
}
```
and the second one is
```
// a2.h
#pragma once
#include "a1.h"
namespace a2 {
class C {
public:
... | You need to use a forward declaration in your header files because you have a circular reference. Something like this:
```
// a1.h
#pragma once
namespace a2 {
class C;
}
namespace a1
{
const int x = 10;
typedef a2::C B;
}
``` |
378,880 | <p>I hope this isn't a waste of time, however I have really been trying to figure this on out. Is it my syntax. I simply want to remove the parent div ".number-row" once the link with a class of ".remove-link" is clicked.</p>
<p>Thanks in advance</p>
<pre><code><script>
$(document).ready(function(){
$(".rem... | [
{
"answer_id": 378898,
"author": "cLFlaVA",
"author_id": 45109,
"author_profile": "https://Stackoverflow.com/users/45109",
"pm_score": 2,
"selected": false,
"text": "<p>This should do it...</p>\n\n<pre><code>$(document).ready(function(){ \n $(\".remove-link\").click(function() { \n ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I hope this isn't a waste of time, however I have really been trying to figure this on out. Is it my syntax. I simply want to remove the parent div ".number-row" once the link with a class of ".remove-link" is clicked.
Thanks in advance
```
<script>
$(document).ready(function(){
$(".remove-link").click(function()... | Try [parents()](http://docs.jquery.com/Traversing/parents) instead of [parent()](http://docs.jquery.com/Traversing/parent):
```
$(document).ready(function(){
$(".remove-link").click(function() {
$(this).parents(".number-row").eq(0).hide();
})
})
``` |
378,883 | <p>I want my web application users to download some data as an Excel file. </p>
<p>I have the next function to send an Input Stream in the response object. </p>
<pre><code>public static void sendFile(InputStream is, HttpServletResponse response) throws IOException {
BufferedInputStream in = null;
try... | [
{
"answer_id": 379148,
"author": "lucas",
"author_id": 31172,
"author_profile": "https://Stackoverflow.com/users/31172",
"pm_score": 0,
"selected": false,
"text": "<p>I think I understand what you're trying to do (maybe I am undershooting, though)</p>\n\n<p>you don't really need that muc... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I want my web application users to download some data as an Excel file.
I have the next function to send an Input Stream in the response object.
```
public static void sendFile(InputStream is, HttpServletResponse response) throws IOException {
BufferedInputStream in = null;
try {
int cou... | The problem with your question is that you are mixing OutputStreams and InputStreams. An InputStream is something you read from and an OutputStream is something you write to.
This is how I write a POI object to the output stream.
```
// this part is important to let the browser know what you're sending
response.setC... |
378,887 | <p><code>String.length</code> will only tell me how many characters are in the String. (In fact, before Ruby 1.9, it will only tell me how many bytes, which is even less useful.)</p>
<p>I'd really like to be able to find out how many 'en' wide a String is. For example:</p>
<pre><code>'foo'.width
# => 3
'moo'.wi... | [
{
"answer_id": 379597,
"author": "krusty.ar",
"author_id": 43981,
"author_profile": "https://Stackoverflow.com/users/43981",
"pm_score": 2,
"selected": false,
"text": "<p>You could attempt to create a standarized \"width proportion table\" to calculate an aproximation, basically you need... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | `String.length` will only tell me how many characters are in the String. (In fact, before Ruby 1.9, it will only tell me how many bytes, which is even less useful.)
I'd really like to be able to find out how many 'en' wide a String is. For example:
```
'foo'.width
# => 3
'moo'.width
# => 3.5 # m's, w's, etc... | You should use the RMagick gem to render a "Draw" object using the font you want (you can load .ttf files and such)
The code would look something like this:
```
the_text = "TheTextYouWantTheWidthOf"
label = Draw.new
label.font = "Vera" #you can also specify a file name... check the rmagick docs to be sure
... |
378,895 | <p>I'm having a little bit of trouble understanding what the problem is here. I have a bit of code that pulls records from a database using LINQ and puts them into an object which is cast into an interface. It looks a bit like this:</p>
<pre><code>public IEnumerable<ISomeObject> query()
{
return from a in ... | [
{
"answer_id": 378931,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 3,
"selected": false,
"text": "<p>Just a guess, but the <strong>as</strong> operator may return a null - so it may have to do with the actual impleme... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | I'm having a little bit of trouble understanding what the problem is here. I have a bit of code that pulls records from a database using LINQ and puts them into an object which is cast into an interface. It looks a bit like this:
```
public IEnumerable<ISomeObject> query()
{
return from a in dc.SomeTable
... | I believe it is an issue of covariance or contravariance as noted by [this forum post](http://www.manning-sandbox.com/message.jspa?messageID=77137#77137).
See [Covariance and Contravariance in C#, Part Two: Array Covariance](http://blogs.msdn.com/ericlippert/archive/2007/10/17/covariance-and-contravariance-in-c-part-t... |
378,905 | <p>I have to ship some groovy code to some users that have only java installed (no grooy, no $groovy_home, etc). I'm trying to invoke groovy from the commandline but I'm having no luck. Here's my bat file:</p>
<pre><code>java -classpath .;lib;bin;bin-groovy introspector.AclCollector
</code></pre>
<p>And here's my exc... | [
{
"answer_id": 378915,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 4,
"selected": true,
"text": "<p>I think you need to explicitly list the groovy jar in the classpath</p>\n"
},
{
"answer_id": 379045,
"au... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22992/"
] | I have to ship some groovy code to some users that have only java installed (no grooy, no $groovy\_home, etc). I'm trying to invoke groovy from the commandline but I'm having no luck. Here's my bat file:
```
java -classpath .;lib;bin;bin-groovy introspector.AclCollector
```
And here's my exception:
```
Exception in... | I think you need to explicitly list the groovy jar in the classpath |
378,909 | <p>I created a NamedTemporaryFile, added some content in it and now I want to save it into a model FileField. </p>
<p>The problem is that I get a SuspiciousOperation because the tmp directory is not within the FileSystemStorage directory.</p>
<p>What's the proper way to do this?</p>
| [
{
"answer_id": 380810,
"author": "rombarcz",
"author_id": 47267,
"author_profile": "https://Stackoverflow.com/users/47267",
"pm_score": 2,
"selected": false,
"text": "<p>You want django to check it for you because it ensures file is put inside MEDIA_ROOT dir so it's accessible for downlo... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1044/"
] | I created a NamedTemporaryFile, added some content in it and now I want to save it into a model FileField.
The problem is that I get a SuspiciousOperation because the tmp directory is not within the FileSystemStorage directory.
What's the proper way to do this? | You want django to check it for you because it ensures file is put inside MEDIA\_ROOT dir so it's accessible for download.
In any case you want to put files outside MEDIA\_ROOT (in this case '/tmp') you should do something like this:
```
from django.core.files.storage import FileSystemStorage
fs = FileSystemStorage(l... |
378,927 | <p>I need to know if a variable in Python is a string or a dict. Is there anything wrong with the following code?</p>
<pre><code>if type(x) == type(str()):
do_something_with_a_string(x)
elif type(x) == type(dict()):
do_somethting_with_a_dict(x)
else:
raise ValueError
</code></pre>
<p><strong>Update</stro... | [
{
"answer_id": 378957,
"author": "nakedfanatic",
"author_id": 44817,
"author_profile": "https://Stackoverflow.com/users/44817",
"pm_score": 2,
"selected": false,
"text": "<p>That should work - so no, there is nothing wrong with your code. However, it could also be done with a dict:</p>\n... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4766/"
] | I need to know if a variable in Python is a string or a dict. Is there anything wrong with the following code?
```
if type(x) == type(str()):
do_something_with_a_string(x)
elif type(x) == type(dict()):
do_somethting_with_a_dict(x)
else:
raise ValueError
```
**Update**: I accepted avisser's answer (though... | What happens if somebody passes a unicode string to your function? Or a class derived from dict? Or a class implementing a dict-like interface? Following code covers first two cases. If you are using Python 2.6 you might want to use [`collections.Mapping`](https://docs.python.org/2/library/collections.html#collections.... |
378,942 | <p>Emacs Lisp function often start like this:</p>
<pre><code>(lambda () (interactive) ...
</code></pre>
<p>What does "(interactive)" do?</p>
| [
{
"answer_id": 378960,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 4,
"selected": false,
"text": "<p>I means that you're including some code for the things you need to make a function callable when bound to a key ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | Emacs Lisp function often start like this:
```
(lambda () (interactive) ...
```
What does "(interactive)" do? | Just to clarify (it is in the quoted docs [that Charlie cites](https://stackoverflow.com/questions/378942/what-does-interactive-mean-in-an-emacs-lisp-function#378960)) `(interactive)` is not just for key-bound functions, but for any function. Without `(interactive)`, it can only be called programmatically, not from `M-... |
378,958 | <p>There is someone in my team that swears by using some kind of GVim feature to do manually code folding.</p>
<p>As I'm using another editor and do not really need the folding feature, I think it only pollutes the source code with tags like:</p>
<pre><code>/* {{{1 */
</code></pre>
<p>Convincing the person not to us... | [
{
"answer_id": 379001,
"author": "grieve",
"author_id": 34329,
"author_profile": "https://Stackoverflow.com/users/34329",
"pm_score": 3,
"selected": false,
"text": "<p>I would imagine he could just add the following to his .vimrc: </p>\n\n<pre><code>set foldmethod=syntax\n</code></pre>\n... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26387/"
] | There is someone in my team that swears by using some kind of GVim feature to do manually code folding.
As I'm using another editor and do not really need the folding feature, I think it only pollutes the source code with tags like:
```
/* {{{1 */
```
Convincing the person not to use this folding is not an option (... | It only took a Google for "vim folding" to [discover](http://www.vim.org/htmldoc/fold.html) that Vim supports six fold methods.
`syntax`, `indent` and `diff` all mean that the user has little control over where the folding happens. That may or may not be a problem.
`marker` is a problem for you because you don't like... |
378,969 | <p>I have the following Int lists:</p>
<pre><code>t1 = [1000, 1001, 1002, 1003, 1004]
t2 = [2000, 2001, 2002]
t3 = [3000, 3001, 3002, 3003]
</code></pre>
<p>The lists size are variable, they are not just 3 like in this example. They can have 1 element or many more. Then I have this:</p>
<pre><code>tAll = [t1, t2, t3... | [
{
"answer_id": 379037,
"author": "comingstorm",
"author_id": 210211,
"author_profile": "https://Stackoverflow.com/users/210211",
"pm_score": 1,
"selected": false,
"text": "<p><code>zip3</code> will turn the 3 lists into a single list of triples. If you want length-three lists instead, y... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40480/"
] | I have the following Int lists:
```
t1 = [1000, 1001, 1002, 1003, 1004]
t2 = [2000, 2001, 2002]
t3 = [3000, 3001, 3002, 3003]
```
The lists size are variable, they are not just 3 like in this example. They can have 1 element or many more. Then I have this:
```
tAll = [t1, t2, t3]
```
I need a function that "turns... | Well, this is the Haskell beginner's way to write it, but since it's doing explicit recursion there is probably a better way. :-)
```
head0 [] = 0
head0 xs = head xs
tail0 [] = []
tail0 xs = tail xs
nreorder n ts
| all null ts = []
| otherwise = (n : map head0 ts) : nreorder (n+1) (map tail0 ts)
```
And `nre... |
378,972 | <p>I've got a variable in Emacs called my-var that I'd like to set whenever I press C-v. How do I do that? I tried this:</p>
<pre><code>(defun set-my-var (value)
"set my var"
(interactive)
(defvar my-var value
"a variable of mine")
)
(global-set-key "\C-v" 'set-my-var)
</code></pre>
<p>But that fails:</p>
... | [
{
"answer_id": 379004,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>It's in the argument. Look over at the text I just posted about <code>(interactive)</code>. When you bind <cod... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | I've got a variable in Emacs called my-var that I'd like to set whenever I press C-v. How do I do that? I tried this:
```
(defun set-my-var (value)
"set my var"
(interactive)
(defvar my-var value
"a variable of mine")
)
(global-set-key "\C-v" 'set-my-var)
```
But that fails:
```
call-interactively: Wrong... | Actually, defvar doesn't do what you think it does either: it only changes the value IF there was no value before. Here's a chunk that does what you're looking for, using the CTRL-u argument:
```
(defun set-my-var (value)
"Revised version by Charlie Martin"
(interactive "p")
(setq my-var value))
```
and here's... |
378,979 | <p>Is it possible to use a converter within a style? For instance I am trying to create a styled <code>TextBlock</code> whose text resizes based on the <code>ActualHeight</code> property of the <code>TextBlock</code>. The resizing would be done via a converter.</p>
| [
{
"answer_id": 379032,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 6,
"selected": true,
"text": "<p>Yes, this is possible. For example:</p>\n\n<pre><code><Style TargetType=\"TextBlock\">\n <Setter Propert... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to use a converter within a style? For instance I am trying to create a styled `TextBlock` whose text resizes based on the `ActualHeight` property of the `TextBlock`. The resizing would be done via a converter. | Yes, this is possible. For example:
```
<Style TargetType="TextBlock">
<Setter Property="FontSize">
<Setter.Value>
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<MyConverter/>
</Binding.Converter>
... |
378,982 | <p>Can I do something like this in the markup of an asp.net page, based off the "Define DEBUG constant" setting?</p>
<pre><code>#IF (DEBUG) THEN
<asp:TextBox ID="TextBox1" runat="server">You're in debug mode</asp:TextBox>
#END IF
</code></pre>
| [
{
"answer_id": 379000,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": -1,
"selected": false,
"text": "<p>It would be easy enough to roll your own. You might miss some of the cooler non-compiling features of Compilation Const... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44394/"
] | Can I do something like this in the markup of an asp.net page, based off the "Define DEBUG constant" setting?
```
#IF (DEBUG) THEN
<asp:TextBox ID="TextBox1" runat="server">You're in debug mode</asp:TextBox>
#END IF
``` | The close as I can get is:
```
<asp:Literal id="isDebug" runat="server" />
<script runat="server">
void Page_Load()
{
#if DEBUG
isDebug.Text = "You're in debug mode";
#endif
}
</script>
```
This would give you problems if you wanted to have anything else in your Page\_Load() event; the literal c... |
378,983 | <p>I'm using IPAddress.TryParse() to parse IP addresses. However, it's a little too permissive (parsing "1" returns 0.0.0.1). I'd like to limit the input to dotted octet notation. What's the best way to do this?</p>
<p>(Note: I'm using .NET 2.0)</p>
<hr>
<p><strong>Edit</strong></p>
<p>Let me clarify:</p>
<p>I'm w... | [
{
"answer_id": 379005,
"author": "Brian Rasmussen",
"author_id": 38206,
"author_profile": "https://Stackoverflow.com/users/38206",
"pm_score": 0,
"selected": false,
"text": "<p>An IP address is actually a 32 bit number - it is not xxx.xxx.xxx.xxx - that's just a human readable format for... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27414/"
] | I'm using IPAddress.TryParse() to parse IP addresses. However, it's a little too permissive (parsing "1" returns 0.0.0.1). I'd like to limit the input to dotted octet notation. What's the best way to do this?
(Note: I'm using .NET 2.0)
---
**Edit**
Let me clarify:
I'm writing an app that will scan a range of IPs l... | If you are interested in parsing the format, then I'd use a regular expression. Here's a good one ([source](http://www.regular-expressions.info/regexbuddy/ipquick.html)):
```
bool IsDottedDecimalIP(string possibleIP)
{
Regex R = New Regex(@"\b(?:\d{1,3}\.){3}\d{1,3}\b");
return R.IsMatch(possibleIP) && Net.IPA... |
378,985 | <p>I am having trouble with visible attribute of an ASP.NET <code>Panel</code> control. I have a page that calls a database table and returns the results in a datagrid.</p>
<h3>Requirements</h3>
<p>If some of the returned values are <code>null</code> I need to hide the image that's next to it.</p>
<p>I am using a <code... | [
{
"answer_id": 379006,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 0,
"selected": false,
"text": "<p>try comparing the result of the eval to blank as opposed to null. </p>\n"
},
{
"answer_id": 379028,
"author"... | 2008/12/18 | [
"https://Stackoverflow.com/questions/378985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am having trouble with visible attribute of an ASP.NET `Panel` control. I have a page that calls a database table and returns the results in a datagrid.
### Requirements
If some of the returned values are `null` I need to hide the image that's next to it.
I am using a `Panel` to determine whether to hide or show t... | try:
`<%# String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem,"addr1").ToString()) #>` |
379,007 | <p>Your basic SP with a default parameter:</p>
<pre><code>ALTER PROCEDURE [usp_debug_fails]
@DATA_DT_ID AS int = 20081130
WITH RECOMPILE
AS
BEGIN
/*
Usage:
EXEC [usp_debug_fails] WITH RECOMPILE
*/
-- Stuff here that depends on DATA_DT_ID
END
</code></pre>
<p>The same SP with a local th... | [
{
"answer_id": 379067,
"author": "gbn",
"author_id": 27535,
"author_profile": "https://Stackoverflow.com/users/27535",
"pm_score": 3,
"selected": true,
"text": "<p>Try masking the input parameter.</p>\n\n<p>I guess the recompile isn't working because of the specified default (<strong>EDI... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18255/"
] | Your basic SP with a default parameter:
```
ALTER PROCEDURE [usp_debug_fails]
@DATA_DT_ID AS int = 20081130
WITH RECOMPILE
AS
BEGIN
/*
Usage:
EXEC [usp_debug_fails] WITH RECOMPILE
*/
-- Stuff here that depends on DATA_DT_ID
END
```
The same SP with a local that is hardcoded.
```
ALTE... | Try masking the input parameter.
I guess the recompile isn't working because of the specified default (**EDIT**: Or parameter sent on first call) being sniffed at compile time. So, recompile has no effect.
I've seen huge difference between estimated plans simply by changing the default from say, zero to NULL, or not ... |
379,027 | <p>Here is an example:</p>
<pre><code> <h:outputText value="#{myBean.myMoney}">
<f:convertNumber type="currency" currencySymbol="$" />
</h:outputText>
</code></pre>
<p>Given that I have $1.006, will this output $1.00 or $1.01?</p>
<p>Doesn't say here:
<a href="http://java.sun.com/java... | [
{
"answer_id": 379500,
"author": "s_t_e_v_e",
"author_id": 21176,
"author_profile": "https://Stackoverflow.com/users/21176",
"pm_score": 4,
"selected": true,
"text": "<p>Answer=Rounded</p>\n\n<p>Hmmm....does that sound right? I don't think its a good idea to be rounding up money. Hopef... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21176/"
] | Here is an example:
```
<h:outputText value="#{myBean.myMoney}">
<f:convertNumber type="currency" currencySymbol="$" />
</h:outputText>
```
Given that I have $1.006, will this output $1.00 or $1.01?
Doesn't say here:
<http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/tlddocs/f/convertNumber.html... | Answer=Rounded
Hmmm....does that sound right? I don't think its a good idea to be rounding up money. Hopefully no banking apps are going to rely on this one.
Brings to mind this scene from One Flew Over the Cuckoo's Nest...
>
> [the inmates are playing cards and betting with cigarettes]
>
> Martini: [rips a cig... |
379,041 | <p>When I write a class I always expose private fields through a public property like this:</p>
<pre><code>private int _MyField;
public int MyField
{ get{return _MyField; }
</code></pre>
<p>When is it ok to just expose a public field like this:</p>
<pre><code>public int MyField;
</code></pre>
<p>I am creating a str... | [
{
"answer_id": 379054,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": 2,
"selected": false,
"text": "<p>The best practice is to use properties for several reasons. First, it decouples the API from the underlying data struct... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | When I write a class I always expose private fields through a public property like this:
```
private int _MyField;
public int MyField
{ get{return _MyField; }
```
When is it ok to just expose a public field like this:
```
public int MyField;
```
I am creating a structure called Result and my intention is do this:... | I only ever expose public fields when they're (static) constants - and even then I'd usually use a property.
By "constant" I mean any readonly, immutable value, not just one which may be expressed as a "const" in C#.
Even readonly *instance* variables (like Result and Message) should be encapsulated in a property in ... |
379,053 | <p>I know that having diamond inheritance is considered bad practice. However, I have 2 cases in which I feel that diamond inheritance could fit very nicely. I want to ask, would you recommend me to use diamond inheritance in these cases, or is there another design that could be better.</p>
<p><strong>Case 1:</strong>... | [
{
"answer_id": 379101,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 3,
"selected": false,
"text": "<p>There's a design-quality difference between implementation-oriented diamond inheritance where implementation is inherited (... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44673/"
] | I know that having diamond inheritance is considered bad practice. However, I have 2 cases in which I feel that diamond inheritance could fit very nicely. I want to ask, would you recommend me to use diamond inheritance in these cases, or is there another design that could be better.
**Case 1:** I want to create class... | Inheritance is the second strongest (more coupling) relations in C++, preceded only by friendship. If you can redesign into using only composition your code will be more loosely coupled. If you cannot, then you should consider whether all your classes should really inherit from the base. Is it due to implementation or ... |
379,068 | <p>I've got a working SOAP::Lite client. It works against an established server, but so far my development server is sending back nothing except a 404. (Which is odd, because I'm not even seeing a connection on the server end.)</p>
<p>The closest parallel that I'm used to is <code>Net::FTP</code>. </p>
<pre><code>my ... | [
{
"answer_id": 379087,
"author": "Stephane Grenier",
"author_id": 39371,
"author_profile": "https://Stackoverflow.com/users/39371",
"pm_score": 4,
"selected": false,
"text": "<p>Mostly it's just experience and proper indenting.</p>\n"
},
{
"answer_id": 379088,
"author": "Eran... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11289/"
] | I've got a working SOAP::Lite client. It works against an established server, but so far my development server is sending back nothing except a 404. (Which is odd, because I'm not even seeing a connection on the server end.)
The closest parallel that I'm used to is `Net::FTP`.
```
my $ftp = Net::FTP->new( "some.host... | When I look at a complex bit of SQL Code, this is what I do.
First, if it is an update or delete, I add code (if it isn't there and commented out) to make it a select. Never try an update or delete for the first time without seeing the results in a select first. If it is an update, I make sure the select shows the cur... |
379,081 | <p>Tracking a single remote branch as a local branch is straightforward enough. </p>
<pre><code>$ git checkout --track -b ${branch_name} origin/${branch_name}
</code></pre>
<p>Pushing all local branches up to the remote, creating new remote branches as needed is also easy.</p>
<pre><code>$ git push --all origin
</co... | [
{
"answer_id": 379213,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 4,
"selected": false,
"text": "<p>You could script that easily enough, but I don't know when it'd be valuable. Those branches would pretty quickly fall b... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47532/"
] | Tracking a single remote branch as a local branch is straightforward enough.
```
$ git checkout --track -b ${branch_name} origin/${branch_name}
```
Pushing all local branches up to the remote, creating new remote branches as needed is also easy.
```
$ git push --all origin
```
I want to do the reverse. If I have... | Using bash:
**after git 1.9.1**
```
for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done
```
>
> **credits:** Val Blant, elias, and Hugo
>
>
>
**before git 1.9.1**
>
> **Note:** the following code if used in later versions of git (>v1.9.1... |
379,105 | <p>Is it possible to specify my own default object instead of it being null? I would like to define my own default properties on certain objects.</p>
<p>For example, if I have an object foo with properties bar and baz, instead of default returing null, I'd like it to be an instance of foo with bar set to "abc" and ba... | [
{
"answer_id": 379112,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>No you cant. Sorry.</p>\n"
},
{
"answer_id": 379129,
"author": "recursive",
"author_id": 44743,
"author... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4068/"
] | Is it possible to specify my own default object instead of it being null? I would like to define my own default properties on certain objects.
For example, if I have an object foo with properties bar and baz, instead of default returing null, I'd like it to be an instance of foo with bar set to "abc" and baz set to "d... | You have to use a constructor to get that functionality. So, you can't use default.
But if your goal is to ensure a certain state of the passed type in a generic class, there may still be hope. If you want to ensure the passed type is instanti-able, use a generic constraint. The new() constraint. This ensures that the... |
379,131 | <p><strong>Area :</strong>
Textbox in Silverlight</p>
<p><strong>Question:</strong>
I need to know what "line number" that is currently edited.</p>
<p><strong>I've tried:</strong>
As a workaround I've tried splitting with textBox.Split("\r") and counting matches on Regex with similar performance. Performance during t... | [
{
"answer_id": 383916,
"author": "Christoffer Lette",
"author_id": 11808,
"author_profile": "https://Stackoverflow.com/users/11808",
"pm_score": 2,
"selected": false,
"text": "<p>As I see it, you don't really need to use <code>string.Split</code> or <code>Regex</code>. Just iterate over ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **Area :**
Textbox in Silverlight
**Question:**
I need to know what "line number" that is currently edited.
**I've tried:**
As a workaround I've tried splitting with textBox.Split("\r") and counting matches on Regex with similar performance. Performance during the first 2000 lines are acceptable but then it gets to s... | As I see it, you don't really need to use `string.Split` or `Regex`. Just iterate over the string and count `'\r'`s up to the caret position.
```
var s = ...the string...
var r = 0;
var c = ...caret position...
for (var i = 0; i < c; i++)
if (s[i] == '\r')
r++;
```
This way, you'll find the line number withou... |
379,136 | <p>Can I call a function from lisp from a library written in c or c++? How can I extend lisp?
This is useful when you want to do some system calls or stuff like that.</p>
| [
{
"answer_id": 379144,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 3,
"selected": false,
"text": "<p>See <a href=\"http://uffi.b9.com/\" rel=\"nofollow noreferrer\">UFFI</a> and <a href=\"http://common-lisp.net/proje... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47537/"
] | Can I call a function from lisp from a library written in c or c++? How can I extend lisp?
This is useful when you want to do some system calls or stuff like that. | It is unusual to call non-lisp code from lisp, and rarely necessary. CLX (the X11 client implementation for CL) doesn't link to the Xlib implementation but "speaks" X11 directly. On any system, your CL implementation is likely to already have excellent operating system hooks rendering this unnecessary.
That said, the ... |
379,138 | <p>Why is that Web Service files (.asmx) have their code-behind placed in app_code folder by default unlike the regular .aspx files?</p>
| [
{
"answer_id": 379144,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 3,
"selected": false,
"text": "<p>See <a href=\"http://uffi.b9.com/\" rel=\"nofollow noreferrer\">UFFI</a> and <a href=\"http://common-lisp.net/proje... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3096/"
] | Why is that Web Service files (.asmx) have their code-behind placed in app\_code folder by default unlike the regular .aspx files? | It is unusual to call non-lisp code from lisp, and rarely necessary. CLX (the X11 client implementation for CL) doesn't link to the Xlib implementation but "speaks" X11 directly. On any system, your CL implementation is likely to already have excellent operating system hooks rendering this unnecessary.
That said, the ... |
379,141 | <p>I have two versions of rails (2.1.0 and 2.2.2) installed in my computer.</p>
<p>When I create a new application, is it possible to specify that I want to use the older (2.1.0) version?</p>
| [
{
"answer_id": 379190,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 2,
"selected": false,
"text": "<p>You can generate the skeleton with either version and require the one you want in <code>config/environment.rb</code>:</p... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755/"
] | I have two versions of rails (2.1.0 and 2.2.2) installed in my computer.
When I create a new application, is it possible to specify that I want to use the older (2.1.0) version? | I found [here](http://craiccomputing.blogspot.com/2008/06/using-older-versions-of-rails.html) an undocumented option to create a new application using an older version of Rails.
```
rails _2.1.0_ new myapp
``` |
379,162 | <p>I just started with the WCF REST Starter Kit.</p>
<p>I created a simple service that return an array of an object.</p>
<p>Using the browser, everything works fine but when I use a WCF client, I get an ArgumentException.</p>
<p>I'm not using IIS and here is the code:</p>
<p><strong>The contract:</strong></p>
<pr... | [
{
"answer_id": 379170,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 3,
"selected": false,
"text": "<ol>\n<li>there aren't any</li>\n<li>it there were, they'd be obsolete</li>\n<li>if they're not obsolete, you won't l... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22693/"
] | I just started with the WCF REST Starter Kit.
I created a simple service that return an array of an object.
Using the browser, everything works fine but when I use a WCF client, I get an ArgumentException.
I'm not using IIS and here is the code:
**The contract:**
```
[ServiceContract]
public interface IGiftSer... | In his book "[SQL Programming Style](https://rads.stackoverflow.com/amzn/click/com/0120887975)," Joe Celko suggests a number of conventions, for example that a collection (e.g. a table) should be named in the plural, while a scalar data element (e.g. a column) should be named in the singular.
He cites [ISO-11179-4](ht... |
379,164 | <p>I have a legacy VB6 application which I've inherited. The issue I'm facing is that I'm getting the infamous</p>
<pre><code>ORA-12638: Credential retrieval failed
</code></pre>
<p>error message whenever it tries to connect to one of our Oracle databases. I can connect fine from SQLPlus and Toad, however. I've Googl... | [
{
"answer_id": 381086,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 4,
"selected": true,
"text": "<p>Honestly this is one of those errors that can be caused by lots of different root problems.</p>\n\n<p>On the assumption... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25371/"
] | I have a legacy VB6 application which I've inherited. The issue I'm facing is that I'm getting the infamous
```
ORA-12638: Credential retrieval failed
```
error message whenever it tries to connect to one of our Oracle databases. I can connect fine from SQLPlus and Toad, however. I've Googled around and everyone see... | Honestly this is one of those errors that can be caused by lots of different root problems.
On the assumption your database server is Windows, check its event log, both System and Application. You may find something there that is useful.
I have encountered this error in some cases because the account under which the ... |
379,172 | <p>Currently I am working on a project where goto statements are heavely used. The main purpose of goto statements is to have one cleanup section in a routine rather than multiple return statements.
Like below:</p>
<pre><code>BOOL foo()
{
BOOL bRetVal = FALSE;
int *p = NULL;
p = new int;
if (p == NULL)
... | [
{
"answer_id": 379188,
"author": "Marcin",
"author_id": 22724,
"author_profile": "https://Stackoverflow.com/users/22724",
"pm_score": 3,
"selected": false,
"text": "<p>In general, you should design your programs to limit the need for gotos. Use OO techniques for \"cleanup\" of your retur... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | Currently I am working on a project where goto statements are heavely used. The main purpose of goto statements is to have one cleanup section in a routine rather than multiple return statements.
Like below:
```
BOOL foo()
{
BOOL bRetVal = FALSE;
int *p = NULL;
p = new int;
if (p == NULL)
{
cout<<... | I am not sure what do you mean by clean up code but in C++ there is a concept called "*resource acquisition is initialization*" and it should be the responsibility of your destructors to clean up stuff.
(Note that in C# and Java, this is usually solved by try/finally)
For more info check out this page:
<http://www.re... |
379,175 | <p>I have a <code>Dictionary<string,int></code> that has the potential to contain upwards of 10+ million unique keys. I am trying to reduce the amount of memory that this takes, while still maintaining the functionality of the dictionary.</p>
<p>I had the idea of storing a hash of the string as a long instead, t... | [
{
"answer_id": 379182,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 2,
"selected": false,
"text": "<p>Why don't you just use <code>GetHashCode()</code> to get a hash of the string?</p>\n"
},
{
"answer_id": 379... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47540/"
] | I have a `Dictionary<string,int>` that has the potential to contain upwards of 10+ million unique keys. I am trying to reduce the amount of memory that this takes, while still maintaining the functionality of the dictionary.
I had the idea of storing a hash of the string as a long instead, this decreases the apps memo... | So I have done something similar recently and for a certain set of reasons that are fairly unique to my application did not use a database. In fact I was try to stop using a database. I have found that GetHashCode is significantly improved in 3.5. One important note, NEVER STORE PERSISTENTLY THE RESULTS FROM GetHashCod... |
379,176 | <p>Is there a library that will convert a Double to a String with the whole number, followed by a fraction?</p>
<p>For example</p>
<pre><code>1.125 = 1 1/8
</code></pre>
<p>I am only looking for fractions to a 64th of an inch. </p>
| [
{
"answer_id": 379198,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 3,
"selected": false,
"text": "<p>One problem you might run into is that not all fractional values can be represented by doubles. Even some values that loo... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17712/"
] | Is there a library that will convert a Double to a String with the whole number, followed by a fraction?
For example
```
1.125 = 1 1/8
```
I am only looking for fractions to a 64th of an inch. | One problem you might run into is that not all fractional values can be represented by doubles. Even some values that look simple, like 0.1. Now on with the pseudocode algorithm. You would probably be best off determining the number of 64ths of an inch, but dividing the decimal portion by 0.015625. After that, you can ... |
379,191 | <p>I have a text file that contains localized language strings that is currently encoded in GB2312 (simplified Chinese), but all of my other language files are in UTF-8. I am finding it very difficult to work with this file, as none of my text editors will work properly with it and keep corrupting it. Are there any too... | [
{
"answer_id": 379660,
"author": "Arthur Reutenauer",
"author_id": 46495,
"author_profile": "https://Stackoverflow.com/users/46495",
"pm_score": 2,
"selected": false,
"text": "<p>GB 2312 is mostly compatible with GB 18030, so any tool able to deal with the latter should treat GB 2312 cor... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] | I have a text file that contains localized language strings that is currently encoded in GB2312 (simplified Chinese), but all of my other language files are in UTF-8. I am finding it very difficult to work with this file, as none of my text editors will work properly with it and keep corrupting it. Are there any tools ... | You can try this [online service](http://www.iconv.org/) that uses the Open Source `iconv` utility.
You can also install [Charco](http://www.marblesoftware.com/Charco.html), a command-line version of it on your machine.
For `GB2312`, you can use `CP936` as the encoding.
If you are a .Net developer you can make a s... |
379,210 | <p>The application that I am working on generates files dynamically with use. This makes backup and syncronization between staging,development and production a real big challenge. One way that we might get smooth solution (if feasable) is to have a script that at the moment of backing up the database can backup the d... | [
{
"answer_id": 381262,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>the should be trivial to accomplish using PHP, perl, python, etc. are you looking for someone to write this for you?</p>\n"... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47222/"
] | The application that I am working on generates files dynamically with use. This makes backup and syncronization between staging,development and production a real big challenge. One way that we might get smooth solution (if feasable) is to have a script that at the moment of backing up the database can backup the dynami... | Do you mean that the application is storing a files as blobs in the MySQL database, and/or creating lots of temporary tables? Or that you just want temporary files - themselves unrelated to a database - to be stored in MySQL as a backup?
I'm not sure that trying to use MySQL as an net-new intermediary for backups of f... |
379,231 | <p>I've been developing Web applications for a while now and have dipped my toe into GUI and Game application development.</p>
<p>In the web application (php for me), a request is made to the file, that file includes all the necessary files to process the info into memory, then the flow is from Top to Bottom for each ... | [
{
"answer_id": 379267,
"author": "RS Conley",
"author_id": 7890,
"author_profile": "https://Stackoverflow.com/users/7890",
"pm_score": 1,
"selected": false,
"text": "<p>For applications and to a lesser extent Games the software is event driven. The user does \"something\" with the keyboa... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22459/"
] | I've been developing Web applications for a while now and have dipped my toe into GUI and Game application development.
In the web application (php for me), a request is made to the file, that file includes all the necessary files to process the info into memory, then the flow is from Top to Bottom for each request. (... | There's almost always a loop in all of these - but it's not something you would tend to think about during most of your development.
If you take a step back, your web applications are based around a loop - the Web Server's `accept()` loop:
```
while(listening) {
get a socket connection;
handle it;
}
```
.... |
379,234 | <p>I'm trying to come up with a clean way of sorting a set of strings based on a "sorting template". I apologize if my wording is confusing, but I can't think of a better way to describe it (maybe someone can come up with a better way to describe it after reading what I'm trying to do?).</p>
<p>Consider the following ... | [
{
"answer_id": 379255,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 1,
"selected": false,
"text": "<p>You could rename your commands like</p>\n\n<pre><code>[1FA, 2TY, 3AK, 4PO, 5PR, 6ZZ, 7QW, 8BC]\n</code></pre>\n\n<p>and s... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18505/"
] | I'm trying to come up with a clean way of sorting a set of strings based on a "sorting template". I apologize if my wording is confusing, but I can't think of a better way to describe it (maybe someone can come up with a better way to describe it after reading what I'm trying to do?).
Consider the following list of st... | You could use a `Dictionary<string, int>` to store and retrieve your sorting template tokens. However, this basically does the same as your enum (only perhaps in a slightly more readable manner), because `Enum.Parse` here could be confusing.
```
var ordering = Dictionary<string, int>();
ordering.Add("FA", 0);
ordering... |
379,236 | <p>I'm trying to design a data model that denotes one user being the friend of another user. This is what i've come up with so far, but it seems clunky, is there a better solution?</p>
<pre><code>User
=====
Id
Name
etc...
UserFriend
===========
UserId
FriendId
IsMutual
IsBlocked
</code></pre>
| [
{
"answer_id": 379243,
"author": "rjurney",
"author_id": 13969,
"author_profile": "https://Stackoverflow.com/users/13969",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps add a Relationship table, put the relationship properties there, and reference it from UserFriend.</p>\n"
},
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8360/"
] | I'm trying to design a data model that denotes one user being the friend of another user. This is what i've come up with so far, but it seems clunky, is there a better solution?
```
User
=====
Id
Name
etc...
UserFriend
===========
UserId
FriendId
IsMutual
IsBlocked
``` | ```
UserRelationship
====
RelatingUserID
RelatedUserID
Type[friend, block, etc]
```
Agree that mutuality doesn't belong as a column; breaks normalization. |
379,238 | <p>My project is about to introduce SOAP. It's going to be used for C++ <-> Java and C++ <-> Flex communication. I'm responsible for refactoring our apps to take advantage of Java business rules engine and new Flex gui.</p>
<p>What resources are must read for C++ SOAP? I've read W3 materials. We're probably be u... | [
{
"answer_id": 379243,
"author": "rjurney",
"author_id": 13969,
"author_profile": "https://Stackoverflow.com/users/13969",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps add a Relationship table, put the relationship properties there, and reference it from UserFriend.</p>\n"
},
... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3579/"
] | My project is about to introduce SOAP. It's going to be used for C++ <-> Java and C++ <-> Flex communication. I'm responsible for refactoring our apps to take advantage of Java business rules engine and new Flex gui.
What resources are must read for C++ SOAP? I've read W3 materials. We're probably be using gSOAP on So... | ```
UserRelationship
====
RelatingUserID
RelatedUserID
Type[friend, block, etc]
```
Agree that mutuality doesn't belong as a column; breaks normalization. |
379,276 | <p>I want to store the username/password information of my windows service 'logon as' user in the app.config.</p>
<p>So in my Installer, I am trying to grab the username/password from app.config and set the property but I am getting an error when trying to install the service.</p>
<p>It works fine if I hard code the ... | [
{
"answer_id": 379521,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 4,
"selected": true,
"text": "<p>The problem is that when your installer runs, you are still in installation phase and your application hasn't been... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | I want to store the username/password information of my windows service 'logon as' user in the app.config.
So in my Installer, I am trying to grab the username/password from app.config and set the property but I am getting an error when trying to install the service.
It works fine if I hard code the username/password... | The problem is that when your installer runs, you are still in installation phase and your application hasn't been fully installed. The app.config will only be available when the actual application is run.
You can however do the following:
1. Prompt the user for the username and password within the installer (or on t... |
379,282 | <p>In the C# example of polymorphism, there is a Cat class which inherits a class called AnimalBase and an interface called IAnimal.</p>
<p>The link in question is: <a href="http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Polymorphism_in_... | [
{
"answer_id": 379296,
"author": "RS Conley",
"author_id": 7890,
"author_profile": "https://Stackoverflow.com/users/7890",
"pm_score": 3,
"selected": false,
"text": "<p>Base Classes are used when you want to reuse BEHAVIOR</p>\n\n<p>Interfaces are used when you want to control how the cl... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | In the C# example of polymorphism, there is a Cat class which inherits a class called AnimalBase and an interface called IAnimal.
The link in question is: <http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming>
My question is, why is both a base class and an interface used? Why not one or the other... | The statement that "inheriting from a base class allows you to inherit BEHAVIOR, whereas implementing an interface only lets you specify INTERACTION" is absolutely true.
But more importantly, interfaces allow statically typed languages to continue to support polymorphism. An Object Oriented purist would insist that a ... |
379,291 | <p>Here's a snippet of code from within TurboGears 1.0.6:</p>
<pre><code>[dispatch.generic(MultiorderGenericFunction)]
def run_with_transaction(func, *args, **kw):
pass
</code></pre>
<p>I can't figure out how putting a list before a function definition can possibly affect it.</p>
<p>In dispatch.generic's docstri... | [
{
"answer_id": 379333,
"author": "e-satis",
"author_id": 9951,
"author_profile": "https://Stackoverflow.com/users/9951",
"pm_score": -1,
"selected": false,
"text": "<p>Nothing mysterious, it's just how syntax was before.</p>\n\n<p>The parser has changed, probably because the Python Zen c... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4105/"
] | Here's a snippet of code from within TurboGears 1.0.6:
```
[dispatch.generic(MultiorderGenericFunction)]
def run_with_transaction(func, *args, **kw):
pass
```
I can't figure out how putting a list before a function definition can possibly affect it.
In dispatch.generic's docstring, it mentions:
>
> Note that ... | The decorator syntax is provided by PyProtocols.
"""
Finally, it's important to note that these "magic" decorators use a very sneaky hack: they abuse the sys.settrace() debugger hook to track whether assignments are taking place. Guido takes a very dim view of this, but the hook's existing functionality isn't going to... |
379,319 | <p>I am writing code that checks for the permission to write to and delete from certain directories. The first is fairly easy. To whit:</p>
<pre><code>FileIOPermission writePermit = new FileIOPermission(FileIOPermissionAccess.Write, _ArchiveHome);
writePermit.Demand();
</code></pre>
<p>But, how do I do the same for p... | [
{
"answer_id": 379336,
"author": "Martijn Laarman",
"author_id": 47020,
"author_profile": "https://Stackoverflow.com/users/47020",
"pm_score": 3,
"selected": true,
"text": "<p>The Write property mutually means you can delete\n<a href=\"http://msdn.microsoft.com/en-us/library/system.secur... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | I am writing code that checks for the permission to write to and delete from certain directories. The first is fairly easy. To whit:
```
FileIOPermission writePermit = new FileIOPermission(FileIOPermissionAccess.Write, _ArchiveHome);
writePermit.Demand();
```
But, how do I do the same for permission to delete from a... | The Write property mutually means you can delete
[msdn link](http://msdn.microsoft.com/en-us/library/system.security.permissions.fileiopermissionaccess(VS.85).aspx) |
379,328 | <p>I want in a good performance way (I hope) replace a named parameter in my string to a named parameter from code, example, my string:</p>
<pre><code>"Hi {name}, do you like milk?"
</code></pre>
<p>How could I replace the {name} by code, Regular expressions? To expensive? Which way do you recommend?</p>
<p>How do t... | [
{
"answer_id": 379341,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "<p>Have you confirmed that regular expressions are too expensive?</p>\n\n<p>The cost of regular expressions is greatly... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want in a good performance way (I hope) replace a named parameter in my string to a named parameter from code, example, my string:
```
"Hi {name}, do you like milk?"
```
How could I replace the {name} by code, Regular expressions? To expensive? Which way do you recommend?
How do they in example NHibernates HQL to... | Have you confirmed that regular expressions are too expensive?
The cost of regular expressions is greatly exaggerated. For such a simple pattern performance will be quite good, probably only slightly less good than direct search-and-replace, in fact. Also, have you experimented with the `Compiled` flag when constructi... |
379,338 | <p>I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated.</p>
<p>Who has done it? How?</p>
<p>EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I... | [
{
"answer_id": 463042,
"author": "Eli Bendersky",
"author_id": 8206,
"author_profile": "https://Stackoverflow.com/users/8206",
"pm_score": 0,
"selected": false,
"text": "<p>Rob,</p>\n\n<p>There's reason behind people's selection of tools. StringTemplate is not terribly popular for Python... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26682/"
] | I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated.
Who has done it? How?
EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in Mo... | Based on the tutorials for both, it looks pretty straightforward:
```
import stringtemplate
import cherrypy
class HelloWorld(object):
def index(self):
hello = stringtemplate.StringTemplate("Hello, $name$")
hello["name"] = "World"
return str(hello)
index.exposed = True
cherrypy.quicks... |
379,346 | <p>The ampoule project uses some tags in docstring, like the javadoc ones. </p>
<p>For example from <a href="http://bazaar.launchpad.net/~dialtone/ampoule/main/annotate/26?file_id=pool.py-20080501191749-jqawtxogk4i0quu3-12" rel="noreferrer">pool.py</a> line 86:</p>
<pre><code>def start(self, ampChild=None):
"""
... | [
{
"answer_id": 379415,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 5,
"selected": true,
"text": "<p>Markup for a documentation tool, probably <a href=\"http://epydoc.sourceforge.net/\" rel=\"noreferrer\">epydoc</a>.</p>\n... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36131/"
] | The ampoule project uses some tags in docstring, like the javadoc ones.
For example from [pool.py](http://bazaar.launchpad.net/~dialtone/ampoule/main/annotate/26?file_id=pool.py-20080501191749-jqawtxogk4i0quu3-12) line 86:
```
def start(self, ampChild=None):
"""
Starts the ProcessPool with a given child prot... | Markup for a documentation tool, probably [epydoc](http://epydoc.sourceforge.net/). |
379,352 | <p>The CherryPy web server can supposedly be deployed in the Google App Engine.</p>
<p>Who has done it, and what was the experience like?</p>
<p>What special effort was required (configuration, etc.)?</p>
<p>Would you recommend it to others?</p>
| [
{
"answer_id": 422503,
"author": "Jack M.",
"author_id": 3421,
"author_profile": "https://Stackoverflow.com/users/3421",
"pm_score": 0,
"selected": false,
"text": "<p>There is a good article on how to do this <del><a href=\"http://boodebr.org/main/python/cherrypy-under-google-appserver\"... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26682/"
] | The CherryPy web server can supposedly be deployed in the Google App Engine.
Who has done it, and what was the experience like?
What special effort was required (configuration, etc.)?
Would you recommend it to others? | The [article](http://web.archive.org/web/20120722170650/http://boodebr.org/main/python/cherrypy-under-google-appserver) is a good example but its slightly out of date now as the [patch is no longer required](https://bitbucket.org/cherrypy/cherrypy/issue/803/patch-for-running-under-google-app-engine), the latest version... |
379,353 | <p>I'm looking for a lightweight way to make my program (written in C) be able to play audio files on either windows or linux. I am currently using windows native calls, which is essentially just a single call that is passed a filename. I would like something similar that works on linux. </p>
<p>The audio files are ... | [
{
"answer_id": 379392,
"author": "Marc",
"author_id": 27947,
"author_profile": "https://Stackoverflow.com/users/27947",
"pm_score": 1,
"selected": false,
"text": "<p>You can try with this one: <a href=\"http://xiph.org/ao/\" rel=\"nofollow noreferrer\">libao</a></p>\n"
},
{
"answ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17324/"
] | I'm looking for a lightweight way to make my program (written in C) be able to play audio files on either windows or linux. I am currently using windows native calls, which is essentially just a single call that is passed a filename. I would like something similar that works on linux.
The audio files are Microsoft PC... | Since I'm also looking for an answer for question I did a bit of research, and I haven't find any simple (simple like calling one function) way to play an audio file. But with some lines of code, it is possible even in a portable way using the already mentioned portaudio and libsndfile (LGPL).
Here is a small test cas... |
379,354 | <p>This one's a tough one - I have a JFrame that generates JTextFields. When I go from generating 2 JTextFields to 12 JTextfields (for example), I see some error where there is an extra differently-sized JTextField at the end. It seems to be a repaint error.</p>
<p><strong>Main.java code:</strong> </p>
<pre><code>im... | [
{
"answer_id": 379392,
"author": "Marc",
"author_id": 27947,
"author_profile": "https://Stackoverflow.com/users/27947",
"pm_score": 1,
"selected": false,
"text": "<p>You can try with this one: <a href=\"http://xiph.org/ao/\" rel=\"nofollow noreferrer\">libao</a></p>\n"
},
{
"answ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] | This one's a tough one - I have a JFrame that generates JTextFields. When I go from generating 2 JTextFields to 12 JTextfields (for example), I see some error where there is an extra differently-sized JTextField at the end. It seems to be a repaint error.
**Main.java code:**
```
import java.awt.*;
import javax.swing... | Since I'm also looking for an answer for question I did a bit of research, and I haven't find any simple (simple like calling one function) way to play an audio file. But with some lines of code, it is possible even in a portable way using the already mentioned portaudio and libsndfile (LGPL).
Here is a small test cas... |
379,383 | <p>I have a std::vector containing a handful of numbers, which are not in any particular order, and may or may not have gaps between the numbers - for example, I may have { 1,2,3, 6 } or { 2,8,4,6 } or { 1, 9, 5, 2 }, etc.</p>
<p>I'd like a simple way to look at this vector and say 'give me the lowest number >= 1 whic... | [
{
"answer_id": 379399,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 3,
"selected": false,
"text": "<p>Sorting the list and then doing a linear search seems the simplest solution. Depending on the expected composition of th... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/987/"
] | I have a std::vector containing a handful of numbers, which are not in any particular order, and may or may not have gaps between the numbers - for example, I may have { 1,2,3, 6 } or { 2,8,4,6 } or { 1, 9, 5, 2 }, etc.
I'd like a simple way to look at this vector and say 'give me the lowest number >= 1 which does *no... | The checked answer uses < for comparison. != is much simpler:
```
int find_gap(std::vector<int> vec) {
std::sort(vec.begin(), vec.end());
int next = 1;
for (std::vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) {
if (*it != next) return next;
++next;
}
return next;
}
f... |
379,385 | <p>Our dev team is looking for an IDE like vi or nano or even textpad for windows that has the capability to autocomplete and error correction for bash or shell script for linux. Basically something similar to .NET autocompletion where you will be able to see if an </p>
<pre><code> if[ $# -ne 5 ]; then
</code></pre>... | [
{
"answer_id": 379494,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>Like most questions of this sort, the One True Answer is EMACS.</p>\n\n<p>However, TextMate, BBEdit, and SubEtha... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47222/"
] | Our dev team is looking for an IDE like vi or nano or even textpad for windows that has the capability to autocomplete and error correction for bash or shell script for linux. Basically something similar to .NET autocompletion where you will be able to see if an
```
if[ $# -ne 5 ]; then
```
has no space between t... | In vim, apart from adding syntax highlighting to show incorrect syntax (the "if" example would not highlight the if correctly) you can add this to your .vimrc:
```
autocmd FileType sh set makeprg=bash\ -n\ '%'
autocmd FileType sh let &efm = "%E%f:\ line\ %l:\ %m," . &efm
```
Now when you run `:make` it will check th... |
379,412 | <p>I have an application for entering in serial numbers to a database. A serial number has a set number of attributes that defines it and the the user must/may provide them to generate.</p>
<pre><code>public class Serial
{
public string Number {get; set;}
public string Part {get; set;}
public string MfgOr... | [
{
"answer_id": 379494,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>Like most questions of this sort, the One True Answer is EMACS.</p>\n\n<p>However, TextMate, BBEdit, and SubEtha... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36602/"
] | I have an application for entering in serial numbers to a database. A serial number has a set number of attributes that defines it and the the user must/may provide them to generate.
```
public class Serial
{
public string Number {get; set;}
public string Part {get; set;}
public string MfgOrder {get; set;}... | In vim, apart from adding syntax highlighting to show incorrect syntax (the "if" example would not highlight the if correctly) you can add this to your .vimrc:
```
autocmd FileType sh set makeprg=bash\ -n\ '%'
autocmd FileType sh let &efm = "%E%f:\ line\ %l:\ %m," . &efm
```
Now when you run `:make` it will check th... |
379,432 | <p>I have a listbox on an HTML form with a Submit button. The listbox has multiple selection enabled. I am able to select multiple values in the listbox, but I don't know how to figure out what values were selected when the form is submitted. Also, I am adding user generated values to the list box dynamically using ... | [
{
"answer_id": 379990,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 3,
"selected": true,
"text": "<p>Below you find an example of a page.</p>\n\n<p>Note that:</p>\n\n<ul>\n<li>the select element (and any form element) needs ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | I have a listbox on an HTML form with a Submit button. The listbox has multiple selection enabled. I am able to select multiple values in the listbox, but I don't know how to figure out what values were selected when the form is submitted. Also, I am adding user generated values to the list box dynamically using JavaSc... | Below you find an example of a page.
Note that:
* the select element (and any form element) needs a name to be included in the post.
* only selected options in the select element will be posted.
*What values are selected in the box by the user?*
When the user submits the form only the selected values will be sent t... |
379,442 | <p>I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations. I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional. Ideally, if the performance hit isn't too great, I'd prefer to ke... | [
{
"answer_id": 379990,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 3,
"selected": true,
"text": "<p>Below you find an example of a page.</p>\n\n<p>Note that:</p>\n\n<ul>\n<li>the select element (and any form element) needs ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46914/"
] | I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations. I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional. Ideally, if the performance hit isn't too great, I'd prefer to keep th... | Below you find an example of a page.
Note that:
* the select element (and any form element) needs a name to be included in the post.
* only selected options in the select element will be posted.
*What values are selected in the box by the user?*
When the user submits the form only the selected values will be sent t... |
379,465 | <p>For my program, I'm attempting to replace the value of a specific hash in an external file with a newly created value. The external file has the value tab-delimited from the key, and I had read the hash in from the external file. I've been looking around online, and this is the closest way I could figure out how to ... | [
{
"answer_id": 379476,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 0,
"selected": false,
"text": "<p>You are trying to read and write to the same file, that is not going to work. You have to read, substitute then write i... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For my program, I'm attempting to replace the value of a specific hash in an external file with a newly created value. The external file has the value tab-delimited from the key, and I had read the hash in from the external file. I've been looking around online, and this is the closest way I could figure out how to do ... | [Tie::File](http://search.cpan.org/perldoc?Tie::File) can fix this for you.
```
use Tie::File;
tie @array, 'Tie::File', $file or die "Could not tie $file: $!";
for (@array) {
s/$hash{$key}/$newvalue/;
}
untie @array;
``` |
379,487 | <p>I know there is re-sharper for Visual Studio, but is there a really good refactoring tool for Eclipse that is better than the small amount of built in refactors?</p>
<p>Preferably something free.</p>
<p>(Update)</p>
<p>Looking to do things like take all string literals in a file and make them constants.<br>
Solve... | [
{
"answer_id": 379547,
"author": "jamesh",
"author_id": 4737,
"author_profile": "https://Stackoverflow.com/users/4737",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://wiki.netbeans.org/Jackpot\" rel=\"nofollow noreferrer\">Jackpot</a> is a refactoring language built into ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45365/"
] | I know there is re-sharper for Visual Studio, but is there a really good refactoring tool for Eclipse that is better than the small amount of built in refactors?
Preferably something free.
(Update)
Looking to do things like take all string literals in a file and make them constants.
Solve lots of PMD errors in so... | This does not really answer your question but I can't properly format this into a comment.
Here is a nice way to extract Strings into constant in eclipse. (I didn't know about the pick out string until a couple of weeks ago)
We have this line:
```
System.out.println("This Line Contains a constant The 42 Constant tha... |
379,506 | <p>I have a central authentication application on server a. Server b has one or more applications on the same domain that need to authenticate from server a. It's easy enough to set it up so that the server b apps redirect out to server a. What's not so easy is getting the ReturnURL to be absolute.</p>
<p>Here's the w... | [
{
"answer_id": 379592,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": "<p>The way the standard AuthorizeAttribute works is by setting the response status code to 401 if the request is not au... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26364/"
] | I have a central authentication application on server a. Server b has one or more applications on the same domain that need to authenticate from server a. It's easy enough to set it up so that the server b apps redirect out to server a. What's not so easy is getting the ReturnURL to be absolute.
Here's the wrinkle. Co... | The way the standard AuthorizeAttribute works is by setting the response status code to 401 if the request is not authenticated. This kicks in the default authentication module's standard response to an unauthorized request. I assume that you're using forms-based authentication, which would build the return url based o... |
379,512 | <p>I'm trying to write a simple routine where I pass it a URL and it goes and renders the content of the webresponse as a jpg. I found a solution somehwere in C# and ported it to vb.net, however when I run it, it throws an argumentexception "parameter is not valid" when trying to instantiate the image. Can someone ta... | [
{
"answer_id": 379528,
"author": "Yuliy",
"author_id": 47527,
"author_profile": "https://Stackoverflow.com/users/47527",
"pm_score": 2,
"selected": false,
"text": "<p>What are you trying to do?</p>\n\n<p>Are you trying convert a web page to JPEG? This will require a bit more code, as wha... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/678/"
] | I'm trying to write a simple routine where I pass it a URL and it goes and renders the content of the webresponse as a jpg. I found a solution somehwere in C# and ported it to vb.net, however when I run it, it throws an argumentexception "parameter is not valid" when trying to instantiate the image. Can someone take a ... | What are you trying to do?
Are you trying convert a web page to JPEG? This will require a bit more code, as what your code is trying to do is to download an already existing image (such as a gif, png, or even another jpeg) and converts it to jpeg. You would need to have something render the HTML document, then you wou... |
379,526 | <p>I'm working on a project where I need the following.</p>
<ul>
<li>WCF service on the server side (.NET 3.5)</li>
<li>WPF client for the client side (.NET 3.0)</li>
</ul>
<p>I have an existing application that I have to use the authentication and authorization from (on the server side). I also need to store some me... | [
{
"answer_id": 379565,
"author": "blowdart",
"author_id": 2525,
"author_profile": "https://Stackoverflow.com/users/2525",
"pm_score": 4,
"selected": true,
"text": "<p>Short answer; you can't. As soon as you use username/password you need some sort of secure channel.</p>\n\n<p>However you... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29849/"
] | I'm working on a project where I need the following.
* WCF service on the server side (.NET 3.5)
* WPF client for the client side (.NET 3.0)
I have an existing application that I have to use the authentication and authorization from (on the server side). I also need to store some metadata about the user in the WCF Se... | Short answer; you can't. As soon as you use username/password you need some sort of secure channel.
However you don't need certificates on the clients; only on the server. |
379,530 | <p>I can, on some of my systems, get my IP address (192.68.m.n format) by doing this:</p>
<pre><code>addr = IPSocket::getAddress(Socket.gethostname())
</code></pre>
<p>...the trouble is that this only works if the name the local machine uses for itself is the name the DNS server associates with it.</p>
<p>How *&... | [
{
"answer_id": 379557,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 3,
"selected": true,
"text": "<p>See <a href=\"https://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails\">this questi... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] | I can, on some of my systems, get my IP address (192.68.m.n format) by doing this:
```
addr = IPSocket::getAddress(Socket.gethostname())
```
...the trouble is that this only works if the name the local machine uses for itself is the name the DNS server associates with it.
How \*&#( hard can it be for ruby to just r... | See [this question](https://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails). Also `see Socket.getaddrinfo()` |
379,546 | <p>In Haskell, is there a way to restrict a monad <code>M a</code> so that <code>a</code> satisfy a type class constraint?</p>
<p>I am translating the <a href="http://github.com/namin/spots/tree/master/probabilisticModeling/README.markdown" rel="noreferrer">probabilistic modeling example</a> from <a href="http://githu... | [
{
"answer_id": 379608,
"author": "Gregory Higley",
"author_id": 27779,
"author_profile": "https://Stackoverflow.com/users/27779",
"pm_score": 4,
"selected": true,
"text": "<p>My understanding of this is that you simply cannot, because a monad is meant to be generalized over all types, no... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34596/"
] | In Haskell, is there a way to restrict a monad `M a` so that `a` satisfy a type class constraint?
I am translating the [probabilistic modeling example](http://github.com/namin/spots/tree/master/probabilisticModeling/README.markdown) from [F#](http://github.com/namin/spots/tree/master/probabilisticModeling/probabilisti... | My understanding of this is that you simply cannot, because a monad is meant to be generalized over all types, not some restricted subset of types such as `(Ord a)`.
Instead of restricting the monadic type `M a`, you can simply restrict functions which use that monadic type, e.g.,
```
foo :: Ord a => Int -> M a
```
... |
379,551 | <p>What's the simplest, most standard, and/or most efficient way to split a List into two sub-Lists in Java? It's OK to mutate the original List, so no copying should be necessary. The method signature could be</p>
<pre><code>/** Split a list into two sublists. The original list will be modified to
* have size i and ... | [
{
"answer_id": 379584,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 2,
"selected": false,
"text": "<p>Getting the returned array is pretty easy using the subList method, but there's no easy way that I know of to r... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | What's the simplest, most standard, and/or most efficient way to split a List into two sub-Lists in Java? It's OK to mutate the original List, so no copying should be necessary. The method signature could be
```
/** Split a list into two sublists. The original list will be modified to
* have size i and will contain e... | Quick semi-pseudo code:
```
List sub=one.subList(...);
List two=new XxxList(sub);
sub.clear(); // since sub is backed by one, this removes all sub-list items from one
```
That uses standard List implementation methods and avoids all the running around in loops. The clear() method is also going to use the internal `r... |
379,552 | <p>Using C#, is there any way to hook into a running application (my own app) and get an instance of a class? As it stands right now I'm doing this</p>
<pre><code>// Find the IAutomation interface.
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (!type.IsAbstract && type.GetInterfac... | [
{
"answer_id": 379568,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 0,
"selected": false,
"text": "<p>If there's an existing instance of the IAutomation interface in the AppDomain there must be something pointing t... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26805/"
] | Using C#, is there any way to hook into a running application (my own app) and get an instance of a class? As it stands right now I'm doing this
```
// Find the IAutomation interface.
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (!type.IsAbstract && type.GetInterface("IAutomation") != nul... | You can use [remoting](http://msdn.microsoft.com/en-us/library/kwdt6w2k(VS.85).aspx), or make your existing instance a COM server, and use COM interop to the existing instance.
Maybe there are some debugging API's that you can use as well, but that I would not consider clean. |
379,556 | <p>I have a large-ish Oracle table containing rows representing units of work, with columns for start time and end time in addition to other meta-data.</p>
<p>I need to generate usage graphs from this data, given some arbitrary filtering criteria and a reporting time period. E.g., show me a graph of all of Alice's jo... | [
{
"answer_id": 379602,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 0,
"selected": false,
"text": "<p>Your best bet is to have a table (a temporary one generated on the fly would be fine if the time-slice is dynamic) an... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16722/"
] | I have a large-ish Oracle table containing rows representing units of work, with columns for start time and end time in addition to other meta-data.
I need to generate usage graphs from this data, given some arbitrary filtering criteria and a reporting time period. E.g., show me a graph of all of Alice's jobs for the ... | In terms of getting the data out, you can use 'group by' and '[truncate](http://www.techonthenet.com/oracle/functions/trunc_date.php)' to slice the data into 1 minute intervals. eg:
```
SELECT user_name, truncate(event_time, 'YYYYMMDD HH24MI'), count(*)
FROM job_table
WHERE event_time > TO_DATE( some start date time)... |
379,558 | <p>Here is my scenario. For the example lets say that I need to return a list of cars based on a search criteria. I would like to have a single View to display the results since the output will be the same, but I need several ways of getting there. For instance, I may have a Form with a textbox to search by year. I... | [
{
"answer_id": 379588,
"author": "Matthew",
"author_id": 20162,
"author_profile": "https://Stackoverflow.com/users/20162",
"pm_score": 0,
"selected": false,
"text": "<p>Each method (action) on the controller would take different parameters, but create the same collection of search result... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47576/"
] | Here is my scenario. For the example lets say that I need to return a list of cars based on a search criteria. I would like to have a single View to display the results since the output will be the same, but I need several ways of getting there. For instance, I may have a Form with a textbox to search by year. I may ha... | **Option 1**
Of course you always can choose the way of /car/search/?vendor=Toyota&color=Red&model=Corola and I think it will be good for you.
```
routes.MapRoute(
"CarSearch",
"car/search",
new { controller = "car", action = "search" }
);
```
You can get params from Request.Params in action in this cas... |
379,560 | <p>By default the BinaryWriter class writes int values with the low bits on the left (e.g. (int)6 becomes 06 00 00 00 when the resulting file is viewed in a hex editor). I need the low bits on the right (e.g. 00 00 00 06). </p>
<p>How do I achieve this?</p>
<p>EDIT: Thanks strager for giving me the name for what I wa... | [
{
"answer_id": 379567,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>You are looking to change the <a href=\"http://en.wikipedia.org/wiki/Byte_order\" rel=\"nofollow noreferrer\">Byte Orde... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512/"
] | By default the BinaryWriter class writes int values with the low bits on the left (e.g. (int)6 becomes 06 00 00 00 when the resulting file is viewed in a hex editor). I need the low bits on the right (e.g. 00 00 00 06).
How do I achieve this?
EDIT: Thanks strager for giving me the name for what I was looking for. I'... | Jon Skeet has an EndianBitConverter [here](http://www.pobox.com/~skeet/csharp/miscutil/) that should do the job. Just use big/little endian as desired. Alternatively, just shift the data a few times ;-p
```
int i = 6;
byte[] raw = new byte[4] {
(byte)(i >> 24), (byte)(i >> 16),
... |
379,571 | <p>I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time... | [
{
"answer_id": 379613,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 0,
"selected": false,
"text": "<p>You want to capture the even of the GridView; identify the command (sender) that is causing the postback, and then you c... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] | I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time th... | Do you set the checked status of the checkbox to false at all in your page load event? |
379,574 | <p>My Java UI unexpectly terminated and dumped an <code>hs_err_pid</code> file. The file says "The crash happened outside the Java Virtual Machine in native code." JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the con... | [
{
"answer_id": 379814,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 1,
"selected": false,
"text": "<p>Judging from:</p>\n\n<pre><code>Stack: [0x02eb0000,0x02f00000], sp=0x02eff4a4, free space=317k\nNative frames: (J=co... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47508/"
] | My Java UI unexpectly terminated and dumped an `hs_err_pid` file. The file says "The crash happened outside the Java Virtual Machine in native code." JNA is the only native code we use. Does anyone know of any know issues or bugs with any JNA version that might cause this. I've included some of the contents from the er... | I just hit that very same bug, it's apppearantly a bug in the new Direct3d accelerated Java2d functionality with 1.6.0\_11 that happens with machines with low video ram.
If you start your app with -Dsun.java2d.d3d=false it should work again.
The sun bug tracking this is the following: <http://bugs.sun.com/view_bug.do?b... |
379,581 | <p>I have an application that I'm trying to debug a crash in. However, it is difficult to detect the problem for a few reasons:</p>
<ul>
<li>The crash happens at shutdown, meaning the offending code isn't on the stack</li>
<li>The crash only happens in release builds, meaning symbols aren't available</li>
</ul>
<p>By... | [
{
"answer_id": 379599,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 1,
"selected": false,
"text": "<p>You seem to have something reading a null pointer - never good.</p>\n\n<p>I'm not sure what platform you are o... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28776/"
] | I have an application that I'm trying to debug a crash in. However, it is difficult to detect the problem for a few reasons:
* The crash happens at shutdown, meaning the offending code isn't on the stack
* The crash only happens in release builds, meaning symbols aren't available
By crash, I mean the following except... | You can make the symbol files even for the release build. Do that, run your program, attach the debugger, close it, and see the cause of the crash in the debugger. |
379,593 | <p>I currently use RCS' merge command to do 3-way merges, but one thing has always annoyed me about it. If I use the -A option, the same change made in both files shows up as a conflict:</p>
<p><<<<<<< file1<br>
file1 line 1<br>
||||||| orig<br>
orig line 1<br>
=======<br>
file2 line 1<br>
>>>>... | [
{
"answer_id": 379716,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>Looks like diff3 has some interesting options.</p>\n\n<p>On ubuntu:</p>\n\n<pre>\n -m --merge\n Output ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I currently use RCS' merge command to do 3-way merges, but one thing has always annoyed me about it. If I use the -A option, the same change made in both files shows up as a conflict:
<<<<<<< file1
file1 line 1
||||||| orig
orig line 1
=======
file2 line 1
>>>>>>> file2
orig line 2
<<<<<<< orig... | Looks like diff3 has some interesting options.
On ubuntu:
```
-m --merge
Output merged file instead of ed script (default -A).
```
You asked for non-graphical, but vimdiff and gvimdiff can do 3 adjacent windows. |
379,594 | <p>I am reading file from ResultSet and it's required to save file into Oracle Database.</p>
<pre><code>...
ResultSet rs = ...
java.sql.Blob myfile = rs.getBlob("field")
java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream();
</code></pre>
<p>I get get this error message</p>
<pre><code>java.lan... | [
{
"answer_id": 379605,
"author": "Dan Vinton",
"author_id": 21849,
"author_profile": "https://Stackoverflow.com/users/21849",
"pm_score": 2,
"selected": false,
"text": "<p><code>java.sql.Blob</code> <a href=\"http://java.sun.com/javase/6/docs/api/java/sql/Blob.html\" rel=\"nofollow noref... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44534/"
] | I am reading file from ResultSet and it's required to save file into Oracle Database.
```
...
ResultSet rs = ...
java.sql.Blob myfile = rs.getBlob("field")
java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream();
```
I get get this error message
```
java.lang.ClassCastException
```
Any one ha... | I have found the solution. I'd like to share with those who has this problem.
The code to get outputstream from oracle blob is:
```
java.io.OutputStream os = ((oracle.sql.BLOB) myBlob).setBinaryStream(1L);
```
setBinaryStream() is actually returning java.io.OutputStream object |
379,607 | <p>What is the best way to determine which ASP.NET button was clicked on a single page using JavaScript?</p>
| [
{
"answer_id": 379616,
"author": "Craig",
"author_id": 27294,
"author_profile": "https://Stackoverflow.com/users/27294",
"pm_score": 1,
"selected": false,
"text": "<p>You can easily add a client side Javascript click handler to an ASP button like this.</p>\n\n<pre><code>Button1.Attribute... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] | What is the best way to determine which ASP.NET button was clicked on a single page using JavaScript? | I just the set the OnClientClick event handler for the button with the JavaScript function I wanted executed when the button was clicked during the Page\_Load event.
```
protected void Page_Load(object sender, EventsArgs e)
{
MyButton.OnClientClick = "MyJavaScriptMethod();";
}
``` |
379,610 | <p>Is it possible to nest html forms like this</p>
<pre><code><form name="mainForm">
<form name="subForm">
</form>
</form>
</code></pre>
<p>so that both forms work? My friend is having problems with this, a part of the <code>subForm</code> works, while another part of it does not.</p>
| [
{
"answer_id": 379622,
"author": "Craig",
"author_id": 27294,
"author_profile": "https://Stackoverflow.com/users/27294",
"pm_score": 10,
"selected": true,
"text": "<p>In a word, no. You can have several forms in a page but they should not be nested.</p>\n\n<p>From the <a href=\"https://w... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27620/"
] | Is it possible to nest html forms like this
```
<form name="mainForm">
<form name="subForm">
</form>
</form>
```
so that both forms work? My friend is having problems with this, a part of the `subForm` works, while another part of it does not. | In a word, no. You can have several forms in a page but they should not be nested.
From the [html5 working draft](https://www.w3.org/TR/html5/forms.html#the-form-element):
>
> **4.10.3 The `form` element**
>
>
> **Content model:**
>
>
> Flow content, but with no form element descendants.
>
>
> |
379,643 | <p>Some of Oracle's analytic functions allow for a <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#i97640" rel="nofollow noreferrer">windowing clause</a> to specify a subset of the current partition, using keywords like "unbounded preceding/following", "current row", or "value_e... | [
{
"answer_id": 379670,
"author": "user34850",
"author_id": 34850,
"author_profile": "https://Stackoverflow.com/users/34850",
"pm_score": -1,
"selected": false,
"text": "<p>It is all about what you're trying to accomplish.\nYou may want to use RANGE BETWEEN/ROWS BETWEEN use it to find LAS... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19239/"
] | Some of Oracle's analytic functions allow for a [windowing clause](http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#i97640) to specify a subset of the current partition, using keywords like "unbounded preceding/following", "current row", or "value\_expr preceding/following" where value\_e... | It doesn't really matter which you use. They are two different ways of expressing the windowing, but the optimizer will perform the query the same way. The term "current row" is one that is common to multiple databases with analytic functions, not just Oracle. It's more of a stylistic difference, in the same way that s... |
379,648 | <p>I've received some documentation from one of our suppliers for a webservice they're publishing and they're very specific that on one of their WebMethods that an argument has the out modifier(? not sure if that's the right descriptor) for instance consider the following WebMethod signature:</p>
<pre><code>[WebMethod... | [
{
"answer_id": 379887,
"author": "Steven Behnke",
"author_id": 42588,
"author_profile": "https://Stackoverflow.com/users/42588",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe this will help:</p>\n\n<p><a href=\"http://kbalertz.com/322624/Proxy-Class-First-Parameter-Service-Method-R... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40650/"
] | I've received some documentation from one of our suppliers for a webservice they're publishing and they're very specific that on one of their WebMethods that an argument has the out modifier(? not sure if that's the right descriptor) for instance consider the following WebMethod signature:
```
[WebMethod]
public void ... | I don't know what the protocol is for providing answers to your own questions, but the article referenced by Steven Behnke provided some clues for me to deduce a solution to this bizarre situation. And rather than leave everyone else to figure out what the implications are, I thought I share my findings.
So, consider ... |
379,649 | <p>This code involves a recursive Stored Procedure call and a "not so great" method of avoiding cursor name collision. In the end I don't care if it uses cursors or not. Just looking for the most elegant approach. I'm mainly going to use it as a simple method to track down Stored Proc hierarchies (without buying a prod... | [
{
"answer_id": 379757,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 2,
"selected": false,
"text": "<p>See <a href=\"https://stackoverflow.com/questions/352176/sqlserver-how-to-sort-table-names-ordered-by... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | This code involves a recursive Stored Procedure call and a "not so great" method of avoiding cursor name collision. In the end I don't care if it uses cursors or not. Just looking for the most elegant approach. I'm mainly going to use it as a simple method to track down Stored Proc hierarchies (without buying a product... | for ms sql server you can use CURSOR LOCAL, then the cursor is local to the sproc call and your code becomes much simpler:
```
CREATE PROCEDURE uspPrintDependencies
(
@obj_name varchar(300),
@level int
)
AS
SET NOCOUNT ON
DECLARE @sub_obj_name varchar(300)
if @level > 0 begin
PRINT Replicate(' ',@level) +... |
379,650 | <p>I need to get array fragments from an array. I'm sick of using Array.Copy().
new ArraySegment(..).Array returns the original [full] array. The one below is what I came up with but I feel it's pretty lame. Is there a better way to do this?</p>
<p><code></p>
<pre><code>class Program
{
static void Main(string[... | [
{
"answer_id": 379666,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "<p>Vyas, I am <em>truly</em> sorry for having posted this useless pile of <code>****</code>. It's been ages since I'v... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] | I need to get array fragments from an array. I'm sick of using Array.Copy().
new ArraySegment(..).Array returns the original [full] array. The one below is what I came up with but I feel it's pretty lame. Is there a better way to do this?
```
class Program
{
static void Main(string[] args)
{
var arr = ... | Vyas, I am *truly* sorry for having posted this useless pile of `****`. It's been ages since I've actually used `ArraySegment` and I simply assumed that it implemented a (more or less) consistent interface. Someone (Jon?) please tell me which drugs were used during the implementation of this useless struct.
Finally, t... |
379,652 | <p>I have a page where I combine labels, input boxes and text areas to display some content.
I would like all of them to have the same font-family and font-size.
I have played with the <em>font-family: inherit</em> style but this doesn't seem to work for the input and text areas.
What would be the easiest way to ensur... | [
{
"answer_id": 379658,
"author": "Gene Roberts",
"author_id": 47544,
"author_profile": "https://Stackoverflow.com/users/47544",
"pm_score": 1,
"selected": false,
"text": "<p>My CSS is iffy as I haven't used it in some time, but I believe doing</p>\n\n<pre><code>*\n{\n font-family: ari... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] | I have a page where I combine labels, input boxes and text areas to display some content.
I would like all of them to have the same font-family and font-size.
I have played with the *font-family: inherit* style but this doesn't seem to work for the input and text areas.
What would be the easiest way to ensure the same... | Ok ... this does the trick:
```
*
{
font-family: arial;
}
input
{
font-family: inherit;
font-size: 100%
}
textarea
{
font-family: inherit;
font-size: 100%
}
``` |
379,672 | <p>I've created a package that contains a stored procedure that I plan to invoke from a separate application. The stored procedure will return a sorted list of all the views and tables in the schema. To do that, it performs a simple select on the DBA_TABLES and DBA_VIEWS synonyms, as shown below:</p>
<pre><code>CREATE... | [
{
"answer_id": 379714,
"author": "Raimonds Simanovskis",
"author_id": 16829,
"author_profile": "https://Stackoverflow.com/users/16829",
"pm_score": 4,
"selected": true,
"text": "<p>Use ALL_TABLES and ALL_VIEWS instead of DBA_TABLES and DBA_VIEWS. ALL_% views should be accessible to all u... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47580/"
] | I've created a package that contains a stored procedure that I plan to invoke from a separate application. The stored procedure will return a sorted list of all the views and tables in the schema. To do that, it performs a simple select on the DBA\_TABLES and DBA\_VIEWS synonyms, as shown below:
```
CREATE OR REPLACE
... | Use ALL\_TABLES and ALL\_VIEWS instead of DBA\_TABLES and DBA\_VIEWS. ALL\_% views should be accessible to all users. |
379,675 | <p>First, to make my job explaining a bit easier, here's some of my code:</p>
<pre><code>JSpinner spin = new JSpinner();
JFormattedTextField text = getTextField(spin);
text.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
// Do stuff... | [
{
"answer_id": 379787,
"author": "javamonkey79",
"author_id": 27657,
"author_profile": "https://Stackoverflow.com/users/27657",
"pm_score": 4,
"selected": true,
"text": "<p>I know this is not the action listener...but maybe this can work for you?</p>\n\n<p><pre><code>\n text.addKeyLis... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19825/"
] | First, to make my job explaining a bit easier, here's some of my code:
```
JSpinner spin = new JSpinner();
JFormattedTextField text = getTextField(spin);
text.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
// Do stuff...
}
});
... | I know this is not the action listener...but maybe this can work for you?
```
text.addKeyListener( new KeyAdapter() {
@Override
public void keyReleased( final KeyEvent e ) {
if ( e.getKeyCode() == KeyEvent.VK_ENTER ) {
System.out.println( "enter pressed"... |
379,689 | <p>I have been trying to figure out how to programmatically identify the process that has a lock on a particular file. I've searched through the Win32 API and WMI, but so far I can't find anything. I know it's possible - Sysinternals is able to list every resource accessed/locked by every process on the system.</p>
... | [
{
"answer_id": 379712,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 2,
"selected": false,
"text": "<p>Because of the way Process Explorer works, I suspect that what you need to look for is a way of finding the file handles ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have been trying to figure out how to programmatically identify the process that has a lock on a particular file. I've searched through the Win32 API and WMI, but so far I can't find anything. I know it's possible - Sysinternals is able to list every resource accessed/locked by every process on the system.
Can anyon... | You can use [handle.exe from Sysinternals](http://technet.microsoft.com/en-us/sysinternals/bb896655).
Something like:
```
> handle /accepteula C:\path\to\directory
...
program.exe pid: 1234 type: File 2E4: C:\path\to\directory
...
```
Thanks to <https://stackoverflow.com/a/599268/367916> . |
379,695 | <p>I am just learning php as I go along, and I'm completely lost here. I've never really used join before, and I think I need to here, but I don't know. I'm not expecting anyone to do it for me but if you could just point me in the right direction it would be amazing, I've tried reading up on joins but there are like... | [
{
"answer_id": 379749,
"author": "smartcoder",
"author_id": 44657,
"author_profile": "https://Stackoverflow.com/users/44657",
"pm_score": 2,
"selected": false,
"text": "<p>Updating board___forums whenever a post or a reply is inserted is - regarding performance - not the worst idea. For ... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am just learning php as I go along, and I'm completely lost here. I've never really used join before, and I think I need to here, but I don't know. I'm not expecting anyone to do it for me but if you could just point me in the right direction it would be amazing, I've tried reading up on joins but there are like 20 d... | Updating board\_\_\_forums whenever a post or a reply is inserted is - regarding performance - not the worst idea. For displaying the index page you only have to select data from one table board\_forums - this is definitely much faster than selecting a second table to get the "last posts' information", even when using ... |
379,748 | <p>I'm trying to set up a small app to experiment with NHibernate in visual studio but I'm not getting far. </p>
<p>The error I get is: "Could not find the dialect in the configuration".</p>
<p>I've tried specifying settings in both app.config and hibernate.cfg.xml but neither seems to work. These files are in the sa... | [
{
"answer_id": 380044,
"author": "Sam",
"author_id": 47636,
"author_profile": "https://Stackoverflow.com/users/47636",
"pm_score": 1,
"selected": false,
"text": "<p>If you're using NHibernate 2.0, but following instructions referring to 1.2, the configuration xml has changed and this wil... | 2008/12/18 | [
"https://Stackoverflow.com/questions/379748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/74652/"
] | I'm trying to set up a small app to experiment with NHibernate in visual studio but I'm not getting far.
The error I get is: "Could not find the dialect in the configuration".
I've tried specifying settings in both app.config and hibernate.cfg.xml but neither seems to work. These files are in the same directory as m... | ok thanks everyone, I've got it sorted now. It seems I needed to call cfg.Configure() to process hibernate.cfg.xml ... once I did this there were a few other errors but they were all quite logical to fix up with error messages that made good sense.
Here's the initialization code that worked.
```
public Form1()
{
... |
379,768 | <p>For example, will SQL Server warn you or does it just die?</p>
| [
{
"answer_id": 379786,
"author": "joshperry",
"author_id": 30587,
"author_profile": "https://Stackoverflow.com/users/30587",
"pm_score": 5,
"selected": true,
"text": "<p>SQL Server 2005 will throw the following error when you overflow the IDENTITY column. </p>\n\n<pre><code>Server: Msg ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/245/"
] | For example, will SQL Server warn you or does it just die? | SQL Server 2005 will throw the following error when you overflow the IDENTITY column.
```
Server: Msg 8115, Level 16, State 1, Line 1
Arithmetic overflow error converting IDENTITY to data type int.
Arithmetic overflow occurred.
```
Your identity column need not be constrained to an INT and indeed can be set to BIGI... |
379,772 | <p>I am using this example:</p>
<pre><code>char *myData[][2] =
{{"John", "j@usa.net"},
{"Erik", "erik@usa.net"},
{"Peter","peter@algonet.se"},
{"Rikard","rikard@algonet.se"},
{"Anders","anders@algonet.se"}};
char **tableData[6];
tableData[0] = myData[0];
tableData[1] = myData[1];
tableData[2] = myData[2];
tabl... | [
{
"answer_id": 379792,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "<p>The pointers in <code>myData[][]</code> as you have it initialized point to literal strings. That memory cannot b... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46767/"
] | I am using this example:
```
char *myData[][2] =
{{"John", "j@usa.net"},
{"Erik", "erik@usa.net"},
{"Peter","peter@algonet.se"},
{"Rikard","rikard@algonet.se"},
{"Anders","anders@algonet.se"}};
char **tableData[6];
tableData[0] = myData[0];
tableData[1] = myData[1];
tableData[2] = myData[2];
tableData[3] = myD... | The pointers in `myData[][]` as you have it initialized point to literal strings. That memory cannot be written to.
You can allocate new memory for your new strings and place the pointers to the new strings into `myData`. Or for what you seem to be doing, just store the pointers to the argv[] strings (as long as you'r... |
379,815 | <p>I have two versions of my application, one "stage" and one "dev."</p>
<p>Right now, "stage" is exposed to the real world for beta-testing.</p>
<p>From time to time, I want an exact replica of the data to be replicated into the "dev" database.</p>
<p>Both databases are on the same hosted Linux machine.</p>
<p>Som... | [
{
"answer_id": 379834,
"author": "Rob Booth",
"author_id": 16445,
"author_profile": "https://Stackoverflow.com/users/16445",
"pm_score": 0,
"selected": false,
"text": "<p>Just use <a href=\"http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html\" rel=\"nofollow noreferrer\">mysqldump</a> ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43980/"
] | I have two versions of my application, one "stage" and one "dev."
Right now, "stage" is exposed to the real world for beta-testing.
From time to time, I want an exact replica of the data to be replicated into the "dev" database.
Both databases are on the same hosted Linux machine.
Sometimes I create "dummy" data in... | Be sure to add security to your script so only the user you are authorizing is able to run that script. basically you want to use mysql and mysqldump commands.
```
mysqldump -u username --password=userpass --add-drop-database --add=locks --create-options --disable-keys --extend-insert --result-file=database.sql databa... |
379,818 | <p>I'm compiling some C# and VB code at run time using the CodeDomProvider, CompilerInfo, and CompilerParameters. It works great, and I really like being able to add scripting support to my application, but it only seems to support .NET 2.0 syntax. For example, the var keyword isn't supported in C#, and the If(bool, st... | [
{
"answer_id": 379819,
"author": "Don Kirkby",
"author_id": 4794,
"author_profile": "https://Stackoverflow.com/users/4794",
"pm_score": 4,
"selected": true,
"text": "<p>OK, I found a big hint here from <a href=\"http://andersnoras.com/blogs/anoras/archive/2008/04/13/codedomproviders-and-... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4794/"
] | I'm compiling some C# and VB code at run time using the CodeDomProvider, CompilerInfo, and CompilerParameters. It works great, and I really like being able to add scripting support to my application, but it only seems to support .NET 2.0 syntax. For example, the var keyword isn't supported in C#, and the If(bool, strin... | OK, I found a big hint here from [Anders Norås](http://andersnoras.com/blogs/anoras/archive/2008/04/13/codedomproviders-and-compiler-magic.aspx) that there is a constructor for the CSharpCodeProvider constructor that takes some options, including the compiler version. When I checked the [MSDN docs](http://msdn.microsof... |
379,827 | <p>As far as I know, there's no way to use {% include %} within a dynamic JS file to include styles. But I don't want to have to make another call to the server to download styles. </p>
<p>Perhaps it would be possible by taking a stylesheet and injecting it into the head element of the document...has anyone does this ... | [
{
"answer_id": 379899,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 0,
"selected": false,
"text": "<p>I can envision cases where you'd want to dynamically generate JS or CSS, but generally you're better off creating s... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] | As far as I know, there's no way to use {% include %} within a dynamic JS file to include styles. But I don't want to have to make another call to the server to download styles.
Perhaps it would be possible by taking a stylesheet and injecting it into the head element of the document...has anyone does this before? | In your JS file:
```
var style = document.createElement('link');
style.setAttribute('rel', 'stylesheet');
style.setAttribute('type', 'text/css');
style.setAttribute('href', 'style.css');
document.getElementsByTagName('head')[0].appendChild(style);
```
Hope that helps. |
379,838 | <p>I've got a form with a bunch of textboxes that are disabled by default, then enabled by use of a checkbox next to each one.</p>
<p>When enabled, the values in these textboxes are required to be a valid number, but when disabled they don't need a value (obviously). I'm using the jQuery Validation plugin to do this ... | [
{
"answer_id": 651876,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know if this is what you were going for... but wouldn't changing .required to .wasReq (as a placeholder to differen... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] | I've got a form with a bunch of textboxes that are disabled by default, then enabled by use of a checkbox next to each one.
When enabled, the values in these textboxes are required to be a valid number, but when disabled they don't need a value (obviously). I'm using the jQuery Validation plugin to do this validation,... | Using the "ignore" option (<http://docs.jquery.com/Plugins/Validation/validate#toptions>) might be the easiest way for you to deal with this. Depends on what else you have on the form. For i.e. you wouldn't filter on disabled items if you had other controls that were disabled but you still needed to validate for some r... |
379,854 | <p>I have a script that did double inserts into the database with the same data. Is there a good way to do this (without scanning through, inserting every record into an array, and then deleting duplicate array entries)?</p>
| [
{
"answer_id": 379861,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 3,
"selected": false,
"text": "<pre><code>DELETE\nFROM t\nWHERE ID IN (\n SELECT MAX(ID)\n FROM t\n GROUP BY {Your Group Criteria Here}\n H... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] | I have a script that did double inserts into the database with the same data. Is there a good way to do this (without scanning through, inserting every record into an array, and then deleting duplicate array entries)? | MySQL supports multi-table DELETE which is really cool and can help here. You can do a self-join on the equality of all columns except the `id`, and then delete the matching row with the greater `id`.
```
DELETE t2
FROM mytable t1 JOIN mytable t2
USING (column1, column2, column3) -- this is an equi-join
WHERE t1.id... |
379,865 | <p>My right side bar isn't staying on top. </p>
<p>These are the two pages for example. www.cafecartel.com </p>
<p>and www.cafecartel.com.index2.php</p>
<p>Currently the way the site is written, the right side bar must be placed like this:</p>
<p>body id="Support"
div id="container1"
div id="container2"</p>
<pre><... | [
{
"answer_id": 379994,
"author": "Michael T. Smith",
"author_id": 22292,
"author_profile": "https://Stackoverflow.com/users/22292",
"pm_score": 1,
"selected": false,
"text": "<p>I'm having trouble fully understanding the question, so my apologies in advance if I misunderstood, but to hav... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My right side bar isn't staying on top.
These are the two pages for example. www.cafecartel.com
and www.cafecartel.com.index2.php
Currently the way the site is written, the right side bar must be placed like this:
body id="Support"
div id="container1"
div id="container2"
```
div id="header"
?php include("inc/he... | I'm having trouble fully understanding the question, so my apologies in advance if I misunderstood, but to have the sidebar appear next to the content and have content appear above the sidebar in HTML, you could float the #maincontent div left, and the #sidebar div right.
`#content { clear: both; }`
`#maincontent { ... |
379,866 | <p>I am working on ASP.NET MVC.</p>
<p>in order to use AjaxHelper, I inserted two javascript files in the site.master as following.</p>
<pre><code><script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascr... | [
{
"answer_id": 383313,
"author": "Jeff.Crossett",
"author_id": 44746,
"author_profile": "https://Stackoverflow.com/users/44746",
"pm_score": 2,
"selected": false,
"text": "<p>Absolutely. The MVCAjax classes will need to reference the more generic Ajax classes. Therefore, the generic one... | 2008/12/19 | [
"https://Stackoverflow.com/questions/379866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46293/"
] | I am working on ASP.NET MVC.
in order to use AjaxHelper, I inserted two javascript files in the site.master as following.
```
<script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>
```
then I used Aja... | Absolutely. The MVCAjax classes will need to reference the more generic Ajax classes. Therefore, the generic ones get referenced first |