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
386,345
<p>Socket has a constructor that takes a winsock SOCKET as parameter and stores it in a private variable:</p> <pre><code>Socket::Socket(SOCKET s) { this-&gt;s = s; } </code></pre> <p>I'm trying to make a class "GameSocket" that will parse data from my Socket class:</p> <pre><code>class GameSocket : public Socket...
[ { "answer_id": 386365, "author": "David Allan Finch", "author_id": 27417, "author_profile": "https://Stackoverflow.com/users/27417", "pm_score": 4, "selected": true, "text": "<p>Add in a constructor for GameSocket</p>\n\n<pre><code>class GameSocket : public Socket {\n\npublic:\n\n // ...
2008/12/22
[ "https://Stackoverflow.com/questions/386345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Socket has a constructor that takes a winsock SOCKET as parameter and stores it in a private variable: ``` Socket::Socket(SOCKET s) { this->s = s; } ``` I'm trying to make a class "GameSocket" that will parse data from my Socket class: ``` class GameSocket : public Socket { protected: void ParseData(unsig...
Add in a constructor for GameSocket ``` class GameSocket : public Socket { public: // you need to add GameSocket(SOCKET s) : Socket(s) {} protected: void ParseData(unsigned char* data, int size); }; ```
386,377
<p>I'm trying to produce a pretty simple XML schema for an XML similar to the following:</p> <pre><code>&lt;messages&gt; &lt;item&gt; &lt;important_tag&gt;&lt;/important_tag&gt; &lt;/item&gt; &lt;item&gt; &lt;important_tag&gt;&lt;/important_tag&gt; &lt;tag2&gt;&lt;/tag2&gt; &lt;/item&gt; &lt;item...
[ { "answer_id": 386560, "author": "Yossi Dahan", "author_id": 43541, "author_profile": "https://Stackoverflow.com/users/43541", "pm_score": 3, "selected": false, "text": "<p>There is a great article on MSDN that talks about desigining extensible schemas, which you can find <a href=\"http:...
2008/12/22
[ "https://Stackoverflow.com/questions/386377", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48369/" ]
I'm trying to produce a pretty simple XML schema for an XML similar to the following: ``` <messages> <item> <important_tag></important_tag> </item> <item> <important_tag></important_tag> <tag2></tag2> </item> <item> <tag2></tag2> <tag3></tag3> </item> </messages> ``` The idea is that ...
Regarding the error: that error message mentions a line that's not in the xsd you included, but these two lines in it are ambiguous: ``` <xs:element ref="important_tag" minOccurs="0"/> <xs:any minOccurs="0"/> ``` The simplest example to show the ambiguity is if there was just one `<important_tag>`: ``` <important...
386,378
<p>Answers provided have all been great, I mentioned in the comments of Alnitak's answer that I would need to go take a look at my CSV Generation script because for whatever reason it wasn't outputting UTF-8. </p> <p>As was correctly pointed out, it WAS outputting UTF-8 - the problem existed with Ye Olde Microsoft Exc...
[ { "answer_id": 386396, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 5, "selected": true, "text": "<p>What you're seeing is <a href=\"http://en.wikipedia.org/wiki/UTF-8\" rel=\"noreferrer\">UTF-8</a> encoding - it's a way of...
2008/12/22
[ "https://Stackoverflow.com/questions/386378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42428/" ]
Answers provided have all been great, I mentioned in the comments of Alnitak's answer that I would need to go take a look at my CSV Generation script because for whatever reason it wasn't outputting UTF-8. As was correctly pointed out, it WAS outputting UTF-8 - the problem existed with Ye Olde Microsoft Excel which w...
What you're seeing is [UTF-8](http://en.wikipedia.org/wiki/UTF-8) encoding - it's a way of storing Unicode characters in a relatively compact format. The pound symbol has value `0x00a3` in Unicode, but when it's written in UTF-8 that becomes `0xc2 0xa3` and that's what's stored in the database. It seems that your data...
386,459
<p>I have this quiz application where I match what people type with the right answer. For now, what I do is basically that :</p> <pre><code>if ($input =~ /$answer/i) { print "you won"; } </code></pre> <p>It's nice, as if the answer is "fish" the user can type "a fish" and be counted a good answer.</p> <p>The pr...
[ { "answer_id": 386607, "author": "mjy", "author_id": 2128202, "author_profile": "https://Stackoverflow.com/users/2128202", "pm_score": 5, "selected": true, "text": "<p>Try the <a href=\"http://search.cpan.org/dist/Text-Unaccent\" rel=\"nofollow noreferrer\">Text::Unaccent</a> module from...
2008/12/22
[ "https://Stackoverflow.com/questions/386459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42083/" ]
I have this quiz application where I match what people type with the right answer. For now, what I do is basically that : ``` if ($input =~ /$answer/i) { print "you won"; } ``` It's nice, as if the answer is "fish" the user can type "a fish" and be counted a good answer. The problem I'm facing is that, well, m...
Try the [Text::Unaccent](http://search.cpan.org/dist/Text-Unaccent) module from CPAN (or [Text::Unaccent::PurePerl](http://search.cpan.org/dist/Text-Unaccent-PurePerl)).
386,476
<p>I have a table where I'm storing Lat/Long coordinates, and I want to make a query where I want to get all the records that are within a distance of a certain point.</p> <p>This table has about 10 million records, and there's an index over the Lat/Long fields</p> <p>This does not need to be precise. Among other th...
[ { "answer_id": 386522, "author": "George Mastros", "author_id": 1408129, "author_profile": "https://Stackoverflow.com/users/1408129", "pm_score": 3, "selected": true, "text": "<p>You can improve the performance of this UDF by NOT declaring variables and doing your calculations more in-li...
2008/12/22
[ "https://Stackoverflow.com/questions/386476", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
I have a table where I'm storing Lat/Long coordinates, and I want to make a query where I want to get all the records that are within a distance of a certain point. This table has about 10 million records, and there's an index over the Lat/Long fields This does not need to be precise. Among other things, I'm consider...
You can improve the performance of this UDF by NOT declaring variables and doing your calculations more in-line. This will likely improve performance a little but (but probably not much). ``` CREATE FUNCTION [dbo].[SquareDistance] (@Lat1 float, @Long1 float, @Lat2 float, @Long2 float) RETURNS float AS BEGIN Retur...
386,484
<p>I don't want my window to be resized either "only horizontally" or "only vertically." Is there a property I can set on my window that can enforce this, or is there a nifty code-behind trick I can use?</p>
[ { "answer_id": 386984, "author": "EndangeredMassa", "author_id": 106, "author_profile": "https://Stackoverflow.com/users/106", "pm_score": 1, "selected": false, "text": "<p>You could try replicating an effect that I often see on Flash Video websites. They allow you to expand the browser ...
2008/12/22
[ "https://Stackoverflow.com/questions/386484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47645/" ]
I don't want my window to be resized either "only horizontally" or "only vertically." Is there a property I can set on my window that can enforce this, or is there a nifty code-behind trick I can use?
You can reserve aspect ratio of contents using WPF's ViewBox with control with fixed width and height inside. Let's give this a try. You can change "Stretch" attribute of ViewBox to experience different results. Here is my screeen shot: ![enter image description here](https://i.stack.imgur.com/VZ9cd.jpg) ``` <Window...
386,487
<p>How do I best capture the HTML (in my instance, for logging) rendered by an aspx-page?</p> <p>I dont want to have to write back to the page using Response.Write, since it messes up my site layout.</p> <p>Using the Response.OutputStream or Response.Output's stream results in an ArgumentException ({System.ArgumentEx...
[ { "answer_id": 386502, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "<p>Many load testers will allow you to log the HTTP responses generated, but bear in mind with ASP.NET those could be som...
2008/12/22
[ "https://Stackoverflow.com/questions/386487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33067/" ]
How do I best capture the HTML (in my instance, for logging) rendered by an aspx-page? I dont want to have to write back to the page using Response.Write, since it messes up my site layout. Using the Response.OutputStream or Response.Output's stream results in an ArgumentException ({System.ArgumentException: Stream w...
Good question, i had to try out and see if i could create a HttpModule to do what you are describing. I didnt have any luck trying to read from the responsestream, but using the ResponseFilter gave me a way to capture the content. The following code seems to work pretty good, and i figured maybe you could use the co...
386,500
<p>How can I initialize a list containing generic objects whose types can be different?</p> <p>For example, I have the following:</p> <pre><code>this.Wheres = new List&lt;Where&lt;&gt;&gt;(); </code></pre> <p>As you know, &lt;> is not valid syntax. However, sometimes the type passed to Where will be a string and som...
[ { "answer_id": 386508, "author": "Sergio", "author_id": 32037, "author_profile": "https://Stackoverflow.com/users/32037", "pm_score": 1, "selected": false, "text": "<pre><code>this.Wheres = new List&lt;Object&gt;();\n</code></pre>\n" }, { "answer_id": 386514, "author": "Jon S...
2008/12/22
[ "https://Stackoverflow.com/questions/386500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31516/" ]
How can I initialize a list containing generic objects whose types can be different? For example, I have the following: ``` this.Wheres = new List<Where<>>(); ``` As you know, <> is not valid syntax. However, sometimes the type passed to Where will be a string and sometimes it will be DateTime, etc. I tried using o...
Well, you haven't really given enough context (what's SqlWhere?) but normally you'd use a type parameter: ``` public class Foo<T> { private IList<T> wheres; public Foo() { wheres = new List<T>(); } } ``` If you want a single collection to contain multiple unrelated types of values, however, you w...
386,506
<p>I am having a problem with binding values in my ActionScript components. I basically want to set the value of a a variable in my component to a value in the model, and have the component variable automatically update when the model value is updated. I think that I just don't fully understand how data binding works i...
[ { "answer_id": 386603, "author": "Alfz", "author_id": 48375, "author_profile": "https://Stackoverflow.com/users/48375", "pm_score": 2, "selected": false, "text": "<p>To use binding by code you should use mx.binding.utils.*</p>\n\n<p>Take a look and the BindingUtils.bindProperty and bindS...
2008/12/22
[ "https://Stackoverflow.com/questions/386506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31298/" ]
I am having a problem with binding values in my ActionScript components. I basically want to set the value of a a variable in my component to a value in the model, and have the component variable automatically update when the model value is updated. I think that I just don't fully understand how data binding works in F...
To fix this, I simply converted the classes to MXML components, and added a private variable for my ModelLocator. ``` /* Type1Lists.mxml */ <?xml version="1.0" encoding="utf-8"?> <TwoLists xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" availableEntities="{__model.selectedComposite.availableType1Entities...
386,554
<p>for a paper I'm looking for an <em>real-life</em> C function which uses volatile variables. That in itself is not hard to find, but I am looking for a function in which the value of the volatile variable must change <strong>during</strong> the course of the execution of the function, for a particular branch of the ...
[ { "answer_id": 386561, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 2, "selected": false, "text": "<p>Pick your favorite open source operating system, and look for old device drivers, you'll find some who have no other way of...
2008/12/22
[ "https://Stackoverflow.com/questions/386554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21369/" ]
for a paper I'm looking for an *real-life* C function which uses volatile variables. That in itself is not hard to find, but I am looking for a function in which the value of the volatile variable must change **during** the course of the execution of the function, for a particular branch of the function to be reached. ...
Some example of my teacher, which worked without volatile with one compiler (lcc), but breaked when i run it with my gcc port for that processor. I had to put volatile in. ``` static int volatile busTimeoutSeen; int busTimeoutISR(int irq) { busTimeoutSeen = 1; return 1; /* skip offending instruction */ } int me...
386,559
<p>I need to delete a temporary file from my C++ windows application (developed in Borland C++ Builder). Currently I use a simple:</p> <pre><code>system("del tempfile.tmp"); </code></pre> <p>This causes a console window to flash in front of my app and it doesn't look very professional. How do I do this without the co...
[ { "answer_id": 386565, "author": "Paul Stephenson", "author_id": 5536, "author_profile": "https://Stackoverflow.com/users/5536", "pm_score": 5, "selected": true, "text": "<p>It sounds like you need the Win32 function <a href=\"http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx\...
2008/12/22
[ "https://Stackoverflow.com/questions/386559", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2079/" ]
I need to delete a temporary file from my C++ windows application (developed in Borland C++ Builder). Currently I use a simple: ``` system("del tempfile.tmp"); ``` This causes a console window to flash in front of my app and it doesn't look very professional. How do I do this without the console window?
It sounds like you need the Win32 function [DeleteFile](http://msdn.microsoft.com/en-us/library/aa363915(VS.85).aspx)(). You will need to `#include <windows.h>` to use it.
386,576
<p>I'm working on a multilingual flex application that has to run in 27+ languages, including asian, hebrew and arabic, as well as all european languages.</p> <p>We work with an embedded font (Myriad Pro) and have plenty of styles in a css that make use of that embedded font. We've tested with a modified version of My...
[ { "answer_id": 386641, "author": "adam", "author_id": 33604, "author_profile": "https://Stackoverflow.com/users/33604", "pm_score": 0, "selected": false, "text": "<p>Rather than having the font and the language files embedded in the .swf shouldn't you be downloading them from the server?...
2008/12/22
[ "https://Stackoverflow.com/questions/386576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48375/" ]
I'm working on a multilingual flex application that has to run in 27+ languages, including asian, hebrew and arabic, as well as all european languages. We work with an embedded font (Myriad Pro) and have plenty of styles in a css that make use of that embedded font. We've tested with a modified version of Myriad inclu...
You could include a property for `fontWeight=bold` or `fontWeight=normal` in your localized property files. Then you could use [setStyle()](http://livedocs.adobe.com/flex/3/html/help.html?content=styles_08.html) to change the applications. An example from the previous link: ``` StyleManager.getStyleDeclaration("Butto...
386,583
<p>I have a Java Applet (JApplet). This Applet uses a JComponent(PanelAux) to show values and images that change periodically. But the applet doesn't refresh itself. What can I do to refresh my applet? </p> <pre><code>//--------------------------------------------RUN public void run() while (true) { try {...
[ { "answer_id": 386605, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 2, "selected": false, "text": "<p>Do you actually call the run() method at any place of start a Thread that uses it?</p>\n\n<p>Also: you definitely...
2008/12/22
[ "https://Stackoverflow.com/questions/386583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a Java Applet (JApplet). This Applet uses a JComponent(PanelAux) to show values and images that change periodically. But the applet doesn't refresh itself. What can I do to refresh my applet? ``` //--------------------------------------------RUN public void run() while (true) { try { m...
Do you actually call the run() method at any place of start a Thread that uses it? Also: you definitely don't want to add new components in your `paint()` method! That is screaming for problems!
386,604
<p>I have a program where I generate bitstreams, of about 80 to 150 bits or so, which I would like to compress, because I'm going to turn them into some kind of ASCII string so people can transmit them around.</p> <p>Does anyone know of a good, free bit-aware compressor that might work on such a stream? My main proble...
[ { "answer_id": 386610, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 2, "selected": false, "text": "<p>I'd guess that no general purpose algorithm will give you great compression for this kind of data.</p>\n\n<p>Your...
2008/12/22
[ "https://Stackoverflow.com/questions/386604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27074/" ]
I have a program where I generate bitstreams, of about 80 to 150 bits or so, which I would like to compress, because I'm going to turn them into some kind of ASCII string so people can transmit them around. Does anyone know of a good, free bit-aware compressor that might work on such a stream? My main problem with the...
What are you hoping to accomplish by compressing 150 bits? Unless you aggregate several of this 19b messages, I'm not sure what you hope to gain. Is it a UI issue--wherein you want your users to send/receive "codes"? How about [base 64 encoding](https://stackoverflow.com/questions/201479/what-is-the-use-of-base-64-enc...
386,609
<p>I have a text file with dos elements - hex(00) for example. I need to read it and convert it. I have tried to use <code>utf8toansi</code>, but this removes the whole line with hex(00). Are there any way to convert to text in the whole file ? I am using <code>win32</code>, <code>RadStudio2007</code>, <code>Delphi</c...
[ { "answer_id": 386654, "author": "mghie", "author_id": 30568, "author_profile": "https://Stackoverflow.com/users/30568", "pm_score": 2, "selected": false, "text": "<p>You could read it into a TMemoryStream, assign a PChar to the first address, and scan with a loop from 0 to Size - 1. It...
2008/12/22
[ "https://Stackoverflow.com/questions/386609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15138/" ]
I have a text file with dos elements - hex(00) for example. I need to read it and convert it. I have tried to use `utf8toansi`, but this removes the whole line with hex(00). Are there any way to convert to text in the whole file ? I am using `win32`, `RadStudio2007`, `Delphi`.
This should do... ``` procedure ConvertFileToDos(const aInFile,aOutFile:String); var FileIn,FileOut:TextFile; C:AnsiChar; LineBreak:String; begin LineBreak := #13#10; AssignFile(FileIn,aInFile); Reset(FileIn); AssignFile(FileOut,aOutFile); ReWrite(FileOut); while not EOF(FileIn) do begin Rea...
386,624
<p>I want to implement in my MFC application project this logic, which written in C# looks like:</p> <pre><code>XmlSerializer ser = new XmlSerializer(typeof(A_CLASS)); StringBuilder sb = new StringBuilder(); XmlWriterSettings sett = new XmlWriterSettings(); sett.Indent = true; sett.IndentChars = "\t"; using (XmlWriter...
[ { "answer_id": 386682, "author": "pyon", "author_id": 46571, "author_profile": "https://Stackoverflow.com/users/46571", "pm_score": 0, "selected": false, "text": "<p>As far as I know, MFC doesn't provide any classes for XML serialization. But there might be libraries out there.</p>\n" ...
2008/12/22
[ "https://Stackoverflow.com/questions/386624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I want to implement in my MFC application project this logic, which written in C# looks like: ``` XmlSerializer ser = new XmlSerializer(typeof(A_CLASS)); StringBuilder sb = new StringBuilder(); XmlWriterSettings sett = new XmlWriterSettings(); sett.Indent = true; sett.IndentChars = "\t"; using (XmlWriter sw = XmlWrite...
MFC will not really help you here, but as usual in C++ today, [Boost](http://www.boost.org/) is your friend :) The [Boost.Serialization](http://www.boost.org/doc/libs/release/libs/serialization/) library has `xml_oarchive` and `xml_iarchive`. For simple examples, have a look here: <http://www.fnord.ca/articles/xml.htm...
386,652
<p>What are the tips/techniques when you need to persist classes with inheritance to relational database that doesn't support inheritance?</p> <p>Say I have this classic example:</p> <pre><code>Person -&gt; Employee -&gt; Manager -&gt; Team lead -&gt; Developer -&gt; Custo...
[ { "answer_id": 386683, "author": "cliff.meyers", "author_id": 41754, "author_profile": "https://Stackoverflow.com/users/41754", "pm_score": 5, "selected": false, "text": "<p>Three common strategies:</p>\n\n<ol>\n<li><p>Create a table for each class in the hierarchy that contain the prope...
2008/12/22
[ "https://Stackoverflow.com/questions/386652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3055/" ]
What are the tips/techniques when you need to persist classes with inheritance to relational database that doesn't support inheritance? Say I have this classic example: ``` Person -> Employee -> Manager -> Team lead -> Developer -> Customer -> PrivilegedCustomer ...
Three common strategies: 1. Create a table for each class in the hierarchy that contain the properties defined for each class and a foreign key back to the top-level superclass table. So you might have a `vehicle` table with other tables like `car` and `airplane` that have a `vehicle_id` column. The disadvantage here ...
386,656
<p>Each client is identified by a hash, passed along with every request to the server. What's the best way to handle tracking a users session in this case?</p> <p>I'm using restful_authentication for user accounts etc. A large percentage of requests are expected to originate without a user account but just the unique ...
[ { "answer_id": 387213, "author": "zenazn", "author_id": 46848, "author_profile": "https://Stackoverflow.com/users/46848", "pm_score": 1, "selected": false, "text": "<p>Depends on what you're trying to do, but the <code>session</code> hash might provide what you want. The session stores i...
2008/12/22
[ "https://Stackoverflow.com/questions/386656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46758/" ]
Each client is identified by a hash, passed along with every request to the server. What's the best way to handle tracking a users session in this case? I'm using restful\_authentication for user accounts etc. A large percentage of requests are expected to originate without a user account but just the unique hash. My...
Using this hash in the URL means that you don't have Rails built-in session. The point of the session is to provide some sense of state between requests. You're already providing this state, seeing that you are passing this hash, so in my opinion you could remove the restful\_authentication plugin and do something like...
386,662
<p>I've been working on some data transformation tasks in SSIS. Visual Studio has gotten better in 2008 in it's usability, but I find there are some things that annoy me (i.e. When I delete something in the Package Explorer it refreshs the whole screen bringing me back to the top of the tree. Also, lack of some keyboar...
[ { "answer_id": 387213, "author": "zenazn", "author_id": 46848, "author_profile": "https://Stackoverflow.com/users/46848", "pm_score": 1, "selected": false, "text": "<p>Depends on what you're trying to do, but the <code>session</code> hash might provide what you want. The session stores i...
2008/12/22
[ "https://Stackoverflow.com/questions/386662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37726/" ]
I've been working on some data transformation tasks in SSIS. Visual Studio has gotten better in 2008 in it's usability, but I find there are some things that annoy me (i.e. When I delete something in the Package Explorer it refreshs the whole screen bringing me back to the top of the tree. Also, lack of some keyboard s...
Using this hash in the URL means that you don't have Rails built-in session. The point of the session is to provide some sense of state between requests. You're already providing this state, seeing that you are passing this hash, so in my opinion you could remove the restful\_authentication plugin and do something like...
386,664
<p>I'm having a hard time with the setup statement in Python's timeit.Timer(stmt, setup_stmt). I appreciate any help to get me out of this tricky problem:</p> <p>So my sniplet looks like this:</p> <pre><code>def compare(string1, string2): # compare 2 strings if __name__ = '__main__': str1 = "This string has ...
[ { "answer_id": 386718, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 4, "selected": true, "text": "<p>Consider This as an alternative.</p>\n\n<pre><code>t = timeit.Timer('compare(p1, p2)', \"from __main__ import compare; p1...
2008/12/22
[ "https://Stackoverflow.com/questions/386664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8203/" ]
I'm having a hard time with the setup statement in Python's timeit.Timer(stmt, setup\_stmt). I appreciate any help to get me out of this tricky problem: So my sniplet looks like this: ``` def compare(string1, string2): # compare 2 strings if __name__ = '__main__': str1 = "This string has \n several new lines...
Consider This as an alternative. ``` t = timeit.Timer('compare(p1, p2)', "from __main__ import compare; p1=%r; p2=%r" % (str1,str2)) ``` The `%r` uses the repr for the string, which Python always quotes and escapes correctly. EDIT: Fixed code by changing a comma to a semicolon; the error is now gone.
386,709
<p>Is this valid and correct?</p> <pre><code>RewriteRule ^myOldPage.html$ /index.php#info [R] </code></pre> <p>I'm specifically interested about the <code>#info</code> part.</p>
[ { "answer_id": 386739, "author": "adam", "author_id": 33604, "author_profile": "https://Stackoverflow.com/users/33604", "pm_score": 0, "selected": false, "text": "<p>Although it looks correct, I have a strange feeling this won't work.</p>\n\n<p>The browser needs to know about the #anchor...
2008/12/22
[ "https://Stackoverflow.com/questions/386709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
Is this valid and correct? ``` RewriteRule ^myOldPage.html$ /index.php#info [R] ``` I'm specifically interested about the `#info` part.
Yes. That's a valid 301 redirect (the [HTTP standard](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) allows for any valid URI to be provided as the redirect). Now the caveat: Not all search engines may love the redirect. Google does a fantastic job of handling anchor tags (they even have a [patent on this](ht...
386,713
<p>I'm trying to make two XML attributes to be mutually exclusive. How can one create an XSD schema to capture this kind of scenario?</p> <p>I would like to have one of these</p> <pre><code>&lt;elem value="1" /&gt; &lt;elem ref="something else" /&gt; </code></pre> <p>but not</p> <pre><code>&lt;elem value="1" ref="s...
[ { "answer_id": 386717, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "<p>Unfortunately AFAIK you can't do that with XML Schema, I've had the same problem myself.</p>\n\n<p>I've seen it suggested...
2008/12/22
[ "https://Stackoverflow.com/questions/386713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21704/" ]
I'm trying to make two XML attributes to be mutually exclusive. How can one create an XSD schema to capture this kind of scenario? I would like to have one of these ``` <elem value="1" /> <elem ref="something else" /> ``` but not ``` <elem value="1" ref="something else" /> ```
Since [RelaxNG](http://www.relaxng.org/) was mentioned in Alnitak's answer, here is a solution with RelaxNG (a language which is, in most cases, better than W3C Schema). Do note the OR (|) in the definition of elem: ``` start = document document = element document {elem+} elem = element elem {ref | value} ref = attrib...
386,728
<p>I am using path-based authentication with svnserve, but it is giving me permission errors if I specify a repository. However, if I just specify a path then it authenticates.</p> <p>In my authz file, if I do this it works:</p> <pre><code>[/my/path] my_username = r </code></pre> <p>If I do this, it does not work:</...
[ { "answer_id": 386789, "author": "LizB", "author_id": 13616, "author_profile": "https://Stackoverflow.com/users/13616", "pm_score": 0, "selected": false, "text": "<p>When you did svnadmin create _________ what ever you gave in that blank is your repository name. For path-based authorizat...
2008/12/22
[ "https://Stackoverflow.com/questions/386728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am using path-based authentication with svnserve, but it is giving me permission errors if I specify a repository. However, if I just specify a path then it authenticates. In my authz file, if I do this it works: ``` [/my/path] my_username = r ``` If I do this, it does not work: ``` [svn:/my/path] my_username = ...
This probably means there's only one repository known to svnserve. Please give more details about your current configuration if you want a precise answer and not guesswork.
386,731
<p>I would like to get the absolute position of an element in relation to the window/root element when it is double clicked. The element's relative position within it's parent is all I can seem to get to, and what I'm trying to get to is the point relative to the window. I've seen solutions of how to get a the point o...
[ { "answer_id": 387034, "author": "Oleg", "author_id": 47856, "author_profile": "https://Stackoverflow.com/users/47856", "pm_score": -1, "selected": false, "text": "<p>Hm.\nYou have to specify window you clicked in <code>Mouse.GetPosition(IInputElement relativeTo)</code>\nFollowing code w...
2008/12/22
[ "https://Stackoverflow.com/questions/386731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42858/" ]
I would like to get the absolute position of an element in relation to the window/root element when it is double clicked. The element's relative position within it's parent is all I can seem to get to, and what I'm trying to get to is the point relative to the window. I've seen solutions of how to get a the point of an...
I think what BrandonS wants is not the position of the *mouse* relative to the root element, but rather the position of some descendant element. For that, there is the [TransformToAncestor](http://msdn.microsoft.com/en-us/library/system.windows.media.visual.transformtoancestor.aspx) method: ``` Point relativePoint = ...
386,753
<p>I am trying to talk to a device using python. I have been handed a tuple of bytes which contains the storage information. How can I convert the data into the correct values:</p> <p>response = (0, 0, 117, 143, 6)</p> <p>The first 4 values are a 32-bit int telling me how many bytes have been used and the last valu...
[ { "answer_id": 386763, "author": "Jay", "author_id": 20840, "author_profile": "https://Stackoverflow.com/users/20840", "pm_score": 5, "selected": true, "text": "<p>See <a href=\"https://stackoverflow.com/questions/5415/\">Convert Bytes to Floating Point Numbers in Python</a> </p>\n\n<p>Y...
2008/12/22
[ "https://Stackoverflow.com/questions/386753", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24459/" ]
I am trying to talk to a device using python. I have been handed a tuple of bytes which contains the storage information. How can I convert the data into the correct values: response = (0, 0, 117, 143, 6) The first 4 values are a 32-bit int telling me how many bytes have been used and the last value is the percentage...
See [Convert Bytes to Floating Point Numbers in Python](https://stackoverflow.com/questions/5415/) You probably want to use the struct module, e.g. ``` import struct response = (0, 0, 117, 143, 6) struct.unpack(">I", ''.join([chr(x) for x in response[:-1]])) ``` Assuming an unsigned int. There may be a better way...
386,762
<p>I have a class called DatabaseHelper that wraps a DbConnection. What's the proper way to setup this class for a using statement? I have implemented IDisposible, but I'm not sure when and where I should be calling Connection.Close() or Connection.Dispose().</p> <p>When I simply call Connection.Dispose() in my own Di...
[ { "answer_id": 386772, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 4, "selected": true, "text": "<p>Call connection.Dispose() from within your dispose method. You should look at the standard pattern for implementi...
2008/12/22
[ "https://Stackoverflow.com/questions/386762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31516/" ]
I have a class called DatabaseHelper that wraps a DbConnection. What's the proper way to setup this class for a using statement? I have implemented IDisposible, but I'm not sure when and where I should be calling Connection.Close() or Connection.Dispose(). When I simply call Connection.Dispose() in my own Dispose() me...
Call connection.Dispose() from within your dispose method. You should look at the standard pattern for implementing IDisposable, which goes above and beyond simply implementing the IDisposable interface and allows for disposing unmanaged objects etc: ``` public void Dispose() { Dispose(true); GC.SuppressFinali...
386,783
<p>I don't know why this method returns a blank string:</p> <pre><code>- (NSString *)installedGitLocation { NSString *launchPath = @"/usr/bin/which"; // Set up the task NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:launchPath]; NSArray *args = [NSArray arrayWithObject:@"git"]; [tas...
[ { "answer_id": 386813, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 2, "selected": false, "text": "<p>Is /usr/local/git/bin in your $PATH when you run the program? I think <code>which</code> only looks in the user's $PA...
2008/12/22
[ "https://Stackoverflow.com/questions/386783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41116/" ]
I don't know why this method returns a blank string: ``` - (NSString *)installedGitLocation { NSString *launchPath = @"/usr/bin/which"; // Set up the task NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:launchPath]; NSArray *args = [NSArray arrayWithObject:@"git"]; [task setArguments...
Running a task via NSTask uses `fork()` and `exec()` to actually run the task. The user's interactive shell isn't involved at all. Since `$PATH` is (by and large) a shell concept, it doesn't apply when you're talking about running processes in some other fashion.
386,792
<p>In Java 1.4 you could use ((SunToolkit) Toolkit.getDefaultToolkit()).getNativeWindowHandleFromComponent() but that was removed.</p> <p>It looks like you have to use JNI to do this now. Do you have the JNI code and sample Java code to do this?</p> <p>I need this to call the Win32 GetWindowLong and SetWindowLong API...
[ { "answer_id": 389734, "author": "RealHowTo", "author_id": 25122, "author_profile": "https://Stackoverflow.com/users/25122", "pm_score": 4, "selected": false, "text": "<p>This little JNI method accepts a window title and returns the corresponding window handle.</p>\n\n<pre><code>JNIEXPOR...
2008/12/22
[ "https://Stackoverflow.com/questions/386792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35264/" ]
In Java 1.4 you could use ((SunToolkit) Toolkit.getDefaultToolkit()).getNativeWindowHandleFromComponent() but that was removed. It looks like you have to use JNI to do this now. Do you have the JNI code and sample Java code to do this? I need this to call the Win32 GetWindowLong and SetWindowLong API calls, which can...
The following code lets you pass a Component to get the window handle (HWND) for it. To make sure that a Component has a corresponding window handle call isLightWeight() on the Component and verify that it equals false. If it doesn't, try it's parent by calling Component.getParent(). Java code: ``` package win32; pub...
386,795
<p>SQL Server 2005</p> <p>I have 10 million rows in DB, and run a select (with lots of "where" and joints.. pretty complex). The results are presented in grid (think goolge results) and because of that, the user cannot possibly use more then 1000 results. </p> <p>So I limit my SQL with a TOP 1000.</p> <p><strong>Pro...
[ { "answer_id": 386805, "author": "Neil Barnwell", "author_id": 26414, "author_profile": "https://Stackoverflow.com/users/26414", "pm_score": 3, "selected": false, "text": "<p>Personally I'd opt for two statements hitting the database. One to retrieve the count, one to retrieve the first...
2008/12/22
[ "https://Stackoverflow.com/questions/386795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/350/" ]
SQL Server 2005 I have 10 million rows in DB, and run a select (with lots of "where" and joints.. pretty complex). The results are presented in grid (think goolge results) and because of that, the user cannot possibly use more then 1000 results. So I limit my SQL with a TOP 1000. **Problem**: User still wants to kn...
``` SELECT TOP 1000 x, y, z, COUNT(*) OVER () AS TotalCount FROM dbo.table ```
386,828
<p>Now I know there are a lot of similar questions around SO but I think I've covered all the basics. Here's what I know:</p> <p>My favicon is accessible through /favicon.ico (<a href="http://www.bandcmotors.co.uk/favicon.ico" rel="nofollow noreferrer">full link</a>)</p> <p>The HTML is (<a href="http://www.bandcmotor...
[ { "answer_id": 386849, "author": "PPS", "author_id": 2093, "author_profile": "https://Stackoverflow.com/users/2093", "pm_score": 1, "selected": false, "text": "<p>It works fine in my safari browser, even in windows... ;)</p>\n" }, { "answer_id": 386853, "author": "cciotti", ...
2008/12/22
[ "https://Stackoverflow.com/questions/386828", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12870/" ]
Now I know there are a lot of similar questions around SO but I think I've covered all the basics. Here's what I know: My favicon is accessible through /favicon.ico ([full link](http://www.bandcmotors.co.uk/favicon.ico)) The HTML is ([page URL](http://www.bandcmotors.co.uk)): ``` <link rel="icon" href="http://www.ba...
Have you tried using a gif or png? The [W3C documentation](http://www.w3.org/2005/10/howto-favicon) cites the following: > > However, the format for the image you have chosen must be 16x16 pixels or 32x32 pixels, using either 8-bit or 24-bit colors. The format of the image must be one of PNG (a W3C standard), GIF, or...
386,831
<p>My MS Visual C# program was compiling and running just fine. I close MS Visual C# to go off and do other things in life.</p> <p>I reopen it and (before doing anything else) go to "Publish" my program and get the following error message:</p> <blockquote> <p>Program C:\myprogram.exe does not contain a static 'Main...
[ { "answer_id": 386852, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 2, "selected": false, "text": "<p>That's odd. Does your program compile and run successfully and only fail on 'Publish' or does it fail on every compi...
2008/12/22
[ "https://Stackoverflow.com/questions/386831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
My MS Visual C# program was compiling and running just fine. I close MS Visual C# to go off and do other things in life. I reopen it and (before doing anything else) go to "Publish" my program and get the following error message: > > Program C:\myprogram.exe does not contain a static 'Main' method suitable for an en...
Are the properties on the file set to Compile?
386,838
<p>I'm working on a PHP CMS like project and I'm trying to find out what's the most convenient way of dealing with the CRUD functionality in PHP.</p> <p>The CMS is programmed completely in procedural PHP (no OOP - I know that many of you will not agree with this...) and was designed keeping everything as simple and li...
[ { "answer_id": 386936, "author": "dcousineau", "author_id": 20265, "author_profile": "https://Stackoverflow.com/users/20265", "pm_score": 3, "selected": true, "text": "<p>By CRUD operations do you mean just the (tedious) database queries?</p>\n\n<p>You could just as easily setup your dat...
2008/12/22
[ "https://Stackoverflow.com/questions/386838", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43923/" ]
I'm working on a PHP CMS like project and I'm trying to find out what's the most convenient way of dealing with the CRUD functionality in PHP. The CMS is programmed completely in procedural PHP (no OOP - I know that many of you will not agree with this...) and was designed keeping everything as simple and light as pos...
By CRUD operations do you mean just the (tedious) database queries? You could just as easily setup your database so that except for a few common fields amongst content types, all data for a particular content type is stored as a serialized associative array in a TEXT field. This way you only need 1 set of queries to ...
386,845
<p>I've written a PHP script that handles file downloads, determining which file is being requested and setting the proper HTTP headers to trigger the browser to actually download the file (rather than displaying it in the browser).</p> <p>I now have a problem where some users have reported certain files being identifi...
[ { "answer_id": 386863, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 6, "selected": true, "text": "<p>Acoording to <a href=\"http://www.rfc-editor.org/rfc/rfc2046.txt\" rel=\"noreferrer\">RFC 2046 (Multipurpose Internet Mail ...
2008/12/22
[ "https://Stackoverflow.com/questions/386845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5291/" ]
I've written a PHP script that handles file downloads, determining which file is being requested and setting the proper HTTP headers to trigger the browser to actually download the file (rather than displaying it in the browser). I now have a problem where some users have reported certain files being identified incorr...
Acoording to [RFC 2046 (Multipurpose Internet Mail Extensions)](http://www.rfc-editor.org/rfc/rfc2046.txt): > > The recommended action for an > implementation that receives an > > "application/octet-stream" entity is > to simply offer to put the data in > a file > > > So I'd go for that one.
386,854
<p>I try to keep my fingers on home row as much as possible.</p> <p>Typing all the parentheses makes me move away from there a fair bit. </p> <p>I use Emacs; the parentheses themselves are no issue, I'm comfortable with them. And I don't like modes that type them for me automatically. </p> <p>I've thought about rema...
[ { "answer_id": 386882, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 3, "selected": false, "text": "<p>I take my fingers off the home keys....</p>\n" }, { "answer_id": 386926, "author": "Adam Jaskiewicz", "au...
2008/12/22
[ "https://Stackoverflow.com/questions/386854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48419/" ]
I try to keep my fingers on home row as much as possible. Typing all the parentheses makes me move away from there a fair bit. I use Emacs; the parentheses themselves are no issue, I'm comfortable with them. And I don't like modes that type them for me automatically. I've thought about remapping the square bracket...
I would personally recommend the lethal combo of [Emacs](http://gnu.org/software/emacs/), [SLIME](http://common-lisp.net/project/slime/) & [paredit.el](http://mumble.net/~campbell/emacs/paredit.el) Paredit allows you to pseudo-semantically edit the LISP code at sexp level, and that makes the parentheses disappear almos...
386,862
<p>I've become very addicted to Project Euler recently and am trying to do <a href="http://projecteuler.net/index.php?section=problems&amp;id=221" rel="nofollow noreferrer">this</a> one next! I've started some analysis on it and have reduced the problem down substantially already. Here's my working:</p> <blockquote> ...
[ { "answer_id": 386948, "author": "lsalamon", "author_id": 47733, "author_profile": "https://Stackoverflow.com/users/47733", "pm_score": 2, "selected": false, "text": "<p>This article about Chinese remainder, fast implementation, can help you : www.codeproject.com/KB/recipes/CRP.aspx</p>\...
2008/12/22
[ "https://Stackoverflow.com/questions/386862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've become very addicted to Project Euler recently and am trying to do [this](http://projecteuler.net/index.php?section=problems&id=221) one next! I've started some analysis on it and have reduced the problem down substantially already. Here's my working: > > A = pqr and > > > 1/A = 1/p + 1/q + 1/r so pqr/A = > p...
As with many of the Project Euler problems, the trick is to find a technique that reduces the brute force solution into something more straight forward: ``` A = pqr and 1/A = 1/p + 1/q + 1/r ``` So, ``` pq + qr + rp = 1 or -r = (pq - 1)/(p + q) ``` Without loss of generality, 0 < p < -q < -r There exists k , ...
386,867
<p>I'm using LINQ to SQL to pull records from a database, sort them by a string field, then perform some other work on them. Unfortunately the Name field that I'm sorting by comes out of the database like this</p> <pre><code>Name ADAPT1 ADAPT10 ADAPT11 ... ADAPT2 ADAPT3 </code></pre> <p>I'd like to sort the Name fie...
[ { "answer_id": 386912, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 1, "selected": false, "text": "<p>Implement a <code>IComparer&lt;string&gt;</code> with your logic:</p>\n\n<pre><code>var adaptationsUnsorted = from ...
2008/12/22
[ "https://Stackoverflow.com/questions/386867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18891/" ]
I'm using LINQ to SQL to pull records from a database, sort them by a string field, then perform some other work on them. Unfortunately the Name field that I'm sorting by comes out of the database like this ``` Name ADAPT1 ADAPT10 ADAPT11 ... ADAPT2 ADAPT3 ``` I'd like to sort the Name field in numerical order. Righ...
Force the hydration of the elements by enumerating the query (call ToList). From that point on, your operations will be against in-memory objects and those operations will not be translated into SQL. ``` List<Adaptation> result = dbContext.Adaptation .Where(aun => aun.EventID = iep.EventID) .ToList(); result.Fo...
386,874
<p>I have to dump a large database over a network pipe that doesn't have that much bandwidth and other people need to use concurrently. If I try it it soaks up all the bandwidth and latency soars and everyone else gets messed up.</p> <p>I'm aware of the --compress flag to mysqldump which help somewhat.</p> <p>How can...
[ { "answer_id": 386887, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 0, "selected": false, "text": "<p>If you send it over TCP, the bandwidth will be shared equally between all parties. If you want to lower the speed ...
2008/12/22
[ "https://Stackoverflow.com/questions/386874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41613/" ]
I have to dump a large database over a network pipe that doesn't have that much bandwidth and other people need to use concurrently. If I try it it soaks up all the bandwidth and latency soars and everyone else gets messed up. I'm aware of the --compress flag to mysqldump which help somewhat. How can I do this withou...
[`trickle`](http://monkey.org/~marius/pages/?page=trickle)? > > trickle is a portable lightweight userspace bandwidth shaper > > > You don't mention how you are actually transffering the DB dump, but if the transfer happens over TCP/IP, trickle should work. For example, if you use `nc` (for example: `nc -L 1234 >...
386,914
<p>I'm creating a site that allows users to submit quotes. How would I go about creating a (relatively simple?) search that returns the most relevant quotes?</p> <p>For example, if the search term was "turkey" then I'd return quotes where the word "turkey" appears twice before quotes where it only appears once.</p> ...
[ { "answer_id": 386919, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 1, "selected": false, "text": "<p>I'd go with Full Text Search, look at it here: <a href=\"http://hockinson.com/fulltext-search-of-mysql-database-ta...
2008/12/22
[ "https://Stackoverflow.com/questions/386914", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1615/" ]
I'm creating a site that allows users to submit quotes. How would I go about creating a (relatively simple?) search that returns the most relevant quotes? For example, if the search term was "turkey" then I'd return quotes where the word "turkey" appears twice before quotes where it only appears once. (I would add a ...
Everyone is suggesting MySQL fulltext search, however you should be aware of a HUGE caveat. The Fulltext search engine is only available for the MyISAM engine (not InnoDB, which is the most commonly used engine due to its referential integrity and ACID compliance). So you have a few options: **1.** The simplest appro...
386,934
<p>I have a string representing a path. Because this application is used on Windows, OSX and Linux, we've defined environment variables to properly map volumes from the different file systems. The result is:</p> <pre><code>"$C/test/testing" </code></pre> <p>What I want to do is evaluate the environment variables in...
[ { "answer_id": 386978, "author": "jblocksom", "author_id": 20626, "author_profile": "https://Stackoverflow.com/users/20626", "pm_score": 8, "selected": true, "text": "<p>Use <a href=\"http://docs.python.org/library/os.path.html#os.path.expandvars\" rel=\"noreferrer\">os.path.expandvars</...
2008/12/22
[ "https://Stackoverflow.com/questions/386934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46914/" ]
I have a string representing a path. Because this application is used on Windows, OSX and Linux, we've defined environment variables to properly map volumes from the different file systems. The result is: ``` "$C/test/testing" ``` What I want to do is evaluate the environment variables in the string so that they're ...
Use [os.path.expandvars](http://docs.python.org/library/os.path.html#os.path.expandvars) to expand the environment variables in the string, for example: ``` >>> os.path.expandvars('$C/test/testing') '/stackoverflow/test/testing' ```
386,944
<p>Can anyone send me JavaScript code on how I can construct a time delay from the time I click a button on a page to the time the function called by the button click is executed. I am a novice with JavaScript, and I have some code that performs a function when I click a button, and I just want to have a time delay.</p...
[ { "answer_id": 386951, "author": "xtofl", "author_id": 6610, "author_profile": "https://Stackoverflow.com/users/6610", "pm_score": 3, "selected": false, "text": "<p>This is the Javascript:</p>\n\n<pre><code> function myfunction() {\n alert( \"delayed\" );\n }\n\n var delay = 1000;\n\...
2008/12/22
[ "https://Stackoverflow.com/questions/386944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can anyone send me JavaScript code on how I can construct a time delay from the time I click a button on a page to the time the function called by the button click is executed. I am a novice with JavaScript, and I have some code that performs a function when I click a button, and I just want to have a time delay.
This is the Javascript: ``` function myfunction() { alert( "delayed" ); } var delay = 1000; setTimeout( myfunction, delay ) ``` That's the essence. Now you need to hook it into a button on a html page: embed the function definition in `< script >` ... `< /script >` tags, and schedule it in the onClick met...
386,945
<p>I have the following problem: some processes, generated dynamically, have a tendency to eat 100% of CPU. I would like to limit all the process matching some criterion (e.g. process name) to a certain amount of CPU percentage.</p> <p>The specific problem I'm trying to solve is harnessing folding@home worker processe...
[ { "answer_id": 386963, "author": "MatthieuP", "author_id": 41469, "author_profile": "https://Stackoverflow.com/users/41469", "pm_score": 0, "selected": false, "text": "<p>I see at least two options:</p>\n\n<ul>\n<li>Use \"ulimit -t\" in the shell that creates your process</li>\n<li>Use \...
2008/12/22
[ "https://Stackoverflow.com/questions/386945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/390180/" ]
I have the following problem: some processes, generated dynamically, have a tendency to eat 100% of CPU. I would like to limit all the process matching some criterion (e.g. process name) to a certain amount of CPU percentage. The specific problem I'm trying to solve is harnessing folding@home worker processes. The bes...
I had a slightly similar issue with `gzip`. Assuming we want to decrease the CPU of a `gzip` process: ``` gzip backup.tar & sleep 2 & cpulimit --limit 10 -e gzip -z ``` Options: * I found `sleep` useful as the `cpulimit` sometimes didn't pick up the new `gzip` process immediately * `--limit 10` limits `gzip` ...
386,981
<p>So I have the following code:</p> <pre><code> return from a in DBContext.Acts join artist in DBContext.Artists on a.ArtistID equals artist.ID into art from artist in art.DefaultIfEmpty() select new Shared.DO.Act { ID = a.ID, Name = a.Name, ...
[ { "answer_id": 387000, "author": "Filip Ekberg", "author_id": 39106, "author_profile": "https://Stackoverflow.com/users/39106", "pm_score": 0, "selected": false, "text": "<p>You want to create a new object, by calling the constructor. Remove Artist = and then replace { } with ().</p>\n...
2008/12/22
[ "https://Stackoverflow.com/questions/386981", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46616/" ]
So I have the following code: ``` return from a in DBContext.Acts join artist in DBContext.Artists on a.ArtistID equals artist.ID into art from artist in art.DefaultIfEmpty() select new Shared.DO.Act { ID = a.ID, Name = a.Name, Artist = new ...
``` Artist = new Shared.DO.Artist { ID = artist == null ? Guid.NewGuid() : artist.ID, Name = artist == null ? string.Empty : artist.Name } ``` Alternatively, add a constructor to Shared.DO.Artist that takes the Linq representation of Artist. The construct...
386,982
<p>I'm trying to use the library released by Novell (Novell.Directory.Ldap). Version 2.1.10.</p> <p>What I've done so far: </p> <ul> <li><p>I tested the connection with an application (<a href="http://www.mcs.anl.gov/~gawor/ldap/index.html" rel="noreferrer">LdapBrowser</a>) and it's working, so its not a communicatio...
[ { "answer_id": 387033, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 2, "selected": false, "text": "<p>91 is \"cannot connect\". Try to put the server in \"ldap://x.x.x.x\" format, check that userDN is set properly...
2008/12/22
[ "https://Stackoverflow.com/questions/386982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16154/" ]
I'm trying to use the library released by Novell (Novell.Directory.Ldap). Version 2.1.10. What I've done so far: * I tested the connection with an application ([LdapBrowser](http://www.mcs.anl.gov/~gawor/ldap/index.html)) and it's working, so its not a communication problem. * It's compiled in Mono, but I'm working ...
I finally found a way to make this work. First, theses posts helped me get on the right track : <http://directoryprogramming.net/forums/thread/788.aspx> Second, I got a compiled dll of the Novell LDAP Library and used the Mono.Security.Dll. The solution: I added this function to the code ``` // This is the Callba...
387,076
<p>How can I use Linq with Dataset.xsd files?</p> <p>I've looked at Linq-to-Datasets and Linq-to-XSD but they don't really seem to work directly with the Visual Studio DataSet.xsd files.</p> <p><strong>EDIT:</strong> I actually found a great link for this: <a href="http://msdn.microsoft.com/en-us/vbasic/bb738035.asp...
[ { "answer_id": 387170, "author": "Ryan Lundy", "author_id": 5486, "author_profile": "https://Stackoverflow.com/users/5486", "pm_score": 3, "selected": true, "text": "<p>A DataSet is just a container for your data, so you need to fill it first. <strong>LINQ to SQL</strong> will create SQ...
2008/12/22
[ "https://Stackoverflow.com/questions/387076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47167/" ]
How can I use Linq with Dataset.xsd files? I've looked at Linq-to-Datasets and Linq-to-XSD but they don't really seem to work directly with the Visual Studio DataSet.xsd files. **EDIT:** I actually found a great link for this: [link text](http://msdn.microsoft.com/en-us/vbasic/bb738035.aspx) but I can't seem to figur...
A DataSet is just a container for your data, so you need to fill it first. **LINQ to SQL** will create SQL and go to the database for you...but when you're working with DataSets, you're using **LINQ to Objects**, which won't create SQL. So you need to make sure that **all** tables you need in the DataSet are filled bef...
387,091
<p>Here's my code:</p> <pre><code>public class Sequence&lt;T&gt; { protected List&lt;T&gt; sequence = new ArrayList&lt;T&gt;(); public Matrix&lt;OrderedPair&lt;T, ?&gt;&gt; createCartesianProduct(Sequence&lt;?&gt; secondSequence) { Matrix&lt;OrderedPair&lt;T, ?&gt;&gt; result = new Matrix&lt;OrderedP...
[ { "answer_id": 387107, "author": "maxnk", "author_id": 45862, "author_profile": "https://Stackoverflow.com/users/45862", "pm_score": 0, "selected": false, "text": "<p>Trust compiler and try to use generic parameters always when calling for OrderedPair :)\nIt's <strong>not required</stron...
2008/12/22
[ "https://Stackoverflow.com/questions/387091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Here's my code: ``` public class Sequence<T> { protected List<T> sequence = new ArrayList<T>(); public Matrix<OrderedPair<T, ?>> createCartesianProduct(Sequence<?> secondSequence) { Matrix<OrderedPair<T, ?>> result = new Matrix<OrderedPair<T, ?>>(); for (int rowIndex = 0; rowIndex < sequence....
The constructor in the inner for loop should have generics: ``` row.add(new OrderedPair **<T, ?>** (sequence.get(rowIndex), secondSequence.sequence.get(columnIndex))); ``` But you can't use `?` like this; so you'll need to replace all the `?`s with a letter, say `E`. Then add an `<E>` into the signature, like this: ...
387,112
<p>Binding a List collection to a datagrid. How can you limit what properties will be displayed?</p> <pre><code>DataGridViewAirport.DataSource = GlobalDisplayAirports </code></pre>
[ { "answer_id": 387125, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 3, "selected": true, "text": "<p>Turn off AutoGenerateColumns, and then you can explicitly create the columns you need. For example here's an example:<...
2008/12/22
[ "https://Stackoverflow.com/questions/387112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
Binding a List collection to a datagrid. How can you limit what properties will be displayed? ``` DataGridViewAirport.DataSource = GlobalDisplayAirports ```
Turn off AutoGenerateColumns, and then you can explicitly create the columns you need. For example here's an example: ``` <asp:GridView ID="myGrid" runat="server" AutoGenerateColumns="False" CellSpacing="0"> <Columns> <asp:BoundField DataField="Total" HeaderText="Amount" DataFormatString="{0:C}"/> </Colu...
387,113
<p>I'm using VBA in the Excel VBE, but c# or vb are fine. The concept should hold true across the languages.</p>
[ { "answer_id": 387700, "author": "BradC", "author_id": 21398, "author_profile": "https://Stackoverflow.com/users/21398", "pm_score": 3, "selected": true, "text": "<p>Not sure what you mean. You want to go through from the bottom to top, instead of top to bottom?</p>\n\n<p>This should do:...
2008/12/22
[ "https://Stackoverflow.com/questions/387113", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25197/" ]
I'm using VBA in the Excel VBE, but c# or vb are fine. The concept should hold true across the languages.
Not sure what you mean. You want to go through from the bottom to top, instead of top to bottom? This should do: ``` Dim myrange As Range Set myrange = Range("B3:E10") Dim row As Integer, col As Integer For row = myrange.Rows.Count To 1 Step -1 For col = myrange.Columns.Count To 1 Step -1 Debug.Print myr...
387,124
<p>Recommended by the ASP.NET team to use cache instead of session, we stopped using session from working with the WebForm model the last few years. So we normally have the session turned off in the web.config</p> <pre><code>&lt;sessionState mode="Off" /&gt; </code></pre> <p>But, now when I'm testing out a ASP.NET M...
[ { "answer_id": 387162, "author": "maxnk", "author_id": 45862, "author_profile": "https://Stackoverflow.com/users/45862", "pm_score": 3, "selected": false, "text": "<p>Hmm... May be you've read about persisting of the heavy objects or relatively rarely accessed objects - it's definitely b...
2008/12/22
[ "https://Stackoverflow.com/questions/387124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32240/" ]
Recommended by the ASP.NET team to use cache instead of session, we stopped using session from working with the WebForm model the last few years. So we normally have the session turned off in the web.config ``` <sessionState mode="Off" /> ``` But, now when I'm testing out a ASP.NET MVC application with this setting ...
Session is used for the TempData store. TempData is a highly limited form of session state which will last only until the next request from a certain user. (**Edit** In MVC 2+, it lasts until it is next read.) The purpose of TempData is to store data, then do a redirect, and have the stored data be available to the act...
387,128
<p>I'm trying to do precedence matching on a table within a stored procedure. The requirements are a bit tricky to explain, but hopefully this will make sense. Let's say we have a table called books, with id, author, title, date, and pages fields. </p> <p>We also have a stored procedure that will match a query with ON...
[ { "answer_id": 387169, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 1, "selected": false, "text": "<p>You don't explain what should happen if more than one result matches any given set of parameters that is reached, so ...
2008/12/22
[ "https://Stackoverflow.com/questions/387128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27689/" ]
I'm trying to do precedence matching on a table within a stored procedure. The requirements are a bit tricky to explain, but hopefully this will make sense. Let's say we have a table called books, with id, author, title, date, and pages fields. We also have a stored procedure that will match a query with ONE row in t...
I believe that the answers your working on are the simplest by far. But I also believe that in SQL server, they will always be full table scans. (IN Oracle you could use Bitmap indexes if the table didn't undergo a lot of simultaneous DML) A more complex solution but a much more performant one would be to build your o...
387,130
<p>Working in academia publishing CS/math, you sooner or later find yourself trying to publish in a journal that will only accept .doc/.rtf. This means tedious, boring hours of translating line after line, especially equations, from LaTeX to an inferior format. Over the years I have tried a number of export tools for L...
[ { "answer_id": 387169, "author": "Tom H", "author_id": 5696608, "author_profile": "https://Stackoverflow.com/users/5696608", "pm_score": 1, "selected": false, "text": "<p>You don't explain what should happen if more than one result matches any given set of parameters that is reached, so ...
2008/12/22
[ "https://Stackoverflow.com/questions/387130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27126/" ]
Working in academia publishing CS/math, you sooner or later find yourself trying to publish in a journal that will only accept .doc/.rtf. This means tedious, boring hours of translating line after line, especially equations, from LaTeX to an inferior format. Over the years I have tried a number of export tools for LaTe...
I believe that the answers your working on are the simplest by far. But I also believe that in SQL server, they will always be full table scans. (IN Oracle you could use Bitmap indexes if the table didn't undergo a lot of simultaneous DML) A more complex solution but a much more performant one would be to build your o...
387,141
<p>I'd like to check if the system is in standby mode, is there any Win32 API for that? I'm not sure if it's the same as the sleep mode.</p> <p>There's some code that gets executed in my app, which causes it to hang when coming out of standby (it's executed during the standby mode), so I'd like to avoid running that c...
[ { "answer_id": 387155, "author": "Joachim Sauer", "author_id": 40342, "author_profile": "https://Stackoverflow.com/users/40342", "pm_score": 3, "selected": true, "text": "<p>When the system is in standby mode, then no program will be running, so the following would be ok:</p>\n\n<pre><co...
2008/12/22
[ "https://Stackoverflow.com/questions/387141", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20208/" ]
I'd like to check if the system is in standby mode, is there any Win32 API for that? I'm not sure if it's the same as the sleep mode. There's some code that gets executed in my app, which causes it to hang when coming out of standby (it's executed during the standby mode), so I'd like to avoid running that code when t...
When the system is in standby mode, then no program will be running, so the following would be ok: ``` int is_in_standby() { return 0; } ``` Or am I missing something?
387,142
<p>I am writing a web server and client test stub for it. I have questions regarding memory management of the parameters.</p> <p>From my client I am calling a soap function ns1_func1(input * pInput, output* pOutput) Now both input and output class contain pointers to other structs.</p> <p>For e.g </p> <p>class Outpu...
[ { "answer_id": 388260, "author": "DGentry", "author_id": 4761, "author_profile": "https://Stackoverflow.com/users/4761", "pm_score": 1, "selected": false, "text": "<p>Because the client and server are generally different processes, or different machines, they are each responsible for the...
2008/12/22
[ "https://Stackoverflow.com/questions/387142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am writing a web server and client test stub for it. I have questions regarding memory management of the parameters. From my client I am calling a soap function ns1\_func1(input \* pInput, output\* pOutput) Now both input and output class contain pointers to other structs. For e.g class Output { class abc \* p1;...
Because the client and server are generally different processes, or different machines, they are each responsible for their own memory management. The client must allocate the memory for its input parameters, which gsoap then serializes to send to the server. The server deserializes the input parameters, allocating an...
387,145
<p>You can read about the 64-bit calling convention <a href="http://msdn.microsoft.com/en-us/library/ms794533.aspx" rel="nofollow noreferrer">here</a>. x64 functions are supposed to clean up after themselves however, when I call malloc from .asm, it overwrites the value at RSP and RSP+8. This seems very wrong. Any s...
[ { "answer_id": 387214, "author": "Brian", "author_id": 16457, "author_profile": "https://Stackoverflow.com/users/16457", "pm_score": 0, "selected": false, "text": "<p>I'm not sure, truthfully, but have you tried stepping through the assembly in a debugger? If you follow the internal log...
2008/12/22
[ "https://Stackoverflow.com/questions/387145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18051/" ]
You can read about the 64-bit calling convention [here](http://msdn.microsoft.com/en-us/library/ms794533.aspx). x64 functions are supposed to clean up after themselves however, when I call malloc from .asm, it overwrites the value at RSP and RSP+8. This seems very wrong. Any suggestions? ``` public TestMalloc extern ...
For the x64 calling convention, even if the parameters are passed in the registers the caller is required to save space for them on the stack: > > Note that space is always allocated > for the register parameters, even if > the parameters themselves are never > homed to the stack; a callee is > guaranteed that sp...
387,167
<p>I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so:</p> <pre><code>&lt;cc1:customControl runat="server" Title='&lt;%= PagePropertyValue%&gt;' &gt; more content &lt;/cc1:customControl&gt; </code></pre> <p>When I do this, ...
[ { "answer_id": 387179, "author": "Zachary Yates", "author_id": 8360, "author_profile": "https://Stackoverflow.com/users/8360", "pm_score": 1, "selected": false, "text": "<p>Try using databinding syntax:\n<code>&lt;%# PagePropertyValue %&gt;</code></p>\n" }, { "answer_id": 387208,...
2008/12/22
[ "https://Stackoverflow.com/questions/387167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13100/" ]
I have a custom server control with a property of Title. When using the control, I'd like to set the value of the title in the aspx page like so: ``` <cc1:customControl runat="server" Title='<%= PagePropertyValue%>' > more content </cc1:customControl> ``` When I do this, however, I am getting the exact String <%= Pa...
You cant. <%= %> will write the string directly to the response-stream, which happens after the server control is constructed. See [this post](https://stackoverflow.com/questions/370201/why-will-expressions-as-property-values-on-a-server-controls-lead-to-a-compile) for an explanation. So its either codebehind, or <%# ...
387,198
<p>I have an international company that has recently been added, which is named "BLA "BLAHBLAH" Ltd. (The double quotes are part of the name. )</p> <p>Whenever a user tries to search for this company, by entering "Blah, or something to that affect, the search fails with a syntax error in SQL server.</p> <p>How can I ...
[ { "answer_id": 387218, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>I strongly suspect you're building the SQL dynamically - e.g. </p>\n\n<pre><code>// Bad code, do not use!\nstring sql...
2008/12/22
[ "https://Stackoverflow.com/questions/387198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32772/" ]
I have an international company that has recently been added, which is named "BLA "BLAHBLAH" Ltd. (The double quotes are part of the name. ) Whenever a user tries to search for this company, by entering "Blah, or something to that affect, the search fails with a syntax error in SQL server. How can I escape this so th...
Unfortunately, double-quotes have special meaning inside FTI, so even if you parameterize it, the FTI engine treats it as a phrase delimiter. I am not sure there is an easy way to include double-quotes in an FTI search. Brackets are also a special character, but can be encased in quotes to treat as a query term - but n...
387,223
<p>In Rails, I'm coding a series of controllers to generate XML. Each time I'm passing a number of properties in to to_xml like:</p> <pre><code>to_xml(:skip_types =&gt; true, :dasherize =&gt; false) </code></pre> <p>Is there a way I can set these as new default properties that will apply whenever to_xml is called in ...
[ { "answer_id": 387308, "author": "csexton", "author_id": 19839, "author_profile": "https://Stackoverflow.com/users/19839", "pm_score": 3, "selected": true, "text": "<p>Are you calling to_xml on a hash or an ActiveRecord model (or something else)? </p>\n\n<p>I am not that you would want ...
2008/12/22
[ "https://Stackoverflow.com/questions/387223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40956/" ]
In Rails, I'm coding a series of controllers to generate XML. Each time I'm passing a number of properties in to to\_xml like: ``` to_xml(:skip_types => true, :dasherize => false) ``` Is there a way I can set these as new default properties that will apply whenever to\_xml is called in my app so that I don't have to...
Are you calling to\_xml on a hash or an ActiveRecord model (or something else)? I am not that you would want to, but you can easily monkey patch to\_xml and redefine it to start with those parameters. I would suggest that you make a new method to\_default\_xml that simply called to\_xml with the parameters you wanted...
387,229
<p>I'm using HTML emails for a client's newsletter. Not using HTML mails is <strong>not</strong> an option. I've used PHPMailer for mailing, but I've also tried using PHP's mail() function directly. In both instances, I get the same problem described below. I've tried sending as multipart as well as sending just the HT...
[ { "answer_id": 389044, "author": "Chase Seibert", "author_id": 7679, "author_profile": "https://Stackoverflow.com/users/7679", "pm_score": 0, "selected": false, "text": "<p>Adding a newline before the HTML in the second MIME block will fix your issue. You can also set \"Content-Dispositi...
2008/12/22
[ "https://Stackoverflow.com/questions/387229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7927/" ]
I'm using HTML emails for a client's newsletter. Not using HTML mails is **not** an option. I've used PHPMailer for mailing, but I've also tried using PHP's mail() function directly. In both instances, I get the same problem described below. I've tried sending as multipart as well as sending just the HTML version. In ...
Okay, I think I solved the problem. The various lines in the header were separated by \r\n and apparently Outlook expected them to be separated by \n only. Even PHPMailer seems to do this, so I'm using PHP's mail() function now.
387,233
<p>I am working with ASP.NET doing some client side javascript.<br> I have the following javascript to handle an XMLHTTPRequest callback. In certain situations, the page will be posted back, using the __doPostBack() function provided by ASP.NET, listed in the code below. However, I would like to be able to set the fo...
[ { "answer_id": 387257, "author": "Mark Brackett", "author_id": 2199, "author_profile": "https://Stackoverflow.com/users/2199", "pm_score": 2, "selected": false, "text": "<p>Since you're doing a full postback, you'd need to use <a href=\"http://msdn.microsoft.com/en-us/library/e04ah0f4.as...
2008/12/22
[ "https://Stackoverflow.com/questions/387233", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18893/" ]
I am working with ASP.NET doing some client side javascript. I have the following javascript to handle an XMLHTTPRequest callback. In certain situations, the page will be posted back, using the \_\_doPostBack() function provided by ASP.NET, listed in the code below. However, I would like to be able to set the focus ...
i have found the solution for this one. In the code behind event handler being called for each particular item, I call the Control.Focus() as the last line. For instance, if a dropdownlist event handler is being triggered, and the next control to get focused is the zipcode text box: ``` protected void ddl_state_select...
387,234
<p>There is a nice state machine tutorial called <a href="http://www.objectmentor.com/resources/articles/umlfsm.pdf" rel="nofollow noreferrer">UML Tutorial: Finite State Machines</a> by Robert C. Martin. But I can't compile the sample code it provides. I got *FsmTest.cpp(46) : error C2664: 'SetState' : cannot convert p...
[ { "answer_id": 387264, "author": "jmucchiello", "author_id": 44065, "author_profile": "https://Stackoverflow.com/users/44065", "pm_score": 1, "selected": false, "text": "<p>Most likely this is because it does not know UnlockedState is a subclass of TurnstileState yet. Remove the function...
2008/12/22
[ "https://Stackoverflow.com/questions/387234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
There is a nice state machine tutorial called [UML Tutorial: Finite State Machines](http://www.objectmentor.com/resources/articles/umlfsm.pdf) by Robert C. Martin. But I can't compile the sample code it provides. I got \*FsmTest.cpp(46) : error C2664: 'SetState' : cannot convert parameter 1 from 'class UnlockedState \*...
The problem is that when you try to call `SetState()` inside of `LockedState::Coin()`, the class `UnlockedState` is an **incomplete type**: it has been *declared* but not *defined*. In order to fix it, you'll need to move the definition of of `Coin()` to after that of `UnlockedState`: ``` class LockedState : public Tu...
387,247
<p>My objective is to get the answer from up to 6000 Urls in the shortest time. It was working very well (12 seconds for 5200 LAN Addresses) until some delay started to happen.</p> <p>My code uses up to 20 simultaneous HttpWebRequest.BeginGetResponse with <code>ThreadPool.RegisterWaitForSingleObject</code> for timeout...
[ { "answer_id": 390034, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>It sounds like you need to set the ReadWriteTimeout property of the request object. </p>\n\n<p><a href=\"http://blogs.msdn....
2008/12/22
[ "https://Stackoverflow.com/questions/387247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48465/" ]
My objective is to get the answer from up to 6000 Urls in the shortest time. It was working very well (12 seconds for 5200 LAN Addresses) until some delay started to happen. My code uses up to 20 simultaneous HttpWebRequest.BeginGetResponse with `ThreadPool.RegisterWaitForSingleObject` for timeout handling. However s...
It sounds like you need to set the ReadWriteTimeout property of the request object. <http://blogs.msdn.com/buckh/archive/2005/02/01/365127.aspx>
387,260
<p>I would like to stop images from loading, as in not even get a chance to download, using greasemonkey. Right now I have </p> <pre><code>var images = document.getElementsByTagName('img'); for (var i=0; i&lt;images.length; i++){ images[i].src = ""; } </code></pre> <p>but I don't think this actually stops the i...
[ { "answer_id": 387276, "author": "PEZ", "author_id": 44639, "author_profile": "https://Stackoverflow.com/users/44639", "pm_score": 0, "selected": false, "text": "<p>Do you know that the images still load? Maybe you should assert it using Firebug or some such?</p>\n" }, { "answer_...
2008/12/22
[ "https://Stackoverflow.com/questions/387260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41718/" ]
I would like to stop images from loading, as in not even get a chance to download, using greasemonkey. Right now I have ``` var images = document.getElementsByTagName('img'); for (var i=0; i<images.length; i++){ images[i].src = ""; } ``` but I don't think this actually stops the images from downloading. Anyone...
Almost all images are not downloaded. So your script almost working as is. I've tested the following script: ``` // ==UserScript== // @name stop downloading images // @namespace http://stackoverflow.com/questions/387388 // @include http://flickr.com/* // ==/UserScript== var images = document.g...
387,309
<p>We're migrating home folders to a new filesystem, and I am looking for a way to automate it using Perl or a shell script. I don't have much choice in programming languages as the systems are proprietary storage clusters that should remain as unchanged as possible.</p> <p>Task: Under directory /home/ I have various ...
[ { "answer_id": 387319, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 4, "selected": true, "text": "<p><code>cp</code>'s -a flag will maintain permission, modification times etc. You should for be able to do something lik...
2008/12/22
[ "https://Stackoverflow.com/questions/387309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18406/" ]
We're migrating home folders to a new filesystem, and I am looking for a way to automate it using Perl or a shell script. I don't have much choice in programming languages as the systems are proprietary storage clusters that should remain as unchanged as possible. Task: Under directory /home/ I have various users' hom...
`cp`'s -a flag will maintain permission, modification times etc. You should for be able to do something like: ``` for a in `ls /home`; do cp -a "/home/$a" "/newhome/$a" ; done ``` Try it with one directory to see if does what you need before automating it. EDIT: You can disable recursive file copying by using rsync...
387,318
<p>After peeking at the SO <a href="http://view-source:" rel="nofollow noreferrer">source</a>, I noticed this tag:</p> <pre><code>&lt;link rel="apple-touch-icon" href="/apple-touch-icon.png" /&gt; </code></pre> <p>Which after a quick Google <a href="http://allinthehead.com/retro/319/how-to-set-an-apple-touch-icon-for...
[ { "answer_id": 387352, "author": "Marc Charbonneau", "author_id": 35136, "author_profile": "https://Stackoverflow.com/users/35136", "pm_score": 2, "selected": false, "text": "<p>A useful header tag for single-purpose webapps is <a href=\"http://daringfireball.net/linked/2008/10/03/fullsc...
2008/12/22
[ "https://Stackoverflow.com/questions/387318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6144/" ]
After peeking at the SO [source](http://view-source:), I noticed this tag: ``` <link rel="apple-touch-icon" href="/apple-touch-icon.png" /> ``` Which after a quick Google [revealed](http://allinthehead.com/retro/319/how-to-set-an-apple-touch-icon-for-any-site) an Apple "favicon" type thing for display on your homepa...
``` <meta name="viewport" content="width=320, initial-scale=2.3, user-scalable=no"> ``` Allows you to set the width, height and scale values ``` <meta name="apple-mobile-web-app-status-bar-style" content="black" /> ``` Set the status bar style, pretty self explanatory. ``` <meta name="apple-mobile-web-app-capable...
387,322
<p>I am working on a Windows utility program which communicates with some custom hardware using a standard COM port. The communication protocol (which is out of my control) requires me to transmit and receive raw 8-bit data bytes.</p> <p>I am currently using the following Windows API function to send data to the COM p...
[ { "answer_id": 387384, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms810467.aspx\" rel=\"nofollow noreferrer\">Serial Communications in...
2008/12/22
[ "https://Stackoverflow.com/questions/387322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33686/" ]
I am working on a Windows utility program which communicates with some custom hardware using a standard COM port. The communication protocol (which is out of my control) requires me to transmit and receive raw 8-bit data bytes. I am currently using the following Windows API function to send data to the COM port: ``` ...
I've done Windows serial port programming before, and am sure that I have been able to send null characters through the serial ports (various file transfer protocols wouldn't have worked otherwise). I can think of two possible explanations: 1. The *receiving* device is printing the data it received using a method that...
387,334
<p>I have a dataview defined as:</p> <pre><code>DataView dvPricing = historicalPricing.GetAuctionData().DefaultView; </code></pre> <p>This is what I have tried, but it returns the name, not the value in the column:</p> <pre><code>dvPricing.ToTable().Columns["GrossPerPop"].ToString(); </code></pre>
[ { "answer_id": 387343, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 4, "selected": true, "text": "<p>You need to specify the row for which you want to get the value. I would probably be more along the lines of table.Rows[in...
2008/12/22
[ "https://Stackoverflow.com/questions/387334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
I have a dataview defined as: ``` DataView dvPricing = historicalPricing.GetAuctionData().DefaultView; ``` This is what I have tried, but it returns the name, not the value in the column: ``` dvPricing.ToTable().Columns["GrossPerPop"].ToString(); ```
You need to specify the row for which you want to get the value. I would probably be more along the lines of table.Rows[index]["GrossPerPop"].ToString()
387,340
<p>I am working on a .jar file library to implement a bunch of helper classes to interface a PC to a piece of external hardware. I'll also add some simple applications, either command-line or GUI, to handle common tasks using the library.</p> <p>My question is, is there a recommended way to simplify the command-line i...
[ { "answer_id": 387345, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 0, "selected": false, "text": "<p>A batch file would do the job. Put the exact command you want executed into a file myProg.bat and run it.</p>\n" }, { ...
2008/12/22
[ "https://Stackoverflow.com/questions/387340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44330/" ]
I am working on a .jar file library to implement a bunch of helper classes to interface a PC to a piece of external hardware. I'll also add some simple applications, either command-line or GUI, to handle common tasks using the library. My question is, is there a recommended way to simplify the command-line instantiati...
1. When you use `-jar`, then`-cp` (and the `CLASSPATH` variable) will be ignored 2. Just provide a executable jar. "`java -jar TheApp <whateverargumentsyouwant>`" shouldn't be too hard (you can have a [Class-Path attribute](http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#Main%20Attributes) in your `jar`...
387,417
<p>I have several instances where that a section of legacy sql statements is based on a dependency. for example. </p> <pre><code>if (x !=null) { SQL = "SELECT z WHERE x &gt; y"; } else { SQL = "SELECT z WHERE x &lt;= y"; } SQL2 = SQL + " JOIN a ON b"; </code></pre> <p>I am creating PreparedStatements out of thi...
[ { "answer_id": 387538, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 1, "selected": false, "text": "<p>This is not the proper use of prepared statement parameters. Parameters can be used only in place of a literal val...
2008/12/22
[ "https://Stackoverflow.com/questions/387417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13491/" ]
I have several instances where that a section of legacy sql statements is based on a dependency. for example. ``` if (x !=null) { SQL = "SELECT z WHERE x > y"; } else { SQL = "SELECT z WHERE x <= y"; } SQL2 = SQL + " JOIN a ON b"; ``` I am creating PreparedStatements out of this legacy code. What is the best-...
*>Should I create a PreparedStatement for the var SQL and nest it inside of SQL2* No *>Or should there be multiple PreparedStatements based on SQL2 without nesting* Yes Furthermore: If you could create one string per query that would be better. I don't really like to mix SQL with code. It makes it harder to debug a...
387,424
<p>I'm always surprised that even after using C# for all this time now, I still manage to find things I didn't know about...</p> <p>I've tried searching the internet for this, but using the "~" in a search isn't working for me so well and I didn't find anything on MSDN either (not to say it isn't there)</p> <p>I saw ...
[ { "answer_id": 387427, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 5, "selected": false, "text": "<pre><code>public enum PurchaseMethod\n{ \n All = ~0, // all bits of All are 1. the ~ operator just in...
2008/12/22
[ "https://Stackoverflow.com/questions/387424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17091/" ]
I'm always surprised that even after using C# for all this time now, I still manage to find things I didn't know about... I've tried searching the internet for this, but using the "~" in a search isn't working for me so well and I didn't find anything on MSDN either (not to say it isn't there) I saw this snippet of c...
~ is the unary one's complement operator -- it flips the bits of its operand. ``` ~0 = 0xFFFFFFFF = -1 ``` in two's complement arithmetic, `~x == -x-1` the ~ operator can be found in pretty much any language that borrowed syntax from C, including Objective-C/C++/C#/Java/Javascript.
387,434
<p>In SQL server you can use the DATENAME function to get the day of week as a string</p> <pre><code>declare @date datetime set @date = '12/16/08' select datename(dw, @date) </code></pre> <p>which returns "Tuesday"</p> <p>and you can use the DATEPART function to get the day of week as an integer</p> <pre><code>decl...
[ { "answer_id": 387441, "author": "HLGEM", "author_id": 9034, "author_profile": "https://Stackoverflow.com/users/9034", "pm_score": 5, "selected": true, "text": "<p>Rather than write a function, you should create a days of the week table with the description and the numeric value. THen yo...
2008/12/22
[ "https://Stackoverflow.com/questions/387434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17917/" ]
In SQL server you can use the DATENAME function to get the day of week as a string ``` declare @date datetime set @date = '12/16/08' select datename(dw, @date) ``` which returns "Tuesday" and you can use the DATEPART function to get the day of week as an integer ``` declare @date datetime set @date = '12/16/08' se...
Rather than write a function, you should create a days of the week table with the description and the numeric value. THen you can simply join to the table to get the numeric. And if you have days stored multiple ways (likely in a characterbased system), you can put all the variants into the table, so TUE, Tues., Tuesd...
387,438
<p>i wonder if i've found a compiler bug? i was removing some old code from my app and now i get stackoverflow at "begin" (see code &amp; disassembly below).</p> <pre><code>procedure TfraNewRTMDisplay.ShowMeasurement; var iDummy, iDummy2, iDummy3:integer; begin // STACK OVERFLOW BEFORE MY CODE STARTS iDummy:=0...
[ { "answer_id": 387478, "author": "Yuliy", "author_id": 47527, "author_profile": "https://Stackoverflow.com/users/47527", "pm_score": 2, "selected": false, "text": "<p>Something's creating a 320 KB buffer. Do you have any of those objects in that chain of calls have a statically allocated...
2008/12/22
[ "https://Stackoverflow.com/questions/387438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14031/" ]
i wonder if i've found a compiler bug? i was removing some old code from my app and now i get stackoverflow at "begin" (see code & disassembly below). ``` procedure TfraNewRTMDisplay.ShowMeasurement; var iDummy, iDummy2, iDummy3:integer; begin // STACK OVERFLOW BEFORE MY CODE STARTS iDummy:=0; iDummy2:=0; ...
Yuliy is right: The 320KB buffer is likely an array[20] of whatever is returned by ChannelMeasSet - based on the size of the rep movsd loop. It looks like you've got some code that is returning a very large data structure by value, rather than just a reference to it. Apart from the stack overflow issue, that's likely ...
387,451
<p>I have a C# public API that is used by many third-party developers that have written custom applications on top of it. In addition, the API is used widely by internal developers.</p> <p>This API wasn't written with testability in mind: most class methods aren't virtual and things weren't factored out into interface...
[ { "answer_id": 387472, "author": "Patrik Hägne", "author_id": 46187, "author_profile": "https://Stackoverflow.com/users/46187", "pm_score": 0, "selected": false, "text": "<p>One approach you don't mention (and the one I'd prefer in most cases) is to extract interfaces for the classes you...
2008/12/22
[ "https://Stackoverflow.com/questions/387451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1869/" ]
I have a C# public API that is used by many third-party developers that have written custom applications on top of it. In addition, the API is used widely by internal developers. This API wasn't written with testability in mind: most class methods aren't virtual and things weren't factored out into interfaces. In addi...
What you're really asking is, "How do I design my API with SOLID and similar principles in mind so my API plays well with others?" It's not just about testability. If your customers are having problems testing their code with yours, then they're also having problems WRITING/USING their code with yours, so this is a big...
387,466
<p>I've got a submission page in php with an html form that points back to the same page. I'd like to be able to check if the required fields in the form aren't filled so I can inform the user. I'd like to know how to do that with php and javascript each. However, I imagine this is a common issue so any other answers a...
[ { "answer_id": 387490, "author": "Riho", "author_id": 44715, "author_profile": "https://Stackoverflow.com/users/44715", "pm_score": 3, "selected": true, "text": "<p>Do the check in posting part of your php </p>\n\n<pre><code> if(isset($_POST['save']))\n {\n $fields=array...
2008/12/22
[ "https://Stackoverflow.com/questions/387466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25680/" ]
I've got a submission page in php with an html form that points back to the same page. I'd like to be able to check if the required fields in the form aren't filled so I can inform the user. I'd like to know how to do that with php and javascript each. However, I imagine this is a common issue so any other answers are ...
Do the check in posting part of your php ``` if(isset($_POST['save'])) { $fields=array(); $fields['Nimi'] = $_POST['name']; $fields['Kool'] = $_POST['school']; $fields['Aadress'] = $_POST['address']; $fields['Telefon'] = $_POST['phone']; ...
387,469
<p>Is JSF being used in the enterprise, or at least growing in use?</p>
[ { "answer_id": 387490, "author": "Riho", "author_id": 44715, "author_profile": "https://Stackoverflow.com/users/44715", "pm_score": 3, "selected": true, "text": "<p>Do the check in posting part of your php </p>\n\n<pre><code> if(isset($_POST['save']))\n {\n $fields=array...
2008/12/22
[ "https://Stackoverflow.com/questions/387469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13143/" ]
Is JSF being used in the enterprise, or at least growing in use?
Do the check in posting part of your php ``` if(isset($_POST['save'])) { $fields=array(); $fields['Nimi'] = $_POST['name']; $fields['Kool'] = $_POST['school']; $fields['Aadress'] = $_POST['address']; $fields['Telefon'] = $_POST['phone']; ...
387,480
<p>What is the best way to hide Tab headers when there is only a single visible Tab?</p> <p>I want to hide TabControl chrome completely, while leaving the content of the Tab visible.</p>
[ { "answer_id": 387565, "author": "Robert Macnee", "author_id": 19273, "author_profile": "https://Stackoverflow.com/users/19273", "pm_score": 7, "selected": true, "text": "<p>You can use a Style applied to TabItem with a DataTrigger that will collapse it if the parent TabControl has only ...
2008/12/22
[ "https://Stackoverflow.com/questions/387480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39068/" ]
What is the best way to hide Tab headers when there is only a single visible Tab? I want to hide TabControl chrome completely, while leaving the content of the Tab visible.
You can use a Style applied to TabItem with a DataTrigger that will collapse it if the parent TabControl has only one item: ``` <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> ...
387,485
<p>I have a sidebar on my webpage that is supposed to span 100% of the page (vertically). It is then supposed to stay there, so when the rest of the content scrolls it does not. To do this, I used:</p> <pre><code>body { height: 100%; } #sidebar { height: 100%; width: 120px; position: fixed; top: 0...
[ { "answer_id": 387503, "author": "Jim Blizard", "author_id": 36924, "author_profile": "https://Stackoverflow.com/users/36924", "pm_score": 6, "selected": true, "text": "<p>I would be very concerned about putting the load of sending e-mails on my database server (small though it may be). ...
2008/12/22
[ "https://Stackoverflow.com/questions/387485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a sidebar on my webpage that is supposed to span 100% of the page (vertically). It is then supposed to stay there, so when the rest of the content scrolls it does not. To do this, I used: ``` body { height: 100%; } #sidebar { height: 100%; width: 120px; position: fixed; top: 0; left: 0;...
I would be very concerned about putting the load of sending e-mails on my database server (small though it may be). I might suggest one of these alternatives: 1. Have application logic detect the need to send an e-mail and send it. 2. Have a MySQL trigger populate a table that queues up the e-mails to be sent and have...
387,488
<p>I am setting a cookie <code>Request.Cookies("TemplateName").value</code> on one of my pages(page 3) of my application. Now I can navigate from page 3 to page 4 and page 2 and retain the value of the cookie. But now when I logout and login again it still has the value, how can I reset the value of the cookie to be bl...
[ { "answer_id": 387522, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 4, "selected": true, "text": "<p>You need to use the Response not the Request</p>\n\n<pre><code>Response.Cookies[\"TemplateName\"].Value = \"\";\n\nRespons...
2008/12/22
[ "https://Stackoverflow.com/questions/387488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34219/" ]
I am setting a cookie `Request.Cookies("TemplateName").value` on one of my pages(page 3) of my application. Now I can navigate from page 3 to page 4 and page 2 and retain the value of the cookie. But now when I logout and login again it still has the value, how can I reset the value of the cookie to be blank "" when I ...
You need to use the Response not the Request ``` Response.Cookies["TemplateName"].Value = ""; Response.Cookies["TemplateName"].Expires = DateTime.Now; ``` EDIT For VB. ``` Dim subkeyName As String subkeyName = "userName" Dim aCookie As HttpCookie = Request.Cookies("userInfo") aCookie.Values.Remove(subkeyName) aCoo...
387,492
<p>I am creating a MFC application in which there is a skin library which handles the UI effect of rendering the controls (it gets called in oninitdialog). But, meanwhile, I have also the requirement of displaying an icon on the buttons. For this, I am marking the buttons as ownerdrawn=true, and able to display icon, b...
[ { "answer_id": 387522, "author": "cgreeno", "author_id": 6088, "author_profile": "https://Stackoverflow.com/users/6088", "pm_score": 4, "selected": true, "text": "<p>You need to use the Response not the Request</p>\n\n<pre><code>Response.Cookies[\"TemplateName\"].Value = \"\";\n\nRespons...
2008/12/22
[ "https://Stackoverflow.com/questions/387492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am creating a MFC application in which there is a skin library which handles the UI effect of rendering the controls (it gets called in oninitdialog). But, meanwhile, I have also the requirement of displaying an icon on the buttons. For this, I am marking the buttons as ownerdrawn=true, and able to display icon, but ...
You need to use the Response not the Request ``` Response.Cookies["TemplateName"].Value = ""; Response.Cookies["TemplateName"].Expires = DateTime.Now; ``` EDIT For VB. ``` Dim subkeyName As String subkeyName = "userName" Dim aCookie As HttpCookie = Request.Cookies("userInfo") aCookie.Values.Remove(subkeyName) aCoo...
387,534
<p>I've got some javascript code that applies an alpha transparency. Before it does that it attempts to detect what type of transparency the browser supports and stores that in a variable for use later. Here's what the code looks like:</p> <pre><code>// figure out the browser support for opacity if (typeof br.backImg....
[ { "answer_id": 387552, "author": "annakata", "author_id": 13018, "author_profile": "https://Stackoverflow.com/users/13018", "pm_score": 2, "selected": false, "text": "<p>What you understand as filters is called opacity. Real filters are a proprietary IE extension which enables opacity am...
2008/12/22
[ "https://Stackoverflow.com/questions/387534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48413/" ]
I've got some javascript code that applies an alpha transparency. Before it does that it attempts to detect what type of transparency the browser supports and stores that in a variable for use later. Here's what the code looks like: ``` // figure out the browser support for opacity if (typeof br.backImg.style.opacity ...
In IE7 it is filter**s** and in IE6 it is filter. The code below returns: * 'opacity' if style.opacity is supported * 'filter' for MS filter ( IE < 7 ) * 'filters' for MS filters ( IE7 ) * 'none' for everything else . ``` var opacityType=( (typeof o.style.opacity !== 'undefined') ? 'opacity' : /*@cc_on @if (@_j...
387,536
<p>I've been programming in Ruby for a few months now, and I'm wondering when it is appropriate to use constants over class variables and vice versa. (I'm working in Rails, thinking about constants in models).</p> <pre><code>class Category TYPES = %w(listing event business).freeze end </code></pre> <p>OR</p> <pre>...
[ { "answer_id": 387586, "author": "Charlie Martin", "author_id": 35092, "author_profile": "https://Stackoverflow.com/users/35092", "pm_score": 7, "selected": true, "text": "<p>The main thing is that by using the CONSTANT notation, you're making it clear to the reader. the lower case, fro...
2008/12/22
[ "https://Stackoverflow.com/questions/387536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6705/" ]
I've been programming in Ruby for a few months now, and I'm wondering when it is appropriate to use constants over class variables and vice versa. (I'm working in Rails, thinking about constants in models). ``` class Category TYPES = %w(listing event business).freeze end ``` OR ``` class Category @@types = %w(l...
The main thing is that by using the CONSTANT notation, you're making it clear to the reader. the lower case, frozen string gives the impression is *might* be settable, forcing someone to go back and read the RDoc.
387,547
<p>I ran into this today when unit testing a generic dictionary.</p> <pre><code>System.Collections.Generic.Dictionary&lt;int, string&gt; actual, expected; actual = new System.Collections.Generic.Dictionary&lt;int, string&gt; { { 1, "foo" }, { 2, "bar" } }; expected = new System.Collections.Generic.Dictionary&lt;int, s...
[ { "answer_id": 387561, "author": "Mike Scott", "author_id": 43649, "author_profile": "https://Stackoverflow.com/users/43649", "pm_score": 2, "selected": false, "text": "<p><code>Dictionary&lt;T,T&gt;.Equals</code> is inherited from Object.Equals and thus does a simple comparison of the o...
2008/12/22
[ "https://Stackoverflow.com/questions/387547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2637/" ]
I ran into this today when unit testing a generic dictionary. ``` System.Collections.Generic.Dictionary<int, string> actual, expected; actual = new System.Collections.Generic.Dictionary<int, string> { { 1, "foo" }, { 2, "bar" } }; expected = new System.Collections.Generic.Dictionary<int, string> { { 1, "foo" }, { 2, "...
> > In other words, why is there no baked-in way to do value equality for generic collections? > > > Probably because it's hard to formulate in generic terms, since this would only be possible if the value type (and key type) of the dictionary also implemented `IEquatable`. However, requiring this would be too str...
387,589
<p>Is there a method built in to NSString that tokenizes the string and searches the beginning of each token? the <code>compare</code> method seems to only do the beginning of a string, and using <code>rangeOfString</code> isn't really sufficient because it doesn't have knowledge of tokens. Right now I'm thinking the...
[ { "answer_id": 387604, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": true, "text": "<p>Using <a href=\"http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringTokenizerRef/Reference/reference.h...
2008/12/22
[ "https://Stackoverflow.com/questions/387589", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44858/" ]
Is there a method built in to NSString that tokenizes the string and searches the beginning of each token? the `compare` method seems to only do the beginning of a string, and using `rangeOfString` isn't really sufficient because it doesn't have knowledge of tokens. Right now I'm thinking the best way to do this is to ...
Using [CFStringTokenizer](http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringTokenizerRef/Reference/reference.html) for, um, tokenizing strings will be more robust than splitting on `@" "`, but searching the results is still left up to you.
387,592
<p>Hopefully, this will be an easy answer for someone with Javascript time behind them...</p> <p>I have a log file that is being watched by a script that feeds new lines in the log out to any connected browsers. A couple people have commented that what they want to see is more of a 'tail -f' behavior - the latest lin...
[ { "answer_id": 387610, "author": "Russ Bradberry", "author_id": 48450, "author_profile": "https://Stackoverflow.com/users/48450", "pm_score": 0, "selected": false, "text": "<pre><code>obj.scrollTop = obj.scrollHeight;\n</code></pre>\n" }, { "answer_id": 387734, "author": "Adr...
2008/12/22
[ "https://Stackoverflow.com/questions/387592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30997/" ]
Hopefully, this will be an easy answer for someone with Javascript time behind them... I have a log file that is being watched by a script that feeds new lines in the log out to any connected browsers. A couple people have commented that what they want to see is more of a 'tail -f' behavior - the latest lines will alw...
``` x = 0; //horizontal coord y = document.height; //vertical coord window.scroll(x,y); ```
387,594
<p>I am considering releasing one of my class libraries written in C# as open source. Before doing that, I am trying to do some refactoring so that it meets the demands of the general public :)</p> <p>I wonder what would be the best namespace schema to use? Basically, I see the following options:</p> <ul> <li>namespa...
[ { "answer_id": 387602, "author": "David Vidmar", "author_id": 11063, "author_profile": "https://Stackoverflow.com/users/11063", "pm_score": 0, "selected": false, "text": "<p>If it's open source and there will be contributors I would pick <strong>MyTool</strong>.</p>\n" }, { "answ...
2008/12/22
[ "https://Stackoverflow.com/questions/387594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8954/" ]
I am considering releasing one of my class libraries written in C# as open source. Before doing that, I am trying to do some refactoring so that it meets the demands of the general public :) I wonder what would be the best namespace schema to use? Basically, I see the following options: * namespace **MyTool**: This j...
I'd go with something like: ``` namespace OpenSourceProjectCodeName.MajorFunctionalArea ``` For example: ``` namespace VideoWizardMagicThing.Audio namespace VideoWizardMagicThing.Audio.Codecs namespace VideoWizardMagicThing.Video namespace VideoWizardMagicThing.Video.Codecs ``` You don't have to go completely mad...
387,606
<p>I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. </p> <p>I am a bit stuck on how to get started. Does anyone have any tips for me?</p>
[ { "answer_id": 387622, "author": "BradC", "author_id": 21398, "author_profile": "https://Stackoverflow.com/users/21398", "pm_score": 1, "selected": false, "text": "<p>A barcode is simply a graphical representation of a series of characters (alphanumeric)</p>\n\n<p>So if you have a method...
2008/12/22
[ "https://Stackoverflow.com/questions/387606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47204/" ]
I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me?
Use [python-mysql](http://mysql-python.sourceforge.net/MySQLdb.html#using-and-extending). It is a [dbapi-compatible](http://www.python.org/dev/peps/pep-0249/) module that lets you talk to the database. ``` import MySQLdb user_input = raw_input("Please enter barcode and press Enter button: ") db = MySQLdb.connect(pas...
387,623
<p>I have a file with 450,000+ rows of entries. Each entry is about 7 characters in length. What I want to know is the unique characters of this file.</p> <p>For instance, if my file were the following;</p> <blockquote> <pre><code>Entry ----- Yabba Dabba Doo </code></pre> </blockquote> <p>Then the result would be</p...
[ { "answer_id": 387630, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "<p>Use a <code>set</code> data structure. Most programming languages / standard libraries come with one flavour or an...
2008/12/22
[ "https://Stackoverflow.com/questions/387623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a file with 450,000+ rows of entries. Each entry is about 7 characters in length. What I want to know is the unique characters of this file. For instance, if my file were the following; > > > ``` > Entry > ----- > Yabba > Dabba > Doo > > ``` > > Then the result would be > > Unique characters: {abdoy} >...
Here's a **PowerShell** example: ``` gc file.txt | select -Skip 2 | % { $_.ToCharArray() } | sort -CaseSensitive -Unique ``` which produces: > > D > > Y > > a > > b > > o > > > I like that it's easy to read. **EDIT**: Here's a faster version: ``` $letters = @{} ; gc file.txt | select -Skip 2...
387,633
<p>How should exceptions be dispatched so that error handling and diagnostics can be handled in a centralized, user-friendly manner?</p> <p>For example:</p> <ul> <li>A DataHW class handles communication with some data acquisition hardware.</li> <li>The DataHW class may throw exceptions based on a number of possible e...
[ { "answer_id": 387667, "author": "fizzer", "author_id": 18167, "author_profile": "https://Stackoverflow.com/users/18167", "pm_score": 4, "selected": true, "text": "<p>Avoid duplicating the catch blocks at each call site by catching (...) and calling a shared handler function which rethro...
2008/12/22
[ "https://Stackoverflow.com/questions/387633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25507/" ]
How should exceptions be dispatched so that error handling and diagnostics can be handled in a centralized, user-friendly manner? For example: * A DataHW class handles communication with some data acquisition hardware. * The DataHW class may throw exceptions based on a number of possible errors: intermittent signal, ...
Avoid duplicating the catch blocks at each call site by catching (...) and calling a shared handler function which rethrows and dispatches: ``` f() { try { // something } catch (...) { handle(); } } void handle() { try { throw; } catch (const Foo& e) ...
387,636
<p>Let's say I have a table called Product, with three columns: Id, CustomerId, Name. Id is the primary key. The schema is outside of the control of my group, and we now have a requirement to always provide CustomerId as a parameter for all queries (selects, updates, deletes). It's a long story I'd rather not get int...
[ { "answer_id": 388986, "author": "Craig Stuntz", "author_id": 7714, "author_profile": "https://Stackoverflow.com/users/7714", "pm_score": 0, "selected": false, "text": "<p>One way would be to <a href=\"http://msdn.microsoft.com/en-us/library/cc716731.aspx\" rel=\"nofollow noreferrer\">us...
2008/12/22
[ "https://Stackoverflow.com/questions/387636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
Let's say I have a table called Product, with three columns: Id, CustomerId, Name. Id is the primary key. The schema is outside of the control of my group, and we now have a requirement to always provide CustomerId as a parameter for all queries (selects, updates, deletes). It's a long story I'd rather not get into ......
Does the CustomerId help uniquely identify the row past @Id? I didn't really follow the "triggers" bit, since the predicate used for the update is not known by the trigger. Or you do want to re-update the CustomerId each time (detectable from `UPDATE(...)` in the trigger) The easiest option is to do it as object updat...
387,638
<pre><code>print("select CustomerNo, CustomerName, Address, City, State, Zip, Phone, Fax, ContactName, Email from Customers where CustomerName like '%field%'"); </code></pre> <p>Hi all. This is a simple question but I wasn't able to figure since I'm pretty new to tsql and sql in general.</p> <p>I use the ab...
[ { "answer_id": 387643, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 0, "selected": false, "text": "<p>If you use =, you say \"equal\", which won't use wildcards.</p>\n\n<p>If you use LIKE, which only work on text fie...
2008/12/22
[ "https://Stackoverflow.com/questions/387638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
``` print("select CustomerNo, CustomerName, Address, City, State, Zip, Phone, Fax, ContactName, Email from Customers where CustomerName like '%field%'"); ``` Hi all. This is a simple question but I wasn't able to figure since I'm pretty new to tsql and sql in general. I use the above stored procedure to do...
Wildcards are simply part of a string literal, e.g. '%field%' is just a string. You can concatenate the wildcards onto your string and then use the string: ``` @Pattern = '%' + @CustomerName + '%'; ...WHERE CustomerName LIKE @Pattern ``` Or else you can write an expression in the SQL involving concatenation: ``` ...
387,646
<p>Why is the compiler unable to infer the correct type for the result from Collections.emptySet() in the following example?</p> <pre><code>import java.util.*; import java.io.*; public class Test { public interface Option&lt;A&gt; { public &lt;B&gt; B option(B b, F&lt;A,B&gt; f); } public interfa...
[ { "answer_id": 387661, "author": "GaryF", "author_id": 1035, "author_profile": "https://Stackoverflow.com/users/1035", "pm_score": 4, "selected": true, "text": "<p>Java needs a lot of hand holding with its inference. The type system could infer better in a lot of cases but in your case t...
2008/12/22
[ "https://Stackoverflow.com/questions/387646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/390636/" ]
Why is the compiler unable to infer the correct type for the result from Collections.emptySet() in the following example? ``` import java.util.*; import java.io.*; public class Test { public interface Option<A> { public <B> B option(B b, F<A,B> f); } public interface F<A,B> { public B f(A...
Java needs a lot of hand holding with its inference. The type system could infer better in a lot of cases but in your case the following will work: ``` print("Collections.<String>emptySet();"); ```
387,654
<p>In Z80 machine code, a cheap technique to initialize a buffer to a fixed value, say all blanks. So a chunk of code might look something like this.</p> <pre><code>LD HL, DESTINATION ; point to the source LD DE, DESTINATION + 1 ; point to the destination LD BC, DESTINATION_SIZE - 1 ; copying ...
[ { "answer_id": 387671, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 3, "selected": false, "text": "<blockquote>\n <p>Why do memmove and memcpy behave this way?</p>\n</blockquote>\n\n<p>Probably because there’s no sp...
2008/12/22
[ "https://Stackoverflow.com/questions/387654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7734/" ]
In Z80 machine code, a cheap technique to initialize a buffer to a fixed value, say all blanks. So a chunk of code might look something like this. ``` LD HL, DESTINATION ; point to the source LD DE, DESTINATION + 1 ; point to the destination LD BC, DESTINATION_SIZE - 1 ; copying this many bytes ...
I believe this goes to the design philosophy of C and C++. As [Bjarne Stroustrup](http://en.wikipedia.org/wiki/Bjarne_Stroustrup) once [said](http://www.research.att.com/~bs/crc.pdf), one of the major guiding principles of the design of C++ is "What you don’t use, you don’t pay for". And while [Dennis Ritchie](http://e...
387,672
<p>I've just started using NHibernate and fluent-NHibernate which I think is great. I've been configuring all my mappings to use LazyLoading for any relationships between classes because generally I find it isn't neccesary to load everything upfront. However sometimes you know 100% you will be loading all of the relati...
[ { "answer_id": 402907, "author": "John_", "author_id": 26081, "author_profile": "https://Stackoverflow.com/users/26081", "pm_score": 4, "selected": true, "text": "<p>I've found this can be used the LazyLoading / Eager loading feature of NHibernate queries.</p>\n\n<p>Create your ICriteria...
2008/12/22
[ "https://Stackoverflow.com/questions/387672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26081/" ]
I've just started using NHibernate and fluent-NHibernate which I think is great. I've been configuring all my mappings to use LazyLoading for any relationships between classes because generally I find it isn't neccesary to load everything upfront. However sometimes you know 100% you will be loading all of the relations...
I've found this can be used the LazyLoading / Eager loading feature of NHibernate queries. Create your ICriteria in the normal manner and then the association name (relationship property, for me is prices) and then the fetch type which can be join, select, lazyload, eager ``` .SetFetchMode("Prices", FetchMode.Join) ...
387,686
<ul> <li>I have a <em>Client</em> and <em>Groupe</em> Model.</li> <li>A <em>Client</em> can be part of multiple <em>groups</em>.</li> <li><em>Clients</em> that are part of a group can use its group's free rental rate at anytime but only once. That is where the intermediary model (<em>ClientGroupe</em>) comes in with th...
[ { "answer_id": 478384, "author": "Vladimir Prudnikov", "author_id": 29364, "author_profile": "https://Stackoverflow.com/users/29364", "pm_score": 0, "selected": false, "text": "<p>When you save your form, you save Client object. Now if you want to assign client to the group you should do...
2008/12/22
[ "https://Stackoverflow.com/questions/387686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/48500/" ]
* I have a *Client* and *Groupe* Model. * A *Client* can be part of multiple *groups*. * *Clients* that are part of a group can use its group's free rental rate at anytime but only once. That is where the intermediary model (*ClientGroupe*) comes in with that extra data. For now, when I try to save the m2m data, it ju...
``` … if form.is_valid(): client_mod = form.save(commit=False) client_mod.save() for groupe in form.cleaned_data.get('groupes'): clientgroupe = ClientGroupe(client=client_mod, groupe=groupe) clientgroupe.save() … ```
387,702
<p>Here's a scenario. You have a large amount of legacy scripts, all using a common library. Said scripts use the 'print' statement for diagnostic output. No changes are allowed to the scripts - they range far and wide, have their approvals, and have long since left the fruitful valleys of oversight and control.</p>...
[ { "answer_id": 387767, "author": "codelogic", "author_id": 43427, "author_profile": "https://Stackoverflow.com/users/43427", "pm_score": 3, "selected": false, "text": "<p>You can use Perl's <a href=\"http://perldoc.perl.org/functions/select.html\" rel=\"noreferrer\">select</a> to redirec...
2008/12/22
[ "https://Stackoverflow.com/questions/387702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18097/" ]
Here's a scenario. You have a large amount of legacy scripts, all using a common library. Said scripts use the 'print' statement for diagnostic output. No changes are allowed to the scripts - they range far and wide, have their approvals, and have long since left the fruitful valleys of oversight and control. Now a ne...
There are a number of built-ins that you can override (see [perlsub](http://perldoc.perl.org/perlsub.html#Overriding-Built-in-Functions)). However, `print` is one of the built-ins that doesn't work this way. The difficulties of overriding `print` are detailed at this [perlmonk's thread](http://www.perlmonks.org/?node=!...
387,707
<p>I prefer to use OOP in large scale projects like the one I'm working on right now. I need to create several classes in JavaScript but, if I'm not mistaken, there are at least a couple of ways to go about doing that. What would be the syntax and why would it be done in that way?</p> <p>I would like to avoid using th...
[ { "answer_id": 387733, "author": "Kenan Banks", "author_id": 43089, "author_profile": "https://Stackoverflow.com/users/43089", "pm_score": 11, "selected": true, "text": "<p>Here's the way to do it without using any external libraries:</p>\n\n<pre><code>// Define a class like this\nfuncti...
2008/12/22
[ "https://Stackoverflow.com/questions/387707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2494/" ]
I prefer to use OOP in large scale projects like the one I'm working on right now. I need to create several classes in JavaScript but, if I'm not mistaken, there are at least a couple of ways to go about doing that. What would be the syntax and why would it be done in that way? I would like to avoid using third-party ...
Here's the way to do it without using any external libraries: ``` // Define a class like this function Person(name, gender){ // Add object properties like this this.name = name; this.gender = gender; } // Add methods like this. All Person objects will be able to invoke this Person.prototype.speak = functio...
387,736
<p>Consider the following:</p> <pre><code>&lt;div onclick="alert('you clicked the header')" class="header"&gt; &lt;span onclick="alert('you clicked inside the header');"&gt;something inside the header&lt;/span&gt; &lt;/div&gt; </code></pre> <p>How can I make it so that when the user clicks the span, it does not fir...
[ { "answer_id": 387750, "author": "James", "author_id": 21677, "author_profile": "https://Stackoverflow.com/users/21677", "pm_score": 9, "selected": true, "text": "<p>Use <a href=\"https://developer.mozilla.org/en/DOM/event.stopPropagation\" rel=\"noreferrer\">event.stopPropagation()</a>....
2008/12/22
[ "https://Stackoverflow.com/questions/387736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43005/" ]
Consider the following: ``` <div onclick="alert('you clicked the header')" class="header"> <span onclick="alert('you clicked inside the header');">something inside the header</span> </div> ``` How can I make it so that when the user clicks the span, it does not fire the `div`'s click event?
Use [event.stopPropagation()](https://developer.mozilla.org/en/DOM/event.stopPropagation). ``` <span onclick="event.stopPropagation(); alert('you clicked inside the header');">something inside the header</span> ``` For IE: `window.event.cancelBubble = true` ``` <span onclick="window.event.cancelBubble = true; alert...
387,772
<p>I can't find the answer to this anywhere, and before I start pawing through generated code with Reflector I thought it'd be worth asking:</p> <p>Suppose I have the following LINQ query run against DataTables in a DataSet:</p> <pre><code>var list = from pr in parentTable.AsEnumerable() join cr in childTable....
[ { "answer_id": 388020, "author": "Andrew Theken", "author_id": 32238, "author_profile": "https://Stackoverflow.com/users/32238", "pm_score": 1, "selected": false, "text": "<p>This is an explaination:\n<a href=\"http://msdn.microsoft.com/en-us/library/bb386969.aspx\" rel=\"nofollow norefe...
2008/12/22
[ "https://Stackoverflow.com/questions/387772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19403/" ]
I can't find the answer to this anywhere, and before I start pawing through generated code with Reflector I thought it'd be worth asking: Suppose I have the following LINQ query run against DataTables in a DataSet: ``` var list = from pr in parentTable.AsEnumerable() join cr in childTable.AsEnumerable() on cr....
I don't think so. In this case, LINQ to Objects will probably just treat the two sides as regular enumerable objects, and do the join manually (without looking at the `DataRelation`).
387,775
<p>Why doesn't the following work?</p> <pre><code>(apply and (list #t #t #f)) </code></pre> <p>While the following works just fine.</p> <pre><code>(apply + (list 1 3 2)) </code></pre> <p>This seems to be the case in both R5RS and R6RS?</p>
[ { "answer_id": 387805, "author": "Paige Ruten", "author_id": 813, "author_profile": "https://Stackoverflow.com/users/813", "pm_score": 5, "selected": true, "text": "<p><code>and</code> isn't a normal function because it will only evaluate as few arguments as it needs, to know whether the...
2008/12/22
[ "https://Stackoverflow.com/questions/387775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1925263/" ]
Why doesn't the following work? ``` (apply and (list #t #t #f)) ``` While the following works just fine. ``` (apply + (list 1 3 2)) ``` This seems to be the case in both R5RS and R6RS?
`and` isn't a normal function because it will only evaluate as few arguments as it needs, to know whether the result is true or false. For example, if the first argument is false, then no matter what the other arguments are, the result has to be false so it won't evaluate the other arguments. If `and` were a normal fun...
387,783
<p>I'm trying to get my head around DI/IoC, NHibernate and getting them to work nicely together for an application that i'm developing. I'm quite new to both NHibernate and DI/IoC so not quite sure whether what i'm doing is the sensible way to be going about it. This is the scenario:</p> <p>The application provides u...
[ { "answer_id": 387914, "author": "plaureano", "author_id": 46265, "author_profile": "https://Stackoverflow.com/users/46265", "pm_score": 1, "selected": false, "text": "<p>A) If you're going to access the MarginCalculator through the Product domain object, you might as well cut out the mi...
2008/12/22
[ "https://Stackoverflow.com/questions/387783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to get my head around DI/IoC, NHibernate and getting them to work nicely together for an application that i'm developing. I'm quite new to both NHibernate and DI/IoC so not quite sure whether what i'm doing is the sensible way to be going about it. This is the scenario: The application provides users with t...
A) If you're going to access the MarginCalculator through the Product domain object, you might as well cut out the middle man and let the DI/IOC container inject the MarginCalculator for you. You can even get rid of the MarginCalculatorAssembler because most DI/IOC containers do most of the boilerplate code of object c...
387,792
<p>Does anyone have or know about vim plugin/macro/function that indents nicely c++ templates?</p> <p>When I highlight template definition in vim .hpp/.h file and indent it with '=' I get something like this:</p> <pre><code>&gt; template &lt; &gt; class TFilter, &gt; class TParser, &gt; ...
[ { "answer_id": 388068, "author": "Judge Maygarden", "author_id": 1491, "author_profile": "https://Stackoverflow.com/users/1491", "pm_score": 3, "selected": true, "text": "<p>You can use the <a href=\"http://vimdoc.sourceforge.net/htmldoc/options.html#%27indentexpr%27\" rel=\"nofollow nor...
2008/12/22
[ "https://Stackoverflow.com/questions/387792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45654/" ]
Does anyone have or know about vim plugin/macro/function that indents nicely c++ templates? When I highlight template definition in vim .hpp/.h file and indent it with '=' I get something like this: ``` > template < > class TFilter, > class TParser, > class TConsumer, > ...
You can use the [identexpr](http://vimdoc.sourceforge.net/htmldoc/options.html#%27indentexpr%27) option to specify indent by evaluating an [expression](http://vimdoc.sourceforge.net/htmldoc/indent.html#indent-expression) (i.e. writing a vim script function). This function should accept a string -- the line -- and retur...
387,806
<p>I would like to map a many-to-many in Hibernate using a link table. I have two classes, Parent and Child class, for example:</p> <pre><code>public class Parent{ private List&lt;Child&gt; _children; //...getters and setters } </code></pre> <p>I use a link table (link_table) with three columns <code>link_id</code>...
[ { "answer_id": 387863, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 0, "selected": false, "text": "<p>I am not sure that you can pull this off easily for an existing database with existing data. Hibernate is usually better of...
2008/12/22
[ "https://Stackoverflow.com/questions/387806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23133/" ]
I would like to map a many-to-many in Hibernate using a link table. I have two classes, Parent and Child class, for example: ``` public class Parent{ private List<Child> _children; //...getters and setters } ``` I use a link table (link\_table) with three columns `link_id`, `parent_id`, and `child_id`. The databas...
I don't think that it is possible (or necessary) to add a link\_id primary key to the join table. The join table will usually consist of the primary keys of the two participating tables. Using XML you will need syntax like this: ``` <class name="Parent"> .... <list name="children" table="link_table"> <ke...