qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
246,438 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/358874/how-can-i-use-a-carriage-return-in-a-html-tooltip">How can I use a carriage return in a HTML tooltip?</a> </p>
</blockquote>
<p>I'd like to know if it's possible to force a newline to show in the tooltip when using title property of a TD.
something like </p>
<pre><code><td title="lineone \n linetwo \n etc...">
</code></pre>
<p>Can this be done?</p>
| [
{
"answer_id": 246439,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 2,
"selected": false,
"text": "<td title=\"lineone\nlinetwo \netc...\">\n"
},
{
"answer_id": 246451,
"author": "RealHowTo",
"author_id": 2512... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15616/"
] |
246,440 | <p>I want to draw spinner controls, such as those found on a NumericUpDown, on a custom component. If I want to draw a drop-down button, I can use ComboBoxRenderer. Is there an equivalent of ComboBoxRenderer for NumericUpDown?</p>
| [
{
"answer_id": 259078,
"author": "Alan",
"author_id": 31223,
"author_profile": "https://Stackoverflow.com/users/31223",
"pm_score": 0,
"selected": false,
"text": "[DllImport(\"uxtheme.dll\", ExactSpelling = true, CharSet = CharSet.Unicode)]\npublic static extern IntPtr OpenThemeData(IntP... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
246,443 | <p>I am experiencing some strange behavior of embedded audio (wav file) on HTML page.
I've got a page <code>https://server.com/listen-to-sound</code>, and a Wav file embedded in it via <code><EMBED/></code> tag, like this:</p>
<pre><code><embed src='https://server.com/path-to-sound' hidden="true" autostart="true" />
</code></pre>
<p>The page <code>https://server.com/listen-to-sound</code> is opened in IE 6 SP3 on machine#1 - the sound is played in the headphones.
The same page is opened on another machine(#2), with <strong>exactly</strong> same IE 6 SP3 version, privacy and proxy settings - there's no sound.</p>
<p>Totally, from 6 machines the sound is played on 2 and not played on 4. From these 4 machines, when the page <code>https://server.com/listen-to-sound</code> is opened in Opera, the sound is played.</p>
<p>I've triple-checked headphone connections, volume settings and other possible hardware and software driver issues: the problem is definitely in IE settings.</p>
<p>I've also checked <code>https://server.com/path.to.sound</code> URL - the 4 machnies that do not play sound fail to open this link, failing with an error like "Failed to download page".</p>
<p>Cleaning IE caches, temporary internet files, SSL certificate caches did not solve the problem either.</p>
<p>Googling gave me nothing special but old Flash trick to use <code><OBJECT></code> tag and <code><EMBED></code> tag to be written in Object's comments.</p>
<p>What have I missed? Have you experienced similar or related problems? How were they solved?
Do you have any suggestions on where the trick is? Do you know some IE "features" that might affect execution(playing, showing) of embedded objects?</p>
| [
{
"answer_id": 246729,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "<NOEMBED>"
},
{
"answer_id": 821112,
"author": "Travis",
"author_id": 307338,
"author_profile": "https:... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17707/"
] |
246,445 | <p>I have a <code>char* p</code>, which points to a <code>\0</code>-terminated string. How do I create a C++ <code>string</code> from it in an exception-safe way?</p>
<p>Here is an unsafe version:</p>
<pre><code>string foo()
{
char *p = get_string();
string str( p );
free( p );
return str;
}
</code></pre>
<p>An obvious solution would be to try-catch - any easier ways? </p>
| [
{
"answer_id": 246457,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 6,
"selected": true,
"text": "shared_ptr"
},
{
"answer_id": 246460,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https:... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23420/"
] |
246,498 | <p>I'm trying to create a unit test to test the case for when the timezone changes on a machine because it has been incorrectly set and then corrected.</p>
<p>In the test I need to be able to create DateTime objects in a none local time zone to ensure that people running the test can do so successfully irrespective of where they are located.</p>
<p>From what I can see from the DateTime constructor I can set the TimeZone to be either the local timezone, the UTC timezone or not specified.</p>
<p>How do I create a DateTime with a specific timezone like PST?</p>
| [
{
"answer_id": 246529,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 9,
"selected": true,
"text": "public struct DateTimeWithZone\n{\n private readonly DateTime utcDateTime;\n private readonly TimeZoneInfo timeZone... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42109/"
] |
246,503 | <p>OK, I am trying to generate the rDoc for paperclip, but the rake task is choking on another plugin before it gets to it, so this is out of the question:</p>
<pre><code>rake doc:plugins
</code></pre>
<p>I could go and fix up the broken plugin, but I'm busy and lazy, so I just want to generate the docs for paperclip. Is there any way of doing this?</p>
| [
{
"answer_id": 246507,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 4,
"selected": true,
"text": "rake doc:plugins:paperclip\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] |
246,518 | <p>I used the owner-drawn strategy on CMyListBox class which derives from CListBox. I only want the DrawItem() method to perform when I insert an item in the listbox. But the method is invoked many times. How can I change to invoke it whenever I need.</p>
| [
{
"answer_id": 246543,
"author": "SmacL",
"author_id": 22564,
"author_profile": "https://Stackoverflow.com/users/22564",
"pm_score": 0,
"selected": false,
"text": "void CMyListBox::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )\n{\n if (!m_DrawingEnabled)\n return;\n}\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26404/"
] |
246,520 | <p>I'm writing a web application which uses windows authentication and I can happily get the user's login name using something like:</p>
<pre><code> string login = User.Identity.Name.ToString();
</code></pre>
<p>But I don't need their login name I want their DisplayName. I've been banging my head for a couple hours now...</p>
<p>Can I access my organisation's AD via a web application?</p>
| [
{
"answer_id": 246655,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": false,
"text": "GetUserProperty(\"<myaccount>\", \"DisplayName\");\n\npublic static string GetUserProperty(string accountName, string property... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31765/"
] |
246,525 | <p>I'm using Python's Imaging Library and I would like to draw some bezier curves.
I guess I could calculate pixel by pixel but I'm hoping there is something simpler.</p>
| [
{
"answer_id": 246628,
"author": "Jasper Bekkers",
"author_id": 31486,
"author_profile": "https://Stackoverflow.com/users/31486",
"pm_score": 5,
"selected": true,
"text": "A"
},
{
"answer_id": 246933,
"author": "Toni Ruža",
"author_id": 6267,
"author_profile": "https:... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] |
246,540 | <p>This error has been driving me nuts. We have a server running Apache and Tomcat, serving multiple different sites. Normally the server runs fine, but sometimes an error happens where people are served the wrong page - <strong>the page that <em>somebody else</em> requested!</strong></p>
<p>Clues:</p>
<ul>
<li>The pages being delivered are those that another user requested recently, and are otherwise delivered correctly. It's been known for two simultaneous requests to be swapped. As far as I can tell, none of the pages being incorrectly delivered are older than a few minutes.</li>
<li>It only affects the files that are being served by Tomcat. Static files like images are unaffected.</li>
<li>It doesn't happen all the time. When it does happen, it happens for everybody.</li>
<li>It seems to happen at times of peak demand. However, the demand is not yet very high - it's certainly well within the bounds of what Apache can cope with.</li>
<li>Restarting Tomcat fixed it, but only for a few minutes. Restarting Apache fixed it, but only for a few minutes.</li>
<li>The server is running Apache 2 and Tomcat 6, using a Java 6 VM on Gentoo. The connection is with AJP13, and <code>JkMount</code> directives within <code><VirtualHost></code> blocks are correct.</li>
<li>There's nothing of use in any of the log files.</li>
</ul>
<hr>
<p><strong>Further information:</strong></p>
<p>Apache does not have any form of caching turned on. All the caching-related entries in httpd.conf and related imports say, for example:</p>
<pre><code><IfDefine CACHE>
LoadModule cache_module modules/mod_cache.so
</IfDefine>
</code></pre>
<p>While the options for Apache don't include that flag:</p>
<pre><code>APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D JK"
</code></pre>
<p>Tomcat likewise has no caching options switched on, that I can find.</p>
<p><a href="https://stackoverflow.com/questions/246540/apachetomcat-error-wrong-pages-being-delivered#246566">toolkit's suggestion</a> was good, but not appropriate in this case. What leads me to believe that the error can't be within my own code is that it isn't simply a few values that are being transferred - it's the entire request, including the URL, parameters, session cookies, the whole thing. People are getting pages back saying "You are logged in as John", when they clearly aren't.</p>
<hr>
<p><strong>Update:</strong></p>
<p>Based on suggestions from several people, I'm going to add the following HTTP headers to Tomcat-served pages to disable all forms of caching:</p>
<pre><code>Cache-Control: no-store
Vary: *
</code></pre>
<p>Hopefully these headers will be respected not just by Apache, but also by any other caches or proxies that may be in the way. Unfortunately I have no way of deliberately reproducing this error, so I'm just going to have to wait and see if it turns up again.</p>
<p>I notice that the following headers are being included - could they be related in any way?</p>
<pre><code>Connection: Keep-Alive
Keep-Alive: timeout=5, max=66
</code></pre>
<hr>
<p><strong>Update:</strong></p>
<p>Apparently this happened again while I was asleep, but has stopped happening now I'm awake to see it. Again, there's nothing useful in the logs that I can see, so I have no clues to what was actually happening or how to prevent it.</p>
<p>Is there any extra information I can put in Apache or Tomcat's logs to make this easier to diagnose?</p>
<hr>
<p><strong>Update:</strong></p>
<p>Since this has happened again a couple of times, we've changed how Apache connects to Tomcat to see if it affects things. We were using <code>mod_jk</code> with a directive like this:</p>
<pre><code>JkMount /portal ajp13
</code></pre>
<p>We've switched now to using <code>mod_proxy_ajp</code>, like so:</p>
<pre><code>ProxyPass /portal ajp://localhost:8009/portal
</code></pre>
<p>We'll see if it makes any difference. This error was always annoyingly unpredictable, so we can never definitively say if it's worked or not.</p>
<hr>
<p><strong>Update:</strong></p>
<p>We just got the error briefly on a site that was left using <code>mod_jk</code>, while a sister site on the same server using <code>mod_proxy_ajp</code> didn't show the error. This doesn't prove anything, but it does provide evidence that swithing to <code>mod_proxy_ajp</code> may have helped.</p>
<hr>
<p><strong>Update:</strong></p>
<p>We just got the error again last night on a site using <code>mod_proxy_ajp</code>, so clearly that hasn't solved it - <code>mod_jk</code> wasn't the source of the problem. I'm going to try the anonymous suggestion of turning off persistent connections:</p>
<pre><code>KeepAlive Off
</code></pre>
<p>If that fails as well, I'm going to be desperate enough to start investigating GlassFish.</p>
<hr>
<p><strong>Update:</strong></p>
<p>Dammit! The problem just came back. I hadn't seen it in a while, so I was starting to think we'd finally sorted it. I hate heisenbugs.</p>
| [
{
"answer_id": 246566,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 3,
"selected": false,
"text": "public class MyServlet ... {\n private String action;\n\n public void doGet(...) {\n action = request.getParam... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1000/"
] |
246,542 | <p>There was no endpoint listening at http;//localhost:8080/xdxservice/xdsrepository that could accept the message. This is often caused by an incorrect address or SOAP action. </p>
| [
{
"answer_id": 246625,
"author": "ZombieSheep",
"author_id": 377,
"author_profile": "https://Stackoverflow.com/users/377",
"pm_score": 1,
"selected": false,
"text": "http;//localhost:8080/xdxservice/xdsrepository\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,559 | <p>I need to copy a set of DLL and PDB files from a set of folders recursively into another folder. I don't want to recreate the folder hierarchy in the target folder.
I want to use built in Windows tools, e.g. DOS commands. </p>
| [
{
"answer_id": 246576,
"author": "Alexander Prokofyev",
"author_id": 11256,
"author_profile": "https://Stackoverflow.com/users/11256",
"pm_score": 8,
"selected": true,
"text": "mkdir targetDir\nfor /r %x in (*.dll, *pdb) do copy \"%x\" targetDir\\\n"
},
{
"answer_id": 5632706,
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32333/"
] |
246,564 | <p>If a variable is declared as <code>static</code> in a function's scope it is only initialized once and retains its value between function calls. What exactly is its lifetime? When do its constructor and destructor get called?</p>
<pre><code>void foo()
{
static string plonk = "When will I die?";
}
</code></pre>
| [
{
"answer_id": 246568,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 9,
"selected": true,
"text": "static"
},
{
"answer_id": 246594,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackove... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] |
246,577 | <p>I am writing an RSS feed (for fun) and was looking at the spec <a href="http://cyber.law.harvard.edu/rss/rss.html" rel="noreferrer">here</a>.</p>
<blockquote>
<p>RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.</p>
</blockquote>
<p>Obviously this means that I am not serving 'pure' RSS if I choose the JSON option. That said, if I conform to the rest of the spec, is it likely that (customised) readers will be able to parse it?</p>
<p>To put it another way, if I conform to the spec, but using JSON instead of XML is it a usable RSS feed?</p>
<p><em>edit</em>
I am not sure I made myself clear.
There is no XML involved. I want to write something akin to RSS (which is XML) using JSON instead. Obviously the readers of such a feed would need to be written to understand the JSON format.
I was wondering if this had been done already. Are there services that serve a feed this way? Are there programs that can aggregate/understand this format. Is the RSS spec (sans the XML part) a useful spec to conform to in this case?</p>
<p>rg </p>
<pre><code>{
"title":"example.com",
"link":"http://www.example.com/",
"description":"Awesome news about junk",
"items":[
{
"title":"An article",
"link":"http://www.example.com/an-article",
"descrition":"Some sample text here",
"pubDate":"2008-10-27 11:06 EST",
"author":"example author",
},
{
"title":"Second",
"link":"http://www.example.com/Seond",
"descrition":"Some sample text here",
"pubDate":"2008-10-25 23:20 EST",
"author":"author mcauthor",
},
{
"title":"third article",
"link":"http://www.example.com/third-article",
"descrition":"Some sample text here",
"pubDate":"2008-10-25 23:18 EST",
"author":"some other author",
}
]
}
</code></pre>
| [
{
"answer_id": 251764,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 4,
"selected": false,
"text": "jQuery.getFeed(options);\n"
},
{
"answer_id": 251780,
"author": "James Newton-King",
"author_id": 1182... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3431280/"
] |
246,623 | <p>I want do something like this:</p>
<pre><code>Result = 'MyString' in [string1, string2, string3, string4];
</code></pre>
<p>This can't be used with strings and I don't want to do something like this:</p>
<pre><code>Result = (('MyString' = string1) or ('MyString' = string2));
</code></pre>
<p>Also I think that creating a StringList to do just this is too complex.</p>
<p>Is there some other way to achieve this?</p>
<p>Thanks.</p>
| [
{
"answer_id": 246660,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 2,
"selected": false,
"text": "function StringInArray(Value: string; Strings: array of string): Boolean;\nvar I: Integer;\nbegin\n Result := False;\n ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] |
246,636 | <p>My WCF Service uses wsHttpBinding and works fine from the client when the service is gerenated by the client using the default options as follows:</p>
<pre><code>RServiceClient R = new RServiceClient();
</code></pre>
<p>However, at some point I'll need to be able to specify the location of the service, presumably by changing the endpoint address as follows:</p>
<pre><code>RServiceClient R = new RServiceClient();
R.Endpoint.Address = new EndpointAddress(new Uri "http://xxx.xxxx.xxx:80/RServer/RService.svc"));
</code></pre>
<p>However, when I do specify the exact endpoint, I get a SecurityNegotiationException:
System.ServiceModel.Security.SecurityNegotiationException was unhandled
Message="The caller was not authenticated by the service."
Source="mscorlib"....</p>
<p>The WCF service runs on IIS and has anonymous access enabled under IIS admin. Also, this error occurs when the client is run from the same machine as the service under an admin account - I havn't got to the scary part of running it over the net yet!</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 246694,
"author": "Calanus",
"author_id": 445,
"author_profile": "https://Stackoverflow.com/users/445",
"pm_score": 0,
"selected": false,
"text": "<system.serviceModel>\n <services>\n <service behaviorConfiguration=\"ServiceBehavior\" name=\"RService\">\n<endpoint addr... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246636",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445/"
] |
246,644 | <p>Here is a simplified version of my database model. I have two tables: "Image", and "HostingProvider" which look like this:</p>
<p><strong>[Image]</strong></p>
<ul>
<li>id</li>
<li>filename</li>
<li>hostingprovider_id</li>
</ul>
<p><strong>[HostingProvider]</strong></p>
<ul>
<li>id</li>
<li>base_url</li>
</ul>
<p>Image HostingproviderId is a many-to-one foreign key relationship to the HostingProvider table. (Each image has one hosting provider). </p>
<p>Essentially I want to be able to have my Image class look like this:</p>
<p><strong>[Image]</strong></p>
<ul>
<li>Id</li>
<li>base_url</li>
<li>filename</li>
</ul>
<p>In NHibernate, how can I create a mapping file that will combine the base_url from the HostingProvider table, into the Image class?</p>
| [
{
"answer_id": 246769,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 0,
"selected": false,
"text": "public class Image {\n public virtual HostingProvider HostingProvider { get; set; } // NHibernate takes care of this\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13145/"
] |
246,656 | <p>I am trying to match the folder name in a relative path using C#. I am using the expression: <code>"/(.*)?/"</code> and reversing the matching from left to right to right to left.
When I pass <code>"images/gringo/"</code> into the regular expression, it correctly gives me <code>"gringo"</code> in the first group - I'm only interested in what is between the brackets.
When I pass in <code>"images/"</code>, it fails to pick up <code>"images"</code>.
I have tried using <code>[/^]</code> and <code>[/$]</code> but neither work.</p>
<p>Thanks,
David</p>
| [
{
"answer_id": 246663,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 4,
"selected": false,
"text": "DirectoryInfo di = new DirectoryInfo(\"images/gringo/\");\nConsole.Out.WriteLine(di.Name);\n"
},
{
"answer_id":... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,667 | <p>I have a table in Access 2007 with 11,000 rows and about 20 columns. I want to create a form button that exports the table to an Excel sheet. The code need to be VBA.</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 246663,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 4,
"selected": false,
"text": "DirectoryInfo di = new DirectoryInfo(\"images/gringo/\");\nConsole.Out.WriteLine(di.Name);\n"
},
{
"answer_id":... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,671 | <p>Is it possible to import csv data into mysql and automatically create the column names, as in can I create just the table, or must I create the table names as well?</p>
<p>Is it possible to check for duplicate entries upon importing? I have an identifier field, but dont know how to make it so it will not be imported twice.</p>
<p>How would you import a jpeg file on a website into a field? Assume the website has been stored locally, and has the same filename as an identifer with ".jpeg" added on to the end.</p>
| [
{
"answer_id": 246695,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 2,
"selected": true,
"text": "LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name'\n[REPLACE | IGNORE]\nINTO TABLE tbl_name\n[CHARACTER SET chars... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
246,697 | <p>I need to create some windows service which will execute every N period of time.<br>
The question is:<br>
Which timer control should I use: <code>System.Timers.Timer</code> or <code>System.Threading.Timer</code> one? Does it influence on something? </p>
<p>I am asking because I heard many evidences to non correct work of <code>System.Timers.Timer</code> in windows services.<br>
Thank you.</p>
| [
{
"answer_id": 246719,
"author": "Andrew Moore",
"author_id": 26210,
"author_profile": "https://Stackoverflow.com/users/26210",
"pm_score": 8,
"selected": true,
"text": "System.Timers.Timer"
},
{
"answer_id": 16566309,
"author": "Nick N.",
"author_id": 869033,
"author... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,701 | <p>Why do database guys go on about normalisation? </p>
<p>What is it? How does it help? </p>
<p>Does it apply to anything outside of databases? </p>
| [
{
"answer_id": 246746,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 3,
"selected": false,
"text": "id, name, address\n214 Mr. Chris 123 Main St.\n317 Mrs. Chris 123 Main St.\n"
},
{
"answer_id": 246751,
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7211/"
] |
246,710 | <p>How do I implement the singleton pattern in C#? I want to put my constants and some basic functions in it as I use those everywhere in my project. I want to have them 'Global' and not need to manually bind them every object I create.</p>
| [
{
"answer_id": 246740,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 3,
"selected": false,
"text": "Singleton != Global"
},
{
"answer_id": 246750,
"author": "tvanfosson",
"author_id": 12950,
"author_p... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22562/"
] |
246,723 | <p>Which functions are available within Delphi to play a sound-file?</p>
| [
{
"answer_id": 246772,
"author": "Igal Tabachnik",
"author_id": 8205,
"author_profile": "https://Stackoverflow.com/users/8205",
"pm_score": 6,
"selected": true,
"text": "uses MMSystem;\n\nprocedure TForm1.Button1Click(Sender: TObject);\nbegin\n sndPlaySound('C:\\Windows\\Media\\Tada.wav... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32354/"
] |
246,725 | <p>When starting a django application using <code>python manage.py shell</code>, I get an InteractiveConsole shell - I can use tab completion, etc.</p>
<pre><code>Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
</code></pre>
<p>When just starting a python interpreter using <code>python</code>, it doesn't offer tab completion.</p>
<p>Can someone tell me what django is doing to give me an interactive console, or what I need to do to start an interactive console without a django app?</p>
| [
{
"answer_id": 246779,
"author": "ashchristopher",
"author_id": 22306,
"author_profile": "https://Stackoverflow.com/users/22306",
"pm_score": 9,
"selected": true,
"text": "# ~/.pythonrc\n# enable syntax completion\ntry:\n import readline\nexcept ImportError:\n print(\"Module readli... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22306/"
] |
246,726 | <p>I'm working on a report in SSRS (SQL Server Reporting Services) right now, and I'm having a problem getting a rectanlge I draw on the page in the report designer to grow. Basically, I've got a rectangle drawn, and then I put a text field inside of it. The contents of this text field can be either very short or very long, so I want it to grow to accomodate its contents.</p>
<p>But when I enter the long text, the textbox grows and then sticks outside of the lines of the rectangle. From the SSRS documentation I read, it says rectangles should grow to contain the items within them, and that those items are "peers".</p>
<p>What gives?</p>
| [
{
"answer_id": 247114,
"author": "Erick B",
"author_id": 1373,
"author_profile": "https://Stackoverflow.com/users/1373",
"pm_score": 3,
"selected": true,
"text": "CanGrow = TRUE"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/146/"
] |
246,760 | <p>In an UML component diagram, how does one tag or identify a component as a database, so that it's easily recognizable? In the old days there was the cylinder symbol for showing database but that's not part of the UML. Same goes for an application server for instance, how would that be shown?</p>
<p>Are stereotypes applicable here? Can the component symbol be enhanced with graphical elements?</p>
| [
{
"answer_id": 246768,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 1,
"selected": false,
"text": "<<database>>"
},
{
"answer_id": 246771,
"author": "Ilya Kochetov",
"author_id": 15329,
"author_profil... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,762 | <p>I have a Spring Interceptor which attempts to add an HTTP header in the postHandle() method.</p>
<pre><code>public void postHandle(HttpServletRequest req, HttpServletResponse resp,
Object obj1, ModelAndView mv)
throws Exception {
response.setHeader("SomeHeaderSet", "set");
response.addHeader("SomeHeaderAdd", "added");
}
}
</code></pre>
<p>However, neither header is added with either setHeader() or addHeader().</p>
<p>Is this even valid to do in the interceptor? I figured it WOULD be, but it ain't workin.</p>
<p>Regards,
Dustin</p>
| [
{
"answer_id": 247522,
"author": "DustinB",
"author_id": 7888,
"author_profile": "https://Stackoverflow.com/users/7888",
"pm_score": 2,
"selected": true,
"text": "response.setContentLength()"
},
{
"answer_id": 3092988,
"author": "Kristian",
"author_id": 11429,
"author... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7888/"
] |
246,766 | <p>I'm using Castle ActiveRecord, but this question applies to NHibernate, too, since a solution that works with NHibernate should work for ActiveRecord. Anyway, what I have is an underlying table structure like this:</p>
<p>TableA -hasMany-> TableB</p>
<p>I have corresponding objects EntityA and EntityB. EntityA has an IList of EntityB objects. This part works fine. Now, I want EntityB to have some kind of reference back to EntityA. I know I can use the BelongsTo attribute on EntityB to give it an actual reference back to the full EntityA type, like:</p>
<pre><code>[BelongsTo("tableAid")]
public EntityA Parent { get; set; }
</code></pre>
<p>But what I'd really like to do is:</p>
<pre><code>[BelongsTo("tableAid")]
public int ParentId { get; set; }
</code></pre>
<p>So, EntityB would store only the ID of the parent object, not a reference to the actual object. This is a trivial example, but I have good reasons for wanting to go with this approach. In the application I'm working on, we have pages that display specific EntityB-like objects, and we'd like for those pages to include links (as in hyperlinks) to the corresponding parent pages. We can do that by using the first approach above, but that requires that the entire EntityA object be loaded when all I really need is the ID. It's not a huge deal, but it just seems wasteful. I know I can use lazy-loading, but again, that seems more like a hack to me...</p>
<p>I have tried flagging the foreign key with the [Property] attribute like so:</p>
<pre><code>[Property]
public int ParentId { get; set; }
</code></pre>
<p>The problem with this approach is that EntityB.ParentId remains null when you do a EntityA.SaveAndFlush() on a new object tree. The correct value is being written to the database, and I can force the value back into EntityB.ParentId by doing an EntityA.Refresh(), but again, that seems like a bit of a hack.</p>
| [
{
"answer_id": 246988,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 0,
"selected": false,
"text": "[Property] public int ParentId { get; set; }\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32353/"
] |
246,787 | <p>I'm creating a cms and have not yet settled on the matter of where to store the complete url for a given page in the structure.</p>
<p>Every page have a slug (url friendly name of the page) and every page has a nullable (for top-level pages) parent and children.</p>
<p>Where do I store the complete url (/first-page/sub-page) for a given page? Should this go in the database along with the other properties of the page or in some cache?</p>
<p><strong>Update</strong></p>
<p>It's not the database design I'm asking about, rather where to store the complete url to a given page so I don't need to traverse the entire url to get the page that the user requested (/first-page/sub-page)</p>
<p><strong>Update 2</strong></p>
<p>I need to find which page belongs to the currently requested url. If the requested url is /first-page/sub-page I don't want to split the url and looping through the database (obviously).</p>
<p>I'd rather have the entire url in the table so that I can just do a single query (WHERE url = '/first-page/sub-page') but this does not seem ideal, what if I change the slug for the parent page? Then I also need to update the url-field for all descendants.</p>
<p>How do other people solve this issue? Are they putting it in the database? In a cache that maps /first-page-/sub-page to the id for the page? Or are they splitting the requested url and looping though the database?</p>
<p>Thanks</p>
<p>Anders</p>
| [
{
"answer_id": 246988,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 0,
"selected": false,
"text": "[Property] public int ParentId { get; set; }\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22092/"
] |
246,791 | <p>I'm consuming a third-party resource (a .dll) in a web service, and my problem is, that invoking this resource (calling a method) is done asynchronous - I need to subscribe to an event, to get the answer for my request. How do I do that in a c# web service?</p>
<p><strong>Update:</strong></p>
<p>With regard to <a href="https://stackoverflow.com/questions/246791/invoking-asynchronous-call-in-a-c-web-service/246892#246892">Sunny's answer</a>:</p>
<p>I don't want to make my web service asynchronous.</p>
| [
{
"answer_id": 246892,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Web.Services;\n\n[WebService(Namespace=\"http://www.contoso.com/\")]\npublic class MyServi... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,801 | <p>I have a PHP script that can encode a PNG image to a Base64 string.</p>
<p>I'd like to do the same thing using JavaScript. I know how to open files, but I'm not sure how to do the encoding. I'm not used to working with binary data.</p>
| [
{
"answer_id": 246813,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 8,
"selected": false,
"text": "/**\n*\n* Base64 encode / decode\n* http://www.webtoolkit.info/\n*\n**/\nvar Base64 = {\n\n // private property\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4939/"
] |
246,806 | <p>Is there any method?
My computer is AMD64.</p>
<pre><code>::std::string str;
BOOL loadU(const wchar_t* lpszPathName, int flag = 0);
</code></pre>
<p>When I used: </p>
<pre><code>loadU(&str);
</code></pre>
<p>the VS2005 compiler says:</p>
<pre><code>Error 7 error C2664:: cannot convert parameter 1 from 'std::string *__w64 ' to 'const wchar_t *'
</code></pre>
<p>How can I do it?</p>
| [
{
"answer_id": 246811,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 7,
"selected": true,
"text": "c_str()"
},
{
"answer_id": 246818,
"author": "marijne",
"author_id": 7038,
"author_profile": "https://... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25749/"
] |
246,814 | <p>I have a function called FindSpecificRowValue that takes in a datatable and returns the row number that contains a particular value. If that value isn't found, I want to indicate so to the calling function.</p>
<p>Is the best approach to:</p>
<ol>
<li>Write a function that returns false if not found, true if found, and the found row number as a byref/output parameter, or</li>
<li>Write a function that returns an int and pass back -999 if the row value isn't found, the row number if it is?</li>
</ol>
| [
{
"answer_id": 246872,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 5,
"selected": true,
"text": "TryFindSpecificRow\nFindSpecificRow\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335036/"
] |
246,817 | <p>I want to automate SVN adds using NAnt. I want to add to SVN all new files in a given directory. The NAnt script will successfully execute the add command, however it displays the Tortoise SVN add dialog and this is not acceptable because it will execute on a build server running CruiseControl. The build server is running Windows Server 2003. </p>
<p>Any ideas?</p>
<pre><code><target name="addtest">
<exec program="c:\program files\tortoisesvn\bin\tortoiseproc.exe"
commandline="/command:add * --force /path:C:\svn\test /notempfile /closeonend:1"
basedir="C:\svn\test"
failonerror="false"/>
</target>
</code></pre>
| [
{
"answer_id": 246833,
"author": "Ben Scheirman",
"author_id": 3381,
"author_profile": "https://Stackoverflow.com/users/3381",
"pm_score": 1,
"selected": false,
"text": "c:\\>svn add ...\n"
},
{
"answer_id": 247688,
"author": "Scott Saad",
"author_id": 4916,
"author_p... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,822 | <p>I'm writing a password encryption routine. I've written the below app to illustrate my problem. About 20% of the time, this code works as expected. The rest of the time, the decryption throws a cryptographic exception - "The data is invalid".</p>
<p>I believe the problem is in the encryption portion, because the decryption portion works the same every time. That is, if the encryption routine yields a value that the decryption routine can decrypt, it can always decrypt it. But if the encryption routine yields a value that chokes the decryption routine, it always chokes. So the decrypt routine is consistent; the encrypt routine is not.</p>
<p>I suspect my use of Unicode encoding is incorrect, but I've tried others with the same result.</p>
<p>What am I doing wrong?</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;
namespace DataProtectionTest
{
public partial class Form1 : Form
{
private static readonly byte[] entropy = { 1, 2, 3, 4, 1, 2, 3, 4 };
private string password;
public Form1()
{
InitializeComponent();
}
private void btnEncryptIt_Click(object sender, EventArgs e)
{
Byte[] pw = Encoding.Unicode.GetBytes(textBox1.Text);
Byte[] encryptedPw = ProtectedData.Protect(pw, entropy, DataProtectionScope.LocalMachine);
password = Encoding.Unicode.GetString(encryptedPw);
}
private void btnDecryptIt_Click(object sender, EventArgs e)
{
Byte[] pwBytes = Encoding.Unicode.GetBytes(password);
try
{
Byte[] decryptedPw = ProtectedData.Unprotect(pwBytes, entropy, DataProtectionScope.LocalMachine);
string pw = Encoding.Unicode.GetString(decryptedPw);
textBox2.Text = pw;
}
catch (CryptographicException ce)
{
textBox2.Text = ce.Message;
}
}
}
}
</code></pre>
| [
{
"answer_id": 247019,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 1,
"selected": false,
"text": "Encoding.GetEncoding(28591)\nEncoding.GetEncoding(\"Latin1\")\nEncoding.GetEncoding(\"iso-8859-1\")\n"
},
{
"answer_id... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2610/"
] |
246,841 | <p>We may tag a question with multiple tags in StackOverflow website, I'm wondering how to find out the most related questions with common tags.</p>
<p>Assume we have 100 questions in a database, each question has several tags. Let's say user is browsing a specific question, and we want to make the system to display the related questions on the page. The criteria for related question is they have most common tags.</p>
<p>For example:
Question 1 is tagged with AAA, BBB, CCC, DDD, EEE.</p>
<p>Question 2 is top 1 related because it also has all those 5 tags.
Question 3 is top 2 related because it has only 4 or 3 tags that Questio1 has.
......</p>
<p>So my question is how to design the database and find out the questions that's related to Question 1 quickly. Thank you very much.</p>
| [
{
"answer_id": 246847,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "SELECT * FROM `questions` WHERE `tag` LIKE '%tagname%' OR (looped for each tag) LIMIT 5,0\n"
},
{
"answer_id": 247041,
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,849 | <p>we're currently planning a larger WPF LoB application and i wonder what others think being the best practice for storing lots of UI settings e.g.</p>
<ul>
<li>Expander States</li>
<li>Menu orders</li>
<li>Sizing Properties</li>
<li>etc...</li>
</ul>
<p>i don't like the idea of having dozens of stored values using the delivered SettingsProvider (i.e. App.config file) although it can be used to store it in an embedded database using a custom SettingsProvider.
being able to use some kind of databinding is also a concern.
Has anyone had the same problems? </p>
<p>What did you do to store lots of ui user settings?</p>
| [
{
"answer_id": 246880,
"author": "thismat",
"author_id": 14045,
"author_profile": "https://Stackoverflow.com/users/14045",
"pm_score": 4,
"selected": false,
"text": "Environment.SpecialFolder.ApplicationData\n"
},
{
"answer_id": 246889,
"author": "Patrick Desjardins",
"au... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227/"
] |
246,859 | <p>Could somebody give me a brief overview of the differences between HTTP 1.0 and HTTP 1.1? I've spent some time with both of the RFCs, but haven't been able to pull out a lot of difference between them. Wikipedia says this:</p>
<blockquote>
<p><strong>HTTP/1.1 (1997-1999)</strong></p>
<p>Current version; persistent connections enabled by default and works well with proxies. Also supports request pipelining, allowing multiple requests to be sent at the same time, allowing the server to prepare for the workload and potentially transfer the requested resources more quickly to the client.</p>
</blockquote>
<p>But that doesn't mean a lot to me. I realize this is a somewhat complicated subject, so I'm not expecting a full answer, but can someone give me a brief overview of the differences at a bit lower level?<br />
By this I mean that I'm looking for the info I would need to know to implement either an HTTP server or application. I'm mostly looking for a nudge in the right direction so that I can figure it out on my own.</p>
| [
{
"answer_id": 246897,
"author": "Leandro López",
"author_id": 22695,
"author_profile": "https://Stackoverflow.com/users/22695",
"pm_score": 3,
"selected": false,
"text": "GET"
},
{
"answer_id": 247026,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] |
246,870 | <p>Each of my clients can have many todo items and every todo item has a due date.</p>
<p>What would be the query for discovering the next undone todo item by due date for each file? In the event that a client has more than one todo, the one with the lowest id is the correct one.</p>
<p>Assuming the following minimal schema:</p>
<pre><code>clients (id, name)
todos (id, client_id, description, timestamp_due, timestamp_completed)
</code></pre>
<p>Thank you.</p>
| [
{
"answer_id": 246918,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": -1,
"selected": false,
"text": "SELECT\n C.Id,\n C.Name,\n T.Id\n T.Description,\n T.timestamp_due\nFROM\n{\n SELECT\n c... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
246,876 | <pre><code>$doba = explode("/", $dob);
$date = date("Y-m-d", mktime(0,0,0, $doba[0], $doba[1], $doba[2]));
</code></pre>
<p>The above code turns any date i pass through into 1999-11-30 and i know it was working yesterday. Date is correct when I echo $doba. Anyone have any ideas?</p>
<p>Cheers</p>
| [
{
"answer_id": 246891,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 3,
"selected": true,
"text": "$doba"
},
{
"answer_id": 246908,
"author": "Andrew Moore",
"author_id": 26210,
"author_profile": "https://St... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] |
246,877 | <p>Any links to a good template for a windows service? (looking for C# code)</p>
<p>Something that has the basic functionality that I could extend.</p>
| [
{
"answer_id": 249770,
"author": "KeesDijk",
"author_id": 6434,
"author_profile": "https://Stackoverflow.com/users/6434",
"pm_score": 1,
"selected": false,
"text": "using System;\nusing System.ServiceProcess;\nusing System.Timers;\n\nnamespace WindowsService1\n{\n public partial class... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,884 | <p>I haven´t experience in making setup, but I all ready make mine but now I need help because when I made a new version I want that the user double click the shortcut and it do the update if there are any.</p>
<p>The application is in <code>c#</code>.</p>
<p>Could you help?</p>
| [
{
"answer_id": 246955,
"author": "Dan Walker",
"author_id": 752,
"author_profile": "https://Stackoverflow.com/users/752",
"pm_score": 1,
"selected": false,
"text": " WebClient wc = new WebClient();\n wc.DownloadFile(UrlOfIniContainingLatestVersion, PlacetoSa... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246884",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32115/"
] |
246,890 | <p>I recently converted a site from asp to CF. Unfortunately, alot of the old users had the "homepage" bookmarked. www.example.com/homepage.asp</p>
<p>Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?</p>
<p>I would normally just delete those files, but the owner(s) wanted to keep it around for their own comparison reasons.</p>
<p>Any ideas?</p>
<p>Thanks</p>
| [
{
"answer_id": 246929,
"author": "Patrick McElhaney",
"author_id": 437,
"author_profile": "https://Stackoverflow.com/users/437",
"pm_score": 4,
"selected": true,
"text": "<%@ Language=VBScript %>\n<%\nResponse.Status=\"301 Moved Permanently\"\nResponse.AddHeader \"Location\", \"/index.cf... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] |
246,893 | <p>Is there a .net equivalent to the C++ unexpected()/set_unexpected() functionality?</p>
<hr>
<p><strong>Edit:</strong> Sorry--I omitted some details previously:</p>
<p>Language: C# 2.0</p>
<p>I have some legacy apps that seem to be throwing some unhandled exception somewhere. I just want to put something in place to stop the customer's pain until I can trace the actual source of the problem. In C++, the function pointed at by set_unexpected() gets called, as far as I know, when an otherwise unhandled exception bubbles to the main routine. Hence my question about a .net equivalent functionality. </p>
| [
{
"answer_id": 11666389,
"author": "Dunc",
"author_id": 188926,
"author_profile": "https://Stackoverflow.com/users/188926",
"pm_score": 0,
"selected": false,
"text": "private delegate long UnhandledExceptionFilter(IntPtr exception);\n\n[DllImport(\"KERNEL32.DLL\", SetLastError = true)]\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] |
246,905 | <p>I just finished a 2d platformer in C++/Allegro. Its still in an incomplete stage...</p>
<p>I wonder how to go about a peer-review from people who are into game development.
I would like to review my project on grounds of </p>
<ol>
<li>game play</li>
<li>Collision detection</li>
<li>use of OOP</li>
<li>programming of sounds, effects etc</li>
<li>any further ideas</li>
<li>ways in which i could have done better</li>
<li>ways to optimize</li>
</ol>
<p>current code looks like a garbage at some places... so could you also suggest some simplification techniques?</p>
<p>you can view my project (if you wish) at updated link - <a href="http://ideamonk.blogspot.com/2008/09/nincompoop-all-ready-for-shaastra-2008.html" rel="nofollow noreferrer">nincompoop</a> <a href="http://ideamonk.googlepages.com/nincompoop_distro.rar" rel="nofollow noreferrer">(direct link)</a></p>
<p><a href="http://ideamonk.googlepages.com/nincompoop_distro.rar" rel="nofollow noreferrer">http://ideamonk.googlepages.com/nincompoop_distro.rar</a></p>
<p>As of now I am switching to C# and XNA, finding it very easy and fast to learn all because I'm impressed from - </p>
<p><a href="http://catalog.xna.com/GameDetails.aspx?releaseId=341" rel="nofollow noreferrer">http://catalog.xna.com/GameDetails.aspx?releaseId=341</a></p>
<blockquote>
<p>I do no intend to sell any product or popularise anything here... my intent is to get tips to be better from people who are better. As for the page where I have uploaded my project, its not supported by ads of any kind. so please feel safe.</p>
</blockquote>
| [
{
"answer_id": 254242,
"author": "postfuturist",
"author_id": 1892,
"author_profile": "https://Stackoverflow.com/users/1892",
"pm_score": 3,
"selected": true,
"text": "int main () \n{\n game_object gob;\n gob.init_allegro();\n gob.load_assets();\n while(true) {\n gob.h... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8786/"
] |
246,912 | <p>Currently there are 2 pages in a jsp file: one of them displays the data and the second one is used for pagination. The task is to include exactly the same paginator table above the data table. Sorry, couldn't resist to draw it :)</p>
<pre><code>|-----------------------------------------|
| Page 2 of 200 < > |
|-----------------------------------------|
|-----------------------------------------|
| Some weird business data comes here |
|-----------------------------------------|
|-----------------------------------------|
| Page 2 of 200 < > |
|-----------------------------------------|
</code></pre>
<p>The question is: how do I do it w/o shameless copypasting?</p>
| [
{
"answer_id": 246975,
"author": "pkaeding",
"author_id": 4257,
"author_profile": "https://Stackoverflow.com/users/4257",
"pm_score": 2,
"selected": false,
"text": "<jsp:include page=\"pagination.jsp\" flush=\"true\" />\n\n<table>...business data...</table>\n\n<jsp:include page=\"paginat... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15187/"
] |
246,919 | <p>What is the best way to implement the page view counter like the ones they have here on the site where each question has a "Views" counter?</p>
<p>Factoring in Performance and Scalability issues.</p>
| [
{
"answer_id": 246980,
"author": "Bob Fanger",
"author_id": 19165,
"author_profile": "https://Stackoverflow.com/users/19165",
"pm_score": 4,
"selected": true,
"text": "UPDATE page_views SET counter = counter + 1 WHERE page_id = x\nif (affected_rows == 0 ) {\n INSERT INTO page_views (pa... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] |
246,930 | <p>I see these two acronyms being thrown around and I was wondering if there are any differences between a GUID and a UUID?</p>
| [
{
"answer_id": 6953207,
"author": "Hoylen",
"author_id": 232064,
"author_profile": "https://Stackoverflow.com/users/232064",
"pm_score": 11,
"selected": true,
"text": "version"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/246930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/343/"
] |
246,931 | <p>I have two models, Article and Post that both inherit from a base model called ContentBase.</p>
<p>You can leave comments on both Articles and Posts, so I am using a Polymorphic Association between Comments and Article or Post.</p>
<p>However, since both Article and Post inherit from ContentBase, the commentable_type field ends up being "ContentBase" for both and screws everything up.</p>
<p>Is there a way to specify the commentable_type field in the has_many relationship in Article and Post?</p>
<p>Edit:</p>
<p>By "screws everything up" I mean if there is an Article with ID=1 and Post with ID=1 and I add a Comment with commentable_id=1, commentable_type=ContentBase, that comment will show up for both the Article and Post.</p>
<p>Here's the code:</p>
<pre><code>class Article < BaseContent
has_many :comments, :as => :commentable
end
class Post < BaseContent
has_many :comments, :as => :commentable
end
</code></pre>
<p>and here's my Comment model:</p>
<pre><code>class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
</code></pre>
| [
{
"answer_id": 247617,
"author": "Mike Breen",
"author_id": 22346,
"author_profile": "https://Stackoverflow.com/users/22346",
"pm_score": 3,
"selected": true,
"text": "Module BaseContent\n def self.included(base)\n base.class_eval do\n validates_presence_of :somefield\n... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1396/"
] |
246,961 | <p>I have many articles in a database (with title,text), I'm looking for an algorithm to find the X most similar articles, something like Stack Overflow's "Related Questions" when you ask a question. </p>
<p>I tried googling for this but only found pages about other "similar text" issues, something like comparing every article with all the others and storing a similarity somewhere. SO does this in "real time" on text that I just typed.</p>
<p>How?</p>
| [
{
"answer_id": 42482364,
"author": "DroidOS",
"author_id": 1077485,
"author_profile": "https://Stackoverflow.com/users/1077485",
"pm_score": 1,
"selected": false,
"text": "[and,amd]"
},
{
"answer_id": 52152966,
"author": "Serge Rogatch",
"author_id": 1915854,
"author_... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25544/"
] |
246,963 | <p>Say I have a class called PermissionManager which should only exist once for my system and basically fulfills the function of managing various permissions for various actions in my application. Now I have some class in my application which needs to be able to check a certain permission in one of its methods. This class's constructor is currently public, i.e. used by API users.</p>
<p>Until a couple of weeks ago, I would have simply had my class call the following pseudo-code somewhere:</p>
<pre><code> PermissionManager.getInstance().isReadPermissionEnabled(this)
</code></pre>
<p>But since I have noticed everyone here hating singletons + this kind of coupling, I was wondering what the better solution would be, since the arguments I have read against singletons seem to make sense (not testable, high coupling, etc.).</p>
<p>So should I actually require API users to pass in a PermissionManager instance in the constructor of the class? Even though I only want a single PermissionManager instance to exist for my application?</p>
<p>Or am I going about this all wrong and should have a non-public constructor and a factory somewhere which passes in the instance of PermissionManager for me?</p>
<hr>
<p><strong>Additional info</strong> Note that when I say "Dependency Injection", I'm talking about the DI <a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="noreferrer">Pattern</a>...I am not using any DI framework like Guice or Spring. (...yet)</p>
| [
{
"answer_id": 247056,
"author": "Eddie Deyo",
"author_id": 9323,
"author_profile": "https://Stackoverflow.com/users/9323",
"pm_score": 3,
"selected": true,
"text": "PermissionManager mManager = null;\npublic PermissionManager Permissions\n{\n if (mManager == null)\n {\n return mMan... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] |
246,966 | <p>I've found that given a form in a HTML page like this:</p>
<pre><code><form name="form">
<input type="image" name="foo"
src="somewhere.gif" alt="image" value="blah"/>
<input type="text" name="bar" value="blah"/>
</form>
</code></pre>
<p>When accessing the elements via the DOM in Javascript, there is <em>no</em> element for the image input! It is just omitted. So, <code>document.forms[0].elements.length</code> is 1, and <code>document.forms[0].element[0].type</code> is "text".</p>
<p>This seems to be the case in Firefox, and IE. I can't find this fact documented anywhere in my reference books or on the web. All I can find is a throwaway comment here:</p>
<p><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=163822#c4" rel="nofollow noreferrer">https://bugzilla.mozilla.org/show_bug.cgi?id=163822#c4</a></p>
<p>Which suggests it "just is like this". If so, well so be it - but is it <em>really</em> not documented anywhere? Is it a historical mistake, or is there a reason for it?</p>
| [
{
"answer_id": 247002,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "elements"
},
{
"answer_id": 247042,
"author": "Greg",
"author_id": 24181,
"author_profile": "htt... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246966",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,969 | <p>I want to do something like this:</p>
<pre><code>const
MyFirstConstArray: array[0..1] of string = ('Hi', 'Foo');
MySecondConstArrayWhichIncludesTheFirstOne: array[0..2] of string =
MyFirstConstArray + ('Bar');
</code></pre>
<p>Basically I want the following result:</p>
<pre><code>MyFirstConstArray -> ('Hi', 'Foo');
MySecondConstArrayWhichIncludesTheFirstOne -> ('Hi', 'Foo', 'Bar');
</code></pre>
<p>Is it possible somehow?</p>
| [
{
"answer_id": 247618,
"author": "Francesca",
"author_id": 9842,
"author_profile": "https://Stackoverflow.com/users/9842",
"pm_score": 3,
"selected": true,
"text": "const\n MyConst1 = 'Hi';\n MyConst2 = 'Foo';\n MyConst3 = 'Bar';\n MyFirstConstArray: array[0..1] of string = (MyConst1... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] |
246,977 | <p>I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact?</p>
<p>(<a href="https://en.wikipedia.org/wiki/Flexible_array_member" rel="noreferrer">Flexible array members</a> are a C feature introduced in C99 whereby one can declare the last element to be an array of unspecified size. For example: )</p>
<pre><code>struct header {
size_t len;
unsigned char data[];
};
</code></pre>
| [
{
"answer_id": 247038,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackoverflow.com/users/1737",
"pm_score": 4,
"selected": false,
"text": "struct header\n{\n size_t len;\n unsigned char data[];\n}; \n"
},
{
"answer_id": 247040,
"author": "Remo.D",
"... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,981 | <p>Does anyone have any idea what is wrong with this create statement for mysql? </p>
<p>EDIT: now it states the error is near: revised VARCHAR(20), paypal_accept TINYINT, pre_terminat' at line 4</p>
<p>Thanks for the help everyone</p>
<p>Still errors after using sql beautifier though</p>
<pre><code>CREATE TABLE AUCTIONS (
ARTICLE_NO VARCHAR(20),
ARTICLE_NAME VARCHAR(100),
SUBTITLE VARCHAR(20),
CURRENT_BID VARCHAR(20),
START_PRICE VARCHAR(20),
BID_COUNT VARCHAR(20),
QUANT_TOTAL VARCHAR(20),
QUANT_SOLD VARCHAR(20),
START DATETIME,
ENDS DATETIME,
ORIGIN_END DATETIME,
SELLER_ID VARCHAR(20),
BEST_BIDDER_ID VARCHAR(20),
FINISHED VARCHAR(20),
WATCH VARCHAR(20),
BUYITNOW_PRICE VARCHAR(20),
PIC_URL VARCHAR(20),
PRIVATE_AUCTION VARCHAR(20),
AUCTION_TYPE VARCHAR(20),
INSERT_DATE DATETIME,
UPDATE_DATE DATETIME,
CAT_1_ID VARCHAR(20),
CAT_2_ID VARCHAR(20),
ARTICLE_DESC VARCHAR(20),
DESC_TEXTONLY VARCHAR(20),
COUNTRYCODE VARCHAR(20),
LOCATION VARCHAR(20),
CONDITION VARCHAR(20),
REVISED VARCHAR(20),
PAYPAL_ACCEPT TINYINT,
PRE_TERMINATED VARCHAR(20),
SHIPPING_TO VARCHAR(20),
FEE_INSERTION VARCHAR(20),
FEE_FINAL VARCHAR(20),
FEE_LISTING VARCHAR(20),
PIC_XXL TINYINT,
PIC_DIASHOW TINYINT,
PIC_COUNT VARCHAR(20),
ITEM_SITE_ID VARCHAR(20),
PRIMARY KEY ( `ARTICLE_NO` ));
</code></pre>
<p>The error is now near 'CONDITION VARCHAR(20), REVISED VARCHAR(20), PAYPAL_ACCEPT TI' at line 29</p>
<p>I really can't see what is wrong, does TINYINT need a parameter?</p>
<p>Do MYSQL column names have to be capitals?</p>
| [
{
"answer_id": 246996,
"author": "dove",
"author_id": 30913,
"author_profile": "https://Stackoverflow.com/users/30913",
"pm_score": 3,
"selected": false,
"text": "watch VARCHAR(20), **????** VARCHAR(20), \nauction_type VARCHAR(20),\n"
},
{
"answer_id": 247061,
"author": "Ste... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] |
246,983 | <p>What's the most efficient way of getting the value of the SERIAL column after the INSERT statement? I.e. I am looking for a way to replicate <code>@@IDENTITY</code> or <code>SCOPE_IDENTITY</code> functionality of MS SQL</p>
| [
{
"answer_id": 247159,
"author": "Brian Schmitt",
"author_id": 30492,
"author_profile": "https://Stackoverflow.com/users/30492",
"pm_score": 1,
"selected": false,
"text": "if LOCAL_SQLCA^.sqlcode = 0 then\n/* return serial */\n Result := LOCAL_SQLCA^.sqlerrd[1]\nelse\n/* return error co... | 2008/10/29 | [
"https://Stackoverflow.com/questions/246983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15329/"
] |
247,006 | <p>I've got a PHP application which needs to grab the contents from another web page, and the web page I'm reading needs a cookie.</p>
<p>I've found info on how to make this call once i have the cookie ( <a href="http://groups.google.com/group/comp.lang.php/msg/4f618114ab15ae2a" rel="nofollow noreferrer">http://groups.google.com/group/comp.lang.php/msg/4f618114ab15ae2a</a> ), however I've no idea how to generate the cookie, or how / where the cookie is saved.</p>
<p>For example, to read this web page via wget I do the following:</p>
<pre><code>wget --quiet --save-cookies cookie.file --output-document=who.cares \
http://remoteServer/login.php?user=xxx&pass=yyy
wget --quiet --load-cookies cookie.file --output-document=documentiwant.html \
http://remoteServer/pageicareabout.html
</code></pre>
<p>... my question is how do I do the '--save-cookies' bit in PHP so that I can use the cookie in the follow-up PHP stream_context_create / file_get_contents block:</p>
<pre><code>$opts = array(http'=> array(
'method'=> "GET",
'header'=>
"Accept-language: en\r\n" .
"Cookie: **NoClueAtAll**\r\n"
)
);
$context = stream_context_create($opts);
$documentiwant = file_get_contents("http://remoteServer/pageicareabout.html",
0, $context);
</code></pre>
| [
{
"answer_id": 247472,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "<?php\n\n$cr = curl_init('http://remoteServer/login.php?user=xxx&pass=yyy');\ncurl_setopt($cr, CURLOPT_RETURNTRANSFER, true); ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,023 | <p>I have a structure like this:</p>
<pre><code><ul>
<li>text1</li>
<li>text2</li>
<li>text3</li>
</ul>
</code></pre>
<p>How do I use javascript or jQuery to get the text as an array?</p>
<pre><code>['text1', 'text2', 'text3']
</code></pre>
<p>My plan after this is to assemble it into a string, probably using <code>.join(', ')</code>, and get it in a format like this:</p>
<pre><code>'"text1", "text2", "text3"'
</code></pre>
| [
{
"answer_id": 247057,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 8,
"selected": true,
"text": "var optionTexts = [];\n$(\"ul li\").each(function() { optionTexts.push($(this).text()) });\n"
},
{
"answer_id": 247067,
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3757/"
] |
247,025 | <p>It is good practice to use the main method to test a java/.net class?</p>
<p>I've seen it reccommended in some text books, but to me it seems like using a unit testing framework would make more sense...</p>
<p>The main method gives you one point of entry to the class and you can test one aspect of the classes functionality. You could I guess test many but it doesn't seem to make sense as much as using Junit or Nunit.</p>
| [
{
"answer_id": 248334,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 0,
"selected": false,
"text": "Compile with /main to specify the type that contains the entry point."
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] |
247,045 | <p>Been a while since I've dealt with ASP.NET and this is the first time I've had to deal with master pages. Been following tutorials everything is fine except a problem I'm having with the footer.</p>
<p>The master page has divs for topContent, mainContent and footerContent. In mainContent I have a ContentPlaceHolder.</p>
<p>The default content page (just getting some proof-of-concept going here) has a few labels and text boxes in it with one multi-line text box in the Content area. "Content1" properly links back to ContentPlaceHolder1 back on the master page.</p>
<p>When I run the site, the content appears but the footer section isn't "pushed down" by the now-filled ContentPlaceHolder - it almost acts like a background image.</p>
<p>What attribute am I missing here? I tried using CSS to force the footerContent to the bottom, but that just put the fotter content at the bottom of the browser and when I expanded the multi-line text box to greater than the browser's window height, the same thing happened (content overlaying the footer)</p>
<p>I know this has to be something simple that I'm missing.</p>
<p>The basics of the master page are as follows:</p>
<pre><code><form id="form1" runat="server">
<div id="topContent">
<table style="width: 832px">
</table>
</div>
<div id="mainContent">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="footerContent">
<br/><br/>
<center style="font-size: small; font-style: italic; font-family: Arial">
<a target="_new" href="/Disclaimer.html">Security and Privacy Notice</a><br/>
...
</center>
</div>
</form>
</code></pre>
<p>Help!</p>
<p>EDIT: Turns out that VS2005 was putting "position: absolute" tags on all the components (labels and text boxes) that I put on the content.aspx page. Going into the asp tags and changing them to "position: relative" did the trick.</p>
| [
{
"answer_id": 247095,
"author": "Schalk Versteeg",
"author_id": 15724,
"author_profile": "https://Stackoverflow.com/users/15724",
"pm_score": 2,
"selected": false,
"text": " <div id=\"mainContent\"style=\"position:relative;\">\n <asp:ContentPlaceHolder id=\"ContentPlaceHolder1\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15891/"
] |
247,053 | <p>On Linux, feenableexcept and fedisableexcept can be used to control the generation of SIGFPE interrupts on floating point exceptions. How can I do this on Mac OS X Intel?</p>
<p>Inline assembly for enabling floating point interrupts is provided in <a href="http://developer.apple.com/documentation/Performance/Conceptual/Mac_OSX_Numerics/Mac_OSX_Numerics.pdf" rel="noreferrer">http://developer.apple.com/documentation/Performance/Conceptual/Mac_OSX_Numerics/Mac_OSX_Numerics.pdf</a>, pp. 7-15, but only for PowerPC assembly.</p>
| [
{
"answer_id": 252590,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 3,
"selected": false,
"text": "short fpflags = 0x1332 // Default FP flags, change this however you want. \nasm(\"fnclex\");\nasm(\"fldcw _fpflags\"... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16480/"
] |
247,059 | <p>In C# there is the static property <a href="http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx" rel="noreferrer">Environment.Newline</a> that changed depending on the running platform.</p>
<p>Is there anything similar in Java?</p>
| [
{
"answer_id": 247069,
"author": "Tom Lokhorst",
"author_id": 2597,
"author_profile": "https://Stackoverflow.com/users/2597",
"pm_score": 9,
"selected": true,
"text": "System.lineSeparator()\n"
},
{
"answer_id": 247597,
"author": "Alan Moore",
"author_id": 20938,
"aut... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20480/"
] |
247,064 | <p>I've recently been lifted out of the .Net world into the Java world and I miss my unit tests.</p>
<p>Using Visual Studio I used NUnit and TestDriven.net to run my unit tests.</p>
<p>What is a comparable system for Java Using Eclipse?</p>
<p>I'm looking specifically for the plugins that will get me going, or a guide on how to do it.</p>
<p>I'm aware that JUnit is what NUnit was initially based on, but I want to know the best way to integrate it into Eclipse as there seem to be a few plugins that do this and I don't have the time to play around with them all.</p>
<p><strong>UPDATE</strong></p>
<p>Okay I didn't know that JUnit was built into the IDE. Are there any plugins that make using JUnit any easier?</p>
| [
{
"answer_id": 247975,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 1,
"selected": false,
"text": "@Test\npublic myTest() {\n // Test code here\n}\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] |
247,066 | <p>I want the most performat way to read and parse a file.</p>
<p>Is it possible to read a file in .NET, but not load the entire file into memory? i.e. just load the file line by line as I parse the content of each row?</p>
<p>Does XmlTextReader load the entire file into memory or does it stream the file into memory as it reads the file?</p>
| [
{
"answer_id": 247107,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 3,
"selected": false,
"text": "string line;\n\n// Read the file and display it line by line.\nSystem.IO.StreamReader file = \n new System.IO.StreamReade... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,086 | <p>I know that one of the defining principles of Test driven development is that you write your Unit tests first and then write code to pass those unit tests, but is it necessary to do it this way?</p>
<p>I've found that I often don't know what I am testing until I've written it, mainly because the past couple of projects I've worked on have more evolved from a proof of concept rather than been designed.</p>
<p>I've tried to write my unit tests before and it can be useful, but it doesn't seem natural to me.</p>
| [
{
"answer_id": 247119,
"author": "Jonke",
"author_id": 15638,
"author_profile": "https://Stackoverflow.com/users/15638",
"pm_score": 2,
"selected": false,
"text": "picker = Pick.new\nitem=picker.pick('a')\nassert item\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20400/"
] |
247,090 | <p>I'm familiar with the issue behind ORA-01775: looping chain of synonyms, but is there any trick to debugging it, or do I just have to "create or replace" my way out of it? </p>
<p>Is there a way to query the schema or whatever to find out what the current definition of a public synonym is? </p>
<p>Even more awesome would be a graphical tool, but at this point, anything would be helpful.</p>
| [
{
"answer_id": 247180,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 5,
"selected": false,
"text": "DBA_SYNONYMS"
},
{
"answer_id": 247191,
"author": "warren",
"author_id": 4418,
"author_profile": "... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/549/"
] |
247,093 | <p>I want to change the registry values on the pocketPC. I ran the following code:</p>
<pre><code>if(enabled)
{
dwData = 120;
}
if(RegSetValueEx(HKEY_LOCAL_MACHINE, _T("System\\CurrentControlSet\\Control\\Power\\Timeouts\\BattSuspendTimeout"), 0, REG_DWORD, (LPBYTE)&dwData, sizeof(DWORD)))
{
return FALSE;
}
</code></pre>
<p>but it doesn't shange the registry entry. Does anyone know how to set registry key values with c++?</p>
<p>Thanks!</p>
| [
{
"answer_id": 248604,
"author": "Shane Powell",
"author_id": 23235,
"author_profile": "https://Stackoverflow.com/users/23235",
"pm_score": 4,
"selected": true,
"text": "HKEY key;\nif(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, \"System\\\\CurrentControlSet\\\\Control\\\\Power\\\\T... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] |
247,106 | <p>Looking at this loop that copies one c-string to another:</p>
<pre><code>void strcpyr(char *s, char *t)
{
while(*s++=*t++)// Why does this work?
;
}
</code></pre>
<p>Why do we not check for the '\0' character in the while loop, like this?</p>
<pre><code>while((*s++=*r++)!='\0')..
</code></pre>
<p>How does the first loop terminate?</p>
| [
{
"answer_id": 247122,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 2,
"selected": false,
"text": "'\\0'"
},
{
"answer_id": 247126,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "http... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,110 | <p>I'm getting started on building a REST API for a project I'm working on, and it led me to do a little research as to the best way to build an API using RoR. I find out pretty quickly that by default, models are open to the world and can be called via URL by simply putting a ".xml" at the end of the URL and passing appropriate parameters.</p>
<p>So then the next question came. How do I secure my app to prevent unauthorized changes? In doing some research I found a couple articles talking about <code>attr_accessible</code> and <code>attr_protected</code> and how they can be used. The particular URL I found talking about these was posted back in May of '07 (<a href="http://railscasts.com/episodes/26-hackers-love-mass-assignment" rel="noreferrer">here</a>). </p>
<p>As with all things ruby, I'm sure that things have evolved since then. So my question is, is this still the best way to secure a REST API within RoR?</p>
<p>If not what do you suggest in either a "new project" or an "existing project"scenario?</p>
| [
{
"answer_id": 247162,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 2,
"selected": false,
"text": " class Model < ActiveRecord::Base \n attr_accessible nil \n end\n"
},
{
"answer_id": 248101,
"author"... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23458/"
] |
247,123 | <p>I am writing a C# console application that takes a binary file, rips it apart, analyzes it, and stores the data into a database. </p>
<p>We want to use BizTalk to orchestrate watching when a new binary file is placed in a directory and calling my application with the file name/names to be parsed. </p>
<p>Can BizTalk run a command line program?<br>
Can it pass command line parameters to the program?<br>
How would I report back to BizTalk that the last run was a success or a failure? </p>
<p>Thank you,<br>
Keith</p>
| [
{
"answer_id": 248503,
"author": "David Hall",
"author_id": 2660,
"author_profile": "https://Stackoverflow.com/users/2660",
"pm_score": 3,
"selected": true,
"text": "System.Diagnostics.Process.Start(@\"C:\\yourPath\\yourExecutable.exe\")"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1048/"
] |
247,128 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content">Resizing an iframe based on content</a> </p>
</blockquote>
<p>I'm loading an iFrame and want the parent to automatically change the height based upon the height of the iFrame's content.</p>
<p>To simply things, all pages belong to the same domain, so I shouldn't run into cross-site scripting issues.</p>
| [
{
"answer_id": 247160,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 5,
"selected": false,
"text": "scrollHeight"
},
{
"answer_id": 247221,
"author": "Allan",
"author_id": 5123,
"author_profile": "https://S... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123/"
] |
247,135 | <p>I use <a href="http://xpath.alephzarro.com/" rel="noreferrer">XPather Browser</a> to check my XPATH expressions on an HTML page.</p>
<p>My end goal is to use these expressions in Selenium for the testing of my user interfaces.</p>
<p>I got an HTML file with a content similar to this:</p>
<pre>
<tr>
<td>abc</td>
<td>&nbsp;</td>
</tr>
</pre>
<p>I want to select a node with a text containing the string "<code>&nbsp;</code>".</p>
<p>With a normal string like "abc" there is no problem. I use an XPATH similar to <code>//td[text()="abc"]</code>.</p>
<p>When I try with an an XPATH like <code>//td[text()="&nbsp;"]</code> it returns nothing. Is there a special rule concerning texts with "<code>&</code>" ?</p>
| [
{
"answer_id": 247158,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " "
},
{
"answer_id": 247368,
"author": "James Sulak",
"author_id": 207,
"author_profile": "https://St... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16927/"
] |
247,143 | <p>FORTRAN provides several functions to convert a double precision number to an integral value. The method used for truncation/rounding differs. I am converting complex scientific algorithms which use these.</p>
<p>According to FORTRAN documentation:<br>
<b>aint(x)</b> returns the integral value between x and 0, nearest x.<br>
<b>anint(x)</b> returns the nearest integral value to x, except halfway cases are
rounded to the integral value larger in magnitude.<br>
<b>nint(x)</b> converts x into int format rounding to the nearest int value, except
halfway cases are rounded to the int value larger in magnitude.</p>
<p><b>Does anyone have an implementation of these in C#?</b>
It might be tricky getting it right.</p>
<p>(int)x appears to match aint()<br>
Convert.ToInt32(x) does not match any of the above.<br>
Trunc(x) does not match any of the above.<br>
Round(x) might match anint or nint. <br></p>
<p>The difference between anint and nint seems to be the return type, where anint returns a double precision value but nint returns an integer. Both are used (acutal sample):<br>
DOUBLE PRECISION A, B, C, D, E, F, G<br>
... values set here ...<br>
F = ANINT(A-B) + ANINT(C-D) + ANINT(B+D-E)<br>
G = NINT(F) + 1D0;<br>
Perhaps a FORTRAN expert could help clarify why the author chose to use both (I am assuming it was intentional).</p>
| [
{
"answer_id": 247171,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 3,
"selected": true,
"text": "nint"
},
{
"answer_id": 247185,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "htt... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10722/"
] |
247,149 | <pre><code><?php
/**
* My codebase is littered with the same conditionals over and over
* again. I'm trying to refactor using inheritance and the Factory
* pattern and I've had some success but I'm now stuck.
*
* I'm stuck because I want to derive a new class from the one
* returned by the Factory. But I can't do that, so I'm obviously
* doing something wrong somewhere else.
*/
/**
* The old implementation was as follows. There's if statements
* everywhere throughout both LayoutView and ItemIndexView and
* SomeOtherView.
*/
class LayoutView { }
class IndexView extends LayoutView { }
class SomeOtherView extends LayoutView { }
/**
* Below is the new implementation. So far I've managed to tidy
* up LayoutView (I think I have anyway). But now I'm stuck because
* the way I've tidied it up has left me not knowing how to extend
* it.
*
* For example's sake, let's say the conditions were relating to a
* type of fish: salmon or tuna.
*/
abstract class LayoutView {
protected function prepareHeader() { echo __METHOD__, "\n"; }
protected function prepareLeftHandSide() { echo __METHOD__, "\n"; }
protected function prepareFooter() { echo __METHOD__, "\n"; }
public function prepare() {
$this->prepareHeader();
$this->prepareLeftHandSide();
$this->prepareFooter();
}
}
class SalmonLayoutView extends LayoutView
{
protected function prepareLeftHandSide() { echo __METHOD__, "\n"; }
}
class TunaLayoutView extends LayoutView
{
protected function prepareLeftHandSide() { echo __METHOD__, "\n"; }
protected function prepareFooter() { echo __METHOD__, "\n"; }
}
class ViewFactory {
public static function getLayoutView($fishType) {
switch($this->$fishType) {
case 'salmon':
return new SalmonLayoutView();
break;
case 'tuna':
return new TunaLayoutView();
break;
}
}
}
/**
* Now LayoutView has been cleaned up and the condition that was once
* scattered through every LayoutView method is now in one place.
*/
$view = ViewFactory::getLayoutView( Config::getOption('fishtype') );
$view->prepare();
/**
* Now here's where I'm stuck. I want to effectively extend whatever
* class $view is an instance of.
*
* The reason being, I wish to derive a view to show an index of
* articles within the appropriate *LayoutView. The IndexView code is
* the same for Salmon and Tuna.
*
* I can do something like this:
*/
class SalmonIndexView extends SalmonLayoutView { }
class TunaIndexView extends TunaLayoutView { }
/**
* But then I'll be writing the same IndexView code twice. What I'd
* like to do is something like this:
*/
$view = ViewFactory::getLayoutView( Config::getOption('fishtype') );
class IndexView extends get_class($view) { }
/**
* But I'm pretty certain that's not possible, and even if it was
* it seems very wrong.
*
* Can someone more experienced in refactoring and OO please let
* me know where I've gone wrong and suggest a clean way to solve
* this?
*/
</code></pre>
| [
{
"answer_id": 249602,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 0,
"selected": false,
"text": "class LayoutView {\n protected View $subview; //Potentially an array of views\n public function prepare() {\n ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,152 | <p>I have an app that is failing on the install. The vendor says I probably have ini_set() disabled. How can I check this?</p>
| [
{
"answer_id": 247224,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 0,
"selected": false,
"text": "<?php\n if(ini_set('error_reporting', 'ALL') === false)\n {\n // Perform failure handling logic\n ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,156 | <p>I'm having a disagreement with someone over how best to implement a simple method that takes an array of integers, and returns the highest integer (using C# 2.0).</p>
<p>Below are the two implementations - I have my own opinion of which is better, and why, but I'd appreciate any impartial opinions.</p>
<p><strong>Option A</strong></p>
<pre><code>public int GetLargestValue(int[] values)
{
try {
Array.Sort(values);
return values[values.Length - 1];
}
catch (Exception){ return -1;}
}
</code></pre>
<p><strong>Option B</strong></p>
<pre><code>public int GetLargestValue(int[] values)
{
if(values == null)
return -1;
if(values.Length < 1)
return -1;
int highestValue = values[0];
foreach(int value in values)
if(value > highestValue)
highestValue = value;
return highestValue;
}
</code></pre>
| [
{
"answer_id": 247176,
"author": "SharePoint Newbie",
"author_id": 21586,
"author_profile": "https://Stackoverflow.com/users/21586",
"pm_score": 3,
"selected": false,
"text": "O(N LogN)"
},
{
"answer_id": 247201,
"author": "JacquesB",
"author_id": 7488,
"author_profil... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,161 | <p>How can I transform a <code>String</code> value into an <code>InputStreamReader</code>?</p>
| [
{
"answer_id": 247184,
"author": "Guido",
"author_id": 12388,
"author_profile": "https://Stackoverflow.com/users/12388",
"pm_score": 9,
"selected": true,
"text": "InputStream is = new ByteArrayInputStream( myString.getBytes( charset ) );\n"
},
{
"answer_id": 247193,
"author":... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4038/"
] |
247,167 | <p>Looking for a bit of regex help.
I'd like to design an expression that matches a string with "<em>foo</em>" OR "<em>bar</em>", but not both "<em>foo</em>" AND "<em>bar</em>"</p>
<p>If I do something like...</p>
<pre><code>/((foo)|(bar))/
</code></pre>
<p>It'll match "<em>foobar</em>". Not what I'm looking for. So, how can I make regex match only when one term or the other is present?</p>
<p>Thanks!</p>
| [
{
"answer_id": 247177,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 4,
"selected": true,
"text": "(/foo/ and not /bar/) || (/bar/ and not /foo/)\n"
},
{
"answer_id": 247202,
"author": "Robert K",
"author_... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26001/"
] |
247,174 | <p>I'm working on a project that contains Thomas Brothers Map page and grid numbers. Is there a way to programatically convert from this map page to a latitude & longitude?</p>
<p>An Example would be for the intersection of the US101 & I405 freeways.</p>
<p>ThomasBrothers: 561-3G (page-grid)</p>
| [
{
"answer_id": 1371593,
"author": "chovy",
"author_id": 33522,
"author_profile": "https://Stackoverflow.com/users/33522",
"pm_score": 0,
"selected": false,
"text": "<Area>\"El Cajon\"</Area>\n<ThomasBrothers>\"1297 5E\"</ThomasBrothers>\n<TBXY>\"6481390:1827008\"</TBXY>\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25007/"
] |
247,204 | <p>We use Telerik's RadEditor for our content management system's WYSIWYG editor. We need the find & replace functionality that is in the WYSIWYG editor to also be in the HTML editor. The editor is pretty customizable, anyone know if there is a way to enable this or hack it in?</p>
| [
{
"answer_id": 247238,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 0,
"selected": false,
"text": "... \n<telerik:EditorSeparator />\n<telerik:editortool name=\"FindAndReplace\" />\n<telerik:editortool name=\"TableWizard\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1208/"
] |
247,209 | <p>As JavaScript frameworks like jQuery make client side web applications richer and more functional, I've started to notice one problem...</p>
<p><strong>How in the world do you keep this organized?</strong></p>
<ul>
<li>Put all your handlers in one spot and write functions for all the events?</li>
<li>Create function/classes to wrap all your functionality?</li>
<li>Write like crazy and just hope it works out for the best?</li>
<li>Give up and get a new career?</li>
</ul>
<p>I mention jQuery, but it's really any JavaScript code in general. I'm finding that as lines upon lines begin to pile up, it gets harder to manage the script files or find what you are looking for. Quite possibly the biggest propblems I've found is there are so many ways to do the same thing, it's hard to know which one is the current commonly accepted best practice.</p>
<p>Are there any general recommendations on the best way to keep your <strong>.js</strong> files as nice and neat as the rest of your application? Or is this just a matter of IDE? Is there a better option out there?</p>
<hr>
<p><strong>EDIT</strong></p>
<p>This question was intended to be more about code organization and not file organization. There has been some really good examples of merging files or splitting content around.</p>
<p>My question is: what is the current commonly accepted best practice way to organize your actual code? What is your way, or even a recommended way to interact with page elements and create reuseable code that doesn't conflict with each other?</p>
<p>Some people have listed <strong>namespaces</strong> which is a good idea. What are some other ways, more specifically dealing with elements on the page and keeping the code organized and neat?</p>
| [
{
"answer_id": 247256,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 0,
"selected": false,
"text": "Behaviour.register({ \n 'a.delete-post': function(element) {\n element.observe('click', function(event) {... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] |
247,228 | <p>How can I run a stored procedure from a CL program? RUNSQLSTM requires a source member, but I just want to build a command so users can pass in variables easily, so this won't work.</p>
| [
{
"answer_id": 251921,
"author": "Paul Morgan",
"author_id": 16322,
"author_profile": "https://Stackoverflow.com/users/16322",
"pm_score": 3,
"selected": false,
"text": "QZDFMDB2"
},
{
"answer_id": 9124306,
"author": "Mitch",
"author_id": 1186823,
"author_profile": "h... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,234 | <p>A quick search gives me <a href="http://www.tawbaware.com/wc.htm" rel="noreferrer">tawbaware wc</a>, but it does not accept stdout as input stream, meaning I can not use pipe within a <em>DOS</em> session.</p>
<p><em>Note:</em> </p>
<p>I can not install cygwin or use powershell (which would have allowed a '<code>|foreach-object {(get-content $_).count}</code>')</p>
<p><a href="http://unxutils.sourceforge.net" rel="noreferrer">unxutils</a> and and <a href="http://gnuwin32.sourceforge.net/" rel="noreferrer">gnuwin32</a> Packages might have this feature...</p>
| [
{
"answer_id": 4354472,
"author": "Dan S.",
"author_id": 399441,
"author_profile": "https://Stackoverflow.com/users/399441",
"pm_score": 3,
"selected": false,
"text": "find /c /v \"~any string that will never occur~\"\n"
},
{
"answer_id": 4820378,
"author": "jeff drake",
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6309/"
] |
247,241 | <p>What's the point in the standard pattern for event delegates in .net? I.e. the EventHandler predefined delegate? Why not just choose the most appropriate signature for the requirement?</p>
<p>Edit: And furthermore, is it necessary to slavishly follow Microsoft's example in all cases?</p>
| [
{
"answer_id": 247279,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": true,
"text": "sender"
},
{
"answer_id": 247477,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3856/"
] |
247,245 | <p>I have not had to mess with mailto links much. However I now need to add a link in the body of a mailto if it is possible. </p>
<p>Is there a way to add a link or to change the email opened to an html email vs a text email?</p>
<p>Something like:</p>
<pre><code><a href="mailto:test@test.test?body=The message's first paragraph.%0A%0aSecond paragraph.%0A%0AThird Paragraph.%0A%0ALink goes here">Link text goes here</a>
</code></pre>
| [
{
"answer_id": 247395,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 8,
"selected": true,
"text": "body"
},
{
"answer_id": 247794,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stac... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13341/"
] |
247,247 | <p>It seems like there is a lot of overhead involved in rapidly opening and closing sqlconnections. Should I persist a connection (one, per client, per database), or continue declaring a new sqlconnection object whenever I need one, and making sure I clean up after myself?</p>
<p>What have you done? What worked well and what worked poorly?</p>
| [
{
"answer_id": 247805,
"author": "Ian Boyd",
"author_id": 12597,
"author_profile": "https://Stackoverflow.com/users/12597",
"pm_score": 0,
"selected": false,
"text": "DbConnection conn = Database.GetConnection();\ntry\n{\n //do stuff with the connetion\n ...\n}\nfinally\n{\n Databa... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15769/"
] |
247,252 | <p>One of the "best practice" is accessing data via stored procedures. I understand why is this scenario good.
My motivation is split database and application logic ( the tables can me changed, if the behaviour of stored procedures are same ), defence for SQL injection ( users can not execute "select * from some_tables", they can only call stored procedures ), and security ( in stored procedure can be "anything" which secure, that user can not select/insert/update/delete data, which is not for them ).</p>
<p>What I don't know is how to access data with dynamic filters.</p>
<p>I'm using MSSQL 2005.</p>
<p>If I have table:</p>
<pre><code>CREATE TABLE tblProduct (
ProductID uniqueidentifier -- PK
, IDProductType uniqueidentifier -- FK to another table
, ProductName nvarchar(255) -- name of product
, ProductCode nvarchar(50) -- code of product for quick search
, Weight decimal(18,4)
, Volume decimal(18,4)
)
</code></pre>
<p>then I should create 4 stored procedures ( create / read / update / delete ).</p>
<p>The stored procedure for "create" is easy.</p>
<pre><code>CREATE PROC Insert_Product ( @ProductID uniqueidentifier, @IDProductType uniqueidentifier, ... etc ... ) AS BEGIN
INSERT INTO tblProduct ( ProductID, IDProductType, ... etc .. ) VALUES ( @ProductID, @IDProductType, ... etc ... )
END
</code></pre>
<p>The stored procedure for "delete" is easy too.</p>
<pre><code>CREATE PROC Delete_Product ( @ProductID uniqueidentifier, @IDProductType uniqueidentifier, ... etc ... ) AS BEGIN
DELETE tblProduct WHERE ProductID = @ProductID AND IDProductType = @IDProductType AND ... etc ...
END
</code></pre>
<p>The stored procedure for "update" is similar as for "delete", but I'm not sure this is the right way, how to do it. I think that updating all columns is not efficient.</p>
<pre><code>CREATE PROC Update_Product( @ProductID uniqueidentifier, @Original_ProductID uniqueidentifier, @IDProductType uniqueidentifier, @Original_IDProductType uniqueidentifier, ... etc ... ) AS BEGIN
UPDATE tblProduct SET ProductID = @ProductID, IDProductType = @IDProductType, ... etc ...
WHERE ProductID = @Original_ProductID AND IDProductType = @Original_IDProductType AND ... etc ...
END
</code></pre>
<p>And the last - stored procedure for "read" is littlebit mystery for me. How pass filter values for complex conditions? I have a few suggestion:</p>
<p>Using XML parameter for passing where condition:</p>
<pre><code>CREATE PROC Read_Product ( @WhereCondition XML ) AS BEGIN
DECLARE @SELECT nvarchar(4000)
SET @SELECT = 'SELECT ProductID, IDProductType, ProductName, ProductCode, Weight, Volume FROM tblProduct'
DECLARE @WHERE nvarchar(4000)
SET @WHERE = dbo.CreateSqlWherecondition( @WhereCondition ) --dbo.CreateSqlWherecondition is some function which returns text with WHERE condition from passed XML
DECLARE @LEN_SELECT int
SET @LEN_SELECT = LEN( @SELECT )
DECLARE @LEN_WHERE int
SET @LEN_WHERE = LEN( @WHERE )
DECLARE @LEN_TOTAL int
SET @LEN_TOTAL = @LEN_SELECT + @LEN_WHERE
IF @LEN_TOTAL > 4000 BEGIN
-- RAISE SOME CONCRETE ERROR, BECAUSE DYNAMIC SQL ACCEPTS MAX 4000 chars
END
DECLARE @SQL nvarchar(4000)
SET @SQL = @SELECT + @WHERE
EXEC sp_execsql @SQL
END
</code></pre>
<p>But, I think the limitation of "4000" characters for one query is ugly.</p>
<p>The next suggestion is using filter tables for every column. Insert filter values into the filter table and then call stored procedure with ID of filters:</p>
<pre><code>CREATE TABLE tblFilter (
PKID uniqueidentifier -- PK
, IDFilter uniqueidentifier -- identification of filter
, FilterType tinyint -- 0 = ignore, 1 = equals, 2 = not equals, 3 = greater than, etc ...
, BitValue bit , TinyIntValue tinyint , SmallIntValue smallint, IntValue int
, BigIntValue bigint, DecimalValue decimal(19,4), NVarCharValue nvarchar(4000)
, GuidValue uniqueidentifier, etc ... )
CREATE TABLE Read_Product ( @Filter_ProductID uniqueidentifier, @Filter_IDProductType uniqueidentifier, @Filter_ProductName uniqueidentifier, ... etc ... ) AS BEGIN
SELECT ProductID, IDProductType, ProductName, ProductCode, Weight, Volume
FROM tblProduct
WHERE ( @Filter_ProductID IS NULL
OR ( ( ProductID IN ( SELECT GuidValue FROM tblFilter WHERE IDFilter = @Filter_ProductID AND FilterType = 1 ) AND NOT ( ProductID IN ( SELECT GuidValue FROM tblFilter WHERE IDFilter = @Filter_ProductID AND FilterType = 2 ) )
AND ( @Filter_IDProductType IS NULL
OR ( ( IDProductType IN ( SELECT GuidValue FROM tblFilter WHERE IDFilter = @Filter_IDProductType AND FilterType = 1 ) AND NOT ( IDProductType IN ( SELECT GuidValue FROM tblFilter WHERE IDFilter = @Filter_IDProductType AND FilterType = 2 ) )
AND ( @Filter_ProductName IS NULL OR ( ... etc ... ) )
END
</code></pre>
<p>But this suggestion is littlebit complicated I think.</p>
<p>Is there some "best practice" to do this type of stored procedures?</p>
| [
{
"answer_id": 247440,
"author": "Mauro",
"author_id": 2208,
"author_profile": "https://Stackoverflow.com/users/2208",
"pm_score": 2,
"selected": false,
"text": "Create sp_ProductSelect\n(\n @ProductID int = null,\n @IDProductType int = null,\n @ProductName varchar(50) = null,\n @Product... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20382/"
] |
247,257 | <p>I am admin on a forum.
Earlier we had phpbb 2.0 and i made a bot that could write to the forum.
Now, we have upgraded the forum to phpbb 3.0, but i can't get my bot to write to the forum anymore.</p>
<p>I have looked for a solution, but now i am out of ideas.
So it would have been great if anyone have a suggestion.</p>
<p>i have btw used CURL and php to make this bot.</p>
<p>Usage of bot:
Users log in on an external website to report results of footballmatches they have played online. The bot will then automatically write a post to the forum.</p>
<p>So basically i need to know what $_POST[] i need to send.</p>
| [
{
"answer_id": 247281,
"author": "Philip Morton",
"author_id": 21709,
"author_profile": "https://Stackoverflow.com/users/21709",
"pm_score": 2,
"selected": false,
"text": "input"
},
{
"answer_id": 2472276,
"author": "Andrew Moore",
"author_id": 26210,
"author_profile"... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24872/"
] |
247,269 | <p>If I invoke a method which does something illegal, the debugger will stop at the line of code, in that method, which threw the exception</p>
<p>If I use reflection to call a method via Invoke and that method throws an exception, the debugger stops on line where the method was called via reflection and not in the faulty method itself </p>
<p>How do I change this, and have the debugger stop on the line of code in error in regardless of how the method was invoked?</p>
<p>The code is built in Debug</p>
| [
{
"answer_id": 247289,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 1,
"selected": false,
"text": "public class MyClass {\n private string GetSomeText() { return DateTime.Now.ToString(); }\n}\n"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
247,284 | <p>I have a form I am submitting using jQuery's ajaxSubmit function from the Forms plugin. I'm trying to add a form name/value pair to the form data just before submission occurs. My plan is to modify the form data in the beforeSubmit event handler.</p>
<p>Given a function that looks like:</p>
<pre><code>function handleActionFormBeforeSubmit(formData, form, options) {
// Add a name/value pair here somehow to formData
}
</code></pre>
<p>How do I add a simple pair to formData? It is an array in the form of:</p>
<pre><code>[ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
</code></pre>
<p>Thanks,
Brian</p>
| [
{
"answer_id": 247776,
"author": "Brian Vallelunga",
"author_id": 2656,
"author_profile": "https://Stackoverflow.com/users/2656",
"pm_score": 5,
"selected": true,
"text": "function handleActionFormBeforeSubmit(formData, form, options) {\n\n // Add a name/value pair indicating this is ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2656/"
] |
247,304 | <p>I'm not sure how password hashing works (will be implementing it later), but need to create database schema now.</p>
<p>I'm thinking of limiting passwords to 4-20 characters, but as I understand after encrypting hash string will be of different length.</p>
<p>So, how to store these passwords in the database?</p>
| [
{
"answer_id": 247348,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 4,
"selected": false,
"text": "CHAR"
},
{
"answer_id": 247379,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "ht... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28098/"
] |
247,305 | <p>I am using the jQuery tableSorter plugin on a page.</p>
<p>Unfortunatley, the table that is being sorted is dynamically modified, and when I sort after adding an element, the element disappears, restoring the table to the state that it was in when the tableSorter was created.</p>
<p>Is there any way that i can force tableSorter to rescan the page so that these new elements are sorted properly?</p>
| [
{
"answer_id": 247319,
"author": "Josh",
"author_id": 2204759,
"author_profile": "https://Stackoverflow.com/users/2204759",
"pm_score": 6,
"selected": true,
"text": "$(table).trigger(\"update\")\n"
},
{
"answer_id": 11052245,
"author": "Devaroop",
"author_id": 909297,
... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32392/"
] |
247,313 | <p>If I had a phone number like this </p>
<pre><code>string phone = "6365555796";
</code></pre>
<p>Which I store with only numeric characters in my database <strong>(as a string)</strong>, is it possible to output the number like this: </p>
<pre><code>"636-555-5796"
</code></pre>
<p>Similar to how I could if I were using a number: </p>
<pre><code>long phone = 6365555796;
string output = phone.ToString("000-000-0000");
</code></pre>
<p>I've tried searching and all I could find online were numeric formatting documents.</p>
<p>The reason I ask is because I think it would be an interesting idea to be able to store only the numeric values in the DB and allow for different formatting using a Constant string value to dictate how my phone numbers are formatted. Or am I better off using a number for this?</p>
<p>EDIT: The question is to format a string that contains numbers, not a number itself.</p>
| [
{
"answer_id": 247332,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 1,
"selected": false,
"text": "string phoneText = \"6365555796\";\nlong phoneNum = long.Parse(phoneText);\nstring output = phoneNum.ToString(\"000-... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
247,317 | <p>I am trying to use MS access to connect to a Oracle database.
I keep on getting the following error message:</p>
<p>ORA-12154: TSN- could not resolve the connect identifier secified</p>
<p>The Oracle Drivers OracleClient10g can verify that the database server exists.</p>
<p>I have a section in my tsnnames.ora file that looks like this:
UBASEP10G =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = bxxx-xxx.yyyy.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = UBASE)
)
)</p>
<p>per my attempts to get this error resolves I added this to the sqlnet.ora file:</p>
<p>NAMES.DIRECTORY_PATH= (HOSTNAME, ONAMES, TNSNAMES,LDAP,EZCONNECT)</p>
<p>When using the Windows ODBC driver configuration utility it asks for the following
following information
DATA SOURCE NAME : MYSOURCE NAME
TSN SERVICE NAME:UBASEP10G
USERID:MYUSERID</p>
<p>any suggestions ?????</p>
| [
{
"answer_id": 247459,
"author": "DCookie",
"author_id": 8670,
"author_profile": "https://Stackoverflow.com/users/8670",
"pm_score": 0,
"selected": false,
"text": "(SID_DESC =\n (GLOBAL_DBNAME = THESERVICE)\n (ORACLE_HOME = d:\\oracle\\10.2.0_DB)\n (SID_NAME = SID1)\n"
},
{
"a... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26883/"
] |
247,318 | <p>Calling addChild with an empty string as the value (or even with whitespace) seems to cause a redundant SimpleXml node to be added inside the node instead of adding just the node with no value.</p>
<p>Here's a quick demo of what happens:</p>
<pre><code>[description] => !4jh5jh1uio4jh5ij14j34io5j!
</code></pre>
<p>And here's with an empty string:</p>
<pre><code>[description] => SimpleXMLElement Object ( [0] => )
</code></pre>
<p>The workaround I'm using at the moment is pretty horrible - I'm doing a str_replace on the final JSON to replace !4jh5jh1uio4jh5ij14j34io5j! with an empty string. Yuck. Perhaps the only answer at this point is 'submit a bug report to simplexml'...</p>
<p>Does anyone have a better solution?</p>
| [
{
"answer_id": 258352,
"author": "joelhardi",
"author_id": 11438,
"author_profile": "https://Stackoverflow.com/users/11438",
"pm_score": 1,
"selected": false,
"text": "$xml = new SimpleXMLElement('<xml></xml>');\n$xml->addChild('node','value');\nprint_r($xml);\n\n$xml = new SimpleXMLElem... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32300/"
] |
247,329 | <p>Unfortunately on my project, we generate a lot of the HTML code in JavaScript like this:</p>
<pre><code>var html = new StringBuffer();
html.append("<td class=\"gr-my-deals\"><a href=\"").append(deal.url).append("\" target=\"_blank\">").append(deal.description).append("</a></td>");
</code></pre>
<p>I have 2 specific complaints about this:</p>
<ol>
<li>The use of escaped double quotes (\”) within the HTML string. These should be replaced by single quotes (‘) to improve readability.</li>
<li>The use of .append() instead of the JavaScript string concatentation operator “+”</li>
</ol>
<p>Applying both of these suggestions, produces the following equivalent line of code, which I consider to be much more readable:</p>
<pre><code>var html = "<td class=’gr-my-deals’><a href=’" + deal.url + "’ target=’_blank’>" + deal.description + "</a></td>";
</code></pre>
<p>I'm now looking for a way to automatically transform the first line of code into the second. All I've come up with so far is to run the following find and replace over all our Javascript code:</p>
<pre><code>Find: ).append(
Replace: +
</code></pre>
<p>This will convert the line of code shown above to:</p>
<pre><code>html.append("<td class=\"gr-my-deals\"><a href=\"" + deal.url + "\" target=\"_blank\">" + deal.description + "</a></td>)";
</code></pre>
<p>This should safely remove all but the first 'append()' statement. Unfortunately, I can't think of any safe way to automatically convert the escaped double-quotes to single quotes. Bear in mind that I can't simply do a find/replace because in some cases you actually do need to use escaped double-quotes. Typically, this is when you're generating HTML that includes nested JS, and that JS contains string parameters, e.g.</p>
<pre><code>function makeLink(stringParam) {
var sb = new StringBuffer();
sb.append("<a href=\"JavaScript:myFunc('" + stringParam + "');\">");
}
</code></pre>
<p>My questions (finally) are:</p>
<ul>
<li>Is there a better way to safely replace the calls to 'append()' with '+'</li>
<li>Is there any way to safely replace the escaped double quotes with single quotes, regex?</li>
</ul>
<p>Cheers,
Don</p>
| [
{
"answer_id": 247383,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 2,
"selected": false,
"text": "function stringFormat( str ) {\n\n for( i = 0; i < arguments.length; i++ ) {\n var r = new RegExp( '\\\\{' + ( i ) + '... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] |
247,331 | <p>I'm using jQuery validate on a form I am building and it is working great. What I want to do is when something is invalid to have the text field change colors and the error message to be white. I figured the following CSS would work:</p>
<pre><code>label .error {color: white; font-weight: bold;}
input .error {background-color: pink; border: 1px dashed red; color: white}
</code></pre>
<p>When I test the validation the above CSS doesn't seem to apply. I checked using Firebug and the label and input area have the 'error' class applied.</p>
<p>The CSS seems valid as when I leave off the .error clause everything looks like I want it too. What am I doing wrong?</p>
| [
{
"answer_id": 247343,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "label.error {color: white; font-weight: bold;}\ninput.error {background-color: pink; border: 1px dashed red; color: white}\... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/204/"
] |
247,350 | <p>There's a lot of questions on here regarding various niche build needs (.NET, continuous integration, etc) but, of course, my niche need is different.</p>
<p>Rather than asking a very specific question right now, I'd like a survey of available build tools (such as make, ant, etc) so I can ask a follow up question more intelligently if needed.</p>
<p>In your answer, please include:</p>
<ul>
<li><strong>ONE</strong> build tool</li>
<li>Link to the main page about that tool</li>
<li>If you know some pros and cons (ie, runs on windows with cygwin, or .NET specific, etc) then list some (not required - the name and link are required)</li>
</ul>
<p>If your build tool is already in an answer, comment on it adding pros/cons/limitations/experiences. Feel free to add as many answers as you like as long as they don't already exist - but don't put several build tools into one answer.</p>
<p>Please be aware that if you duplicate answers you may be downvoted - add additional information about a given build in the comments. Ideally these comments will be incorporated into the answer over time.</p>
<p>-Adam</p>
| [
{
"answer_id": 790667,
"author": "Will Robertson",
"author_id": 4161,
"author_profile": "https://Stackoverflow.com/users/4161",
"pm_score": 2,
"selected": false,
"text": ":-)"
}
] | 2008/10/29 | [
"https://Stackoverflow.com/questions/247350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
247,369 | <p>I am attempting to allow my web designers to use the metadata we have about database fields in the asp.net pages they are creating. The most obvious one is as follows:</p>
<pre><code><asp:TextBox runat="server" id="txTextBox" MaxLength="<Value From Metadata here>" ... />
</code></pre>
<p>All the required metadata is stored in our class objects and is accessible due to its public static nature.</p>
<p>The benefit of this would be that they can set values which</p>
<p><strong>a)</strong> might change without them being aware or caring<br>
<strong>b)</strong> improve the user experience with very little coding effort</p>
<p>and all without having them need worry about what the value is or where it has come from. This will primarily be used for automatically bound controls - i.e. ones which are added with little or no developer interaction. </p>
<p>This question is very similar to <a href="https://stackoverflow.com/questions/232986/xaml-binding-textbox-maxlength-to-class-constant">One of my previous questions</a> which now works wonderfully (but that was in WPF / XAML ).</p>
<p>The main point of this question is that I want as little developer requirement on this as possible - Ideally there would be some <code><%# Constant.Value %></code> type syntax which could be used directly within the <code>Maxlength=""</code> attribute of the asp:Textbox control meaning that no code needs to be added to a page/usercontrol at all.</p>
<p>I have a feeling it isn't possible, but I would love someone to prove me wrong.</p>
<p>Ta</p>
| [
{
"answer_id": 247390,
"author": "Marcus King",
"author_id": 19840,
"author_profile": "https://Stackoverflow.com/users/19840",
"pm_score": 0,
"selected": false,
"text": "<asp:TextBox runat=\"server\" id=\"txTextBox\" MaxLength=\"<%=Constants.SomeValue%>\" />\n"
},
{
"answer_id": ... | 2008/10/29 | [
"https://Stackoverflow.com/questions/247369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31128/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.