qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
310,518 | <p>I'm digging into Reflection for the first time and I'm truely stuck. I've googled everything I can think of. I'm 90% where I wanna be now.</p>
<p>I'm trying to return the value of a Property in a custom class through Reflection.</p>
<p>Here's my class declaration:</p>
<pre><code>Public Class Class2
Private newPropertyValue2 As String
Public Property NewProperty2() As String
Get
Return newPropertyValue2
End Get
Set(ByVal value As String)
newPropertyValue2 = value
End Set
End Property
End Class
</code></pre>
<p>The class I've written to look at the class through reflection looks like this:</p>
<pre><code>Public Class ObjectCompare
Private _OriginalObject As PropertyInfo()
Public Property OriginalObject() As PropertyInfo()
Get
Return _OriginalObject
End Get
Set(ByVal value As PropertyInfo())
_OriginalObject = value
End Set
End Property
Public Sub CompareObjects()
Dim property_value As Object
For i As Integer = 0 To OriginalObject.Length - 1
If OriginalObject(i).GetIndexParameters().Length = 0 Then
Dim propInfo As PropertyInfo = OriginalObject(i)
Try
property_value = propInfo.GetValue(Me, Nothing)
Catch ex As TargetException
End Try
End If
Next
End Sub
End Class
</code></pre>
<p>I put a breakpoint on the property_value = propInfo.GetValue(Me, Nothing) line to see what the result is.</p>
<p>Here's how I call my code:</p>
<pre><code>Dim test As New Class2
test.NewProperty2 = "2"
Dim go As New ObjectCompare
Dim propInf As PropertyInfo()
propInf = test.GetType.GetProperties()
go.OriginalObject = propInf
go.CompareObjects()
</code></pre>
<p>Through reflection I can see the PropertyName and Type, all I need is the value of the Property! Now when I get to the breakpoint, I get a TargetException and the error message says "Object does not match target type." Its now 1AM in the morning and I'm wrecked, any help right now would be appreciated. I've searched MSDN and Google to death and then on last time for fun ;)</p>
| [
{
"answer_id": 310639,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 5,
"selected": true,
"text": "Me"
},
{
"answer_id": 310648,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://St... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38595/"
] |
310,540 | <p>Are there any good references for best practices for storing postal addresses in an RDBMS? It seems there are lots of tradeoffs that can be made and lots of pros and cons to each to be evaluated -- surely this has been done time and time again? Maybe someone has at least written done some lessons learned somewhere?</p>
<p>Examples of the tradeoffs I am talking about are storing the zipcode as an integer vs a char field, should house number be stored as a separate field or part of address line 1, should suite/apartment/etc numbers be normalized or just stored as a chunk of text in address line 2, how do you handle zip +4 (separate fields or one big field, integer vs text)? etc. </p>
<p>I'm primarily concerned with U.S. addresses at this point but I imagine there are some best practices in regards to preparing yourself for the eventuality of going global as well (e.g. naming fields appropriately like region instead of state or postal code instead of zip code, etc.</p>
| [
{
"answer_id": 310605,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 3,
"selected": false,
"text": "postal-code"
},
{
"answer_id": 14954313,
"author": "GWed",
"author_id": 1085343,
"author_profile": "h... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2168/"
] |
310,548 | <p>I have a thread that, when its function exits its loop (the exit is triggered by an event), it does some cleanup and then sets a different event to let a master thread know that it is done.</p>
<p>However, under some circumstances, SetEvent() seems not to return after it sets the thread's 'I'm done' event.</p>
<p>This thread is part of a DLL and the problem seems to occur after the DLL has been loaded/attached, the thread started, the thread ended and the DLL detached/unloaded a number of times without the application shutting down in between. The number of times this sequence has to be repeated before this problem happens is variable.</p>
<p>In case you are skeptical that I know what I'm talking about, I have determined what's happening by bracketing the SetEvent() call with calls to OutputDebugString(). The output before SetEvent() appears. Then, the waiting thread produces output that indicates that the Event has been set.</p>
<p>However, the second call to OutputDebugString() in the exiting thread (the one AFTER SetEvent() ) never occurs, or at least its string never shows up. If this happens, the application crashes a few moments later.</p>
<p>(Note that the calls to OutputDebugString() were added after the problem started occurring, so it's unlikely to be hanging there, rather than in SetEvent().)</p>
<p>I'm not entirely sure what causes the crash, but it occurs in the same thread in which SetEvent() didn't return immediately (I've been tracking/outputting the thread IDs). I suppose it's possible that SetEvent() is finally returning, by which point the context to which it is returning is gone/invalid, but what could cause such a delay?</p>
<p>It turns out that I've been blinded by looking at this code for so long, and it didn't even occur to me to check the return code. I'm done looking at it for today, so I'll know what it's returning (<em>if</em> it's returning) on Monday and I'll edit this question with that info then.</p>
<p>Update: I changed the (master) code to wait for the thread to exit rather than for it to set the event, and removed the SetEvent() call from the slave thread. This changed the nature of the bug: now, instead of failing to return from SetEvent(), it doesn't exit the thread at all and the whole thing hangs.</p>
<p>This indicates that the problem is not with SetEvent(), but something deeper. No idea what, yet, but it's good not to be chasing down that blind alley.</p>
<p>Update (Feb 13/09):<br>
It turned out that the problem was deeper than I thought when I asked this question. jdigital (and probably others) has pretty much nailed the underlying problem: we were trying to unload a thread as part of the process of detaching a DLL.</p>
<p>This, as I didn't realize at the time, but have since found out through research here and elsewhere (Raymond Chen's blog, for example), is a Very Bad Thing.</p>
<p>The problem was, because of the way it was coded and the way it was behaving, it not obvious that that was the underlying problem - it was camouflaged as all sorts of other Bad Behaviours that I had to wade through.</p>
<p>Some of the suggestions here helped me do that, so I'm grateful to everyone who contributed. Thank you!</p>
| [
{
"answer_id": 310585,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 2,
"selected": false,
"text": "HANDLE *"
},
{
"answer_id": 310860,
"author": "titanae",
"author_id": 2387,
"author_profile": "https://Stack... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35305/"
] |
310,551 | <p>Omnicompletion is working, but it automatically inserts the first result.</p>
<p>What I'd like to do is open the omnicomplete menu, then be able to type to narrow down the results, then hit enter or tab or space or something to insert the selected menu item.</p>
<p>Is this possible?</p>
| [
{
"answer_id": 310567,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 0,
"selected": false,
"text": ":he compl-current\n"
},
{
"answer_id": 311607,
"author": "orestis",
"author_id": 32617,
"author_pro... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1367022/"
] |
310,557 | <p>I am trying to declare and use a class B inside of a class A
and define B outside A.<br>
I know for a fact that this is possible because Bjarne Stroustrup<br>
uses this in his book "The C++ programming language"<br>
(page 293,for example the String and Srep classes).</p>
<p>So this is my minimal piece of code that causes problems</p>
<pre><code>class A{
struct B; // forward declaration
B* c;
A() { c->i; }
};
struct A::B {
/*
* we define struct B like this becuase it
* was first declared in the namespace A
*/
int i;
};
int main() {
}
</code></pre>
<p>This code gives the following compilation errors in g++ :</p>
<pre><code>tst.cpp: In constructor ‘A::A()’:
tst.cpp:5: error: invalid use of undefined type ‘struct A::B’
tst.cpp:3: error: forward declaration of ‘struct A::B’
</code></pre>
<p>I tried to look at the C++ Faq and the closeset I got was <a href="http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.12" rel="nofollow noreferrer">here</a> and <a href="http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.13" rel="nofollow noreferrer">here</a> but<br>
those don't apply to my situation.<br>
I also <a href="https://stackoverflow.com/questions/237064/c-nested-classes-driving-me-crazy">read this</a> from here but it's not solving my problem.</p>
<p>Both gcc and MSVC 2005 give compiler errors on this</p>
| [
{
"answer_id": 310562,
"author": "CB Bailey",
"author_id": 19563,
"author_profile": "https://Stackoverflow.com/users/19563",
"pm_score": 4,
"selected": false,
"text": "c->i"
},
{
"answer_id": 310578,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34051/"
] |
310,558 | <p>I have a RVDS project for a certain video decoder (its all C code),
created for ARM926EJ-S target, executed using the RVDS 2.2 simulator.
I am not using any scatterload / <configuration file> / <map file> to
mention the various memory segments in the code like Stack segment,
Heap, Data segment, Code Segment for RVDS Simulator environment.</p>
<ul>
<li>When I add or comment some code (redundant/dead code), then compile the project and execute it, the decoder exits gracefully after mentioning that an error condition has occured , which should not have been the case, as the commented/added code is redundant and does not affect the functionality at all.</li>
<li>Now if i do the operation opposite to that done in 1.) i.e. uncomment code that was commented in step 1.) and compile and execute, the decoder works perfectly fine till its logically end.</li>
<li>Same C source/header files work in a MSVC workspace just fine.</li>
</ul>
<p>I tried to debug a lot through this behaviour but i am not able to pinpoint the cause and the fix for it.</p>
<ul>
<li>Is it a case of stack corruption as i add/remove code?</li>
<li>Is any segment getting overwritten, like Stack segment overflowing into the Data segment, or code segment overflowing into the Data segment?</li>
</ul>
| [
{
"answer_id": 310562,
"author": "CB Bailey",
"author_id": 19563,
"author_profile": "https://Stackoverflow.com/users/19563",
"pm_score": 4,
"selected": false,
"text": "c->i"
},
{
"answer_id": 310578,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] |
310,561 | <p>I'm looking at the MySQL docs <a href="http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html" rel="noreferrer">here</a> and trying to sort out the distinction between FOREIGN KEYs and CONSTRAINTs. I thought an FK <strong>was</strong> a constraint, but the docs seem to talk about them like they're separate things.</p>
<p>The syntax for creating an FK is (in part)...</p>
<pre><code>[CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (index_col_name, ...)
REFERENCES tbl_name (index_col_name,...)
</code></pre>
<p>So the "CONSTRAINT" clause is optional. Why would you include it or not include it? If you leave it out does MySQL create a foreign key but not a constraint? Or is it more like a "CONSTRAINT" is nothing more than a name for you FK, so if you don't specify it you get an anonymous FK?</p>
<p>Any clarification would be greatly appreciated.</p>
<p>Thanks,</p>
<p>Ethan</p>
| [
{
"answer_id": 310586,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 7,
"selected": true,
"text": "PRIMARY KEY"
},
{
"answer_id": 34298305,
"author": "RxBx",
"author_id": 5683718,
"author_profile": ... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,572 | <p>Here's the goal: to replace all standalone ampersands with &amp; but NOT replace those that are already part of an HTML entity such as &nbsp;.</p>
<p>I think I need a regular expression for PHP (preferably for preg_ functions) that will match only standalone ampersands. I just don't know how to do that with preg_replace.</p>
| [
{
"answer_id": 310577,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 4,
"selected": true,
"text": "html_entity_decode"
},
{
"answer_id": 310632,
"author": "Doug Kaye",
"author_id": 17307,
"author_profile": "... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17307/"
] |
310,576 | <p>What win32 calls can be used to detect key press events globally (not just for 1 window, I'd like to get a message EVERY time a key is pressed), from a windows service?</p>
| [
{
"answer_id": 310602,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 4,
"selected": true,
"text": "LRESULT CALLBACK KeyboardProc( \n int code,\n WPARAM wParam,\n LPARAM lParam\n);\n"
},
{
"answer... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3886/"
] |
310,580 | <p>Is it possible to create a final route that catches all .. and bounces the user to a 404 view in ASP.NET MVC?</p>
<p>NOTE: I don't want to set this up in my IIS settings.</p>
| [
{
"answer_id": 310636,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile": "https://Stackoverflow.com/users/30674",
"pm_score": 7,
"selected": true,
"text": "routes.MapRoute(\n \"404-PageNotFound\",\n \"{*url}\",\n new { controller = \"StaticContent\", action = \"PageN... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
310,583 | <p>I'm sure there are different approaches to this problem, and I can think of some. But I'd like to hear other people's opinion on this. To be more specific I've built a widget that allows users to choose their location from a google maps map. This widget is displayed on demand and will probably be used every 1 out of 10 uses of the page where it's placed. The simplest way to load the dependency for this widget (google maps js api) is to place a script tag in the page. But this would make the browser request that script on every page load. I'm looking for a way to make the browser request that script only when the user requires for the widget to be displayed.</p>
| [
{
"answer_id": 310588,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": -1,
"selected": false,
"text": "<script src=\"...\">"
},
{
"answer_id": 310590,
"author": "FlySwat",
"author_id": 1965,
"author_profil... | 2008/11/21 | [
"https://Stackoverflow.com/questions/310583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] |
310,589 | <p>In our MOSS '07 site we have a page that contains just a Page Viewer web part in it that points to a site on another server. However, I've noticed that on that page (and any others that have a Page Viewer web part on it) our drop down menus and hover effects are <strong>super slow</strong> and completely max out the CPU on the visitor's computer (process is <strong>IExplorer</strong>.)</p>
<p>Through testing, I was able to determine that it doesn't matter what URL the web part is pointed to...just having the Iframe on the page seems to cause it (just setting the viewer to load Google's homepage--which is probably the simplest site I know--still causes the problem). If I go and remove the web part, the menus start functioning just fine again.</p>
<p>I attached a debugger to the process and stepped through the <code>Menu_HoverStatic</code> and called functions and it seems to have a hard time when assigning <code>panel.scrollTop</code> to zero in the <code>PopOut_Show</code> function.</p>
<p>Has anyone else noticed this? ...perhaps found a solution to it? I can't find where to edit <code>PopOut_Show</code> function on our server (I think it's a resource in one of the .NET DLLs) or else I'd just comment out that line as I don't think it's really important anyway...at least on our site.</p>
<p>I really like the ability to have web pages from another server hosted in our SharePoint site, but the performance on the hovers is agonizing... and, honestly, unacceptable. Depending on the resources of the user's computer, the hover effects can take 15 seconds to complete at times!!!!</p>
<p>Any suggestions would be really appreciated!</p>
| [
{
"answer_id": 310588,
"author": "miceuz",
"author_id": 24443,
"author_profile": "https://Stackoverflow.com/users/24443",
"pm_score": -1,
"selected": false,
"text": "<script src=\"...\">"
},
{
"answer_id": 310590,
"author": "FlySwat",
"author_id": 1965,
"author_profil... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30866/"
] |
310,595 | <p>I need to test if a file is a shortcut. I'm still trying to figure out how stuff will be set up, but I might only have it's path, I might only have the actual contents of the file (as a byte[]) or I might have both.</p>
<p>A few complications include that I it could be in a zip file (in this cases the path will be an internal path)</p>
| [
{
"answer_id": 310625,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 5,
"selected": true,
"text": "/// <summary>\n/// Returns whether the given path/file is a link\n/// </summary>\n/// <param name=\"shortcutFilename\">... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1343/"
] |
310,599 | <p>It's simple enough to code up a class to store/validate something like <code>192.168.0.0/16</code>, but I was curious if a native type for this already existed in .NET? I would imagine it would work a lot like <code>IPAddress</code>:</p>
<pre><code>CIDR subnet = CIDR.Parse("192.168.0.0/16");
</code></pre>
<p>Basically it just needs to make sure you're working with an IPv4 or IPv6 address and then that the number of bits your specifying is valid for that type.</p>
| [
{
"answer_id": 2239906,
"author": "Koen Zomers",
"author_id": 1271303,
"author_profile": "https://Stackoverflow.com/users/1271303",
"pm_score": 5,
"selected": false,
"text": "IPNetwork ipnetwork = IPNetwork.Parse(\"192.168.168.100/24\");\n\nConsole.WriteLine(\"Network : {0}\", ipnetwork.... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9642/"
] |
310,629 | <p>I need to write some methods for loading/saving some classes to and from a binary file. However I also want to be able to accept the binary data from other places, such as a binary string.</p>
<p>In c++ I could do this by simply making my class methods use std::istream and std::ostream which could be a file, a stringstream, the console, whatever.</p>
<p>Does python have a similar input/output class which can be made to represent almost any form of i/o, or at least files and memory?</p>
| [
{
"answer_id": 310635,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 4,
"selected": true,
"text": "from cStringIO import StringIO\n\ns = \"My very long string I want to read like a file\"\nfile_like_string = StringI... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] |
310,634 | <p>PHP, for all its warts, is pretty good on this count. There's no difference between an array and a hash (maybe I'm naive, but this seems obviously right to me), and to iterate through either you just do</p>
<pre><code>foreach (array/hash as $key => $value)
</code></pre>
<p>In Ruby there are a bunch of ways to do this sort of thing:</p>
<pre><code>array.length.times do |i|
end
array.each
array.each_index
for i in array
</code></pre>
<p>Hashes make more sense, since I just always use</p>
<pre><code>hash.each do |key, value|
</code></pre>
<p>Why can't I do this for arrays? If I want to remember just one method, I guess I can use <code>each_index</code> (since it makes both the index and value available), but it's annoying to have to do <code>array[index]</code> instead of just <code>value</code>.</p>
<hr>
<p>Oh right, I forgot about <code>array.each_with_index</code>. However, this one sucks because it goes <code>|value, key|</code> and <code>hash.each</code> goes <code>|key, value|</code>! Is this not insane?</p>
| [
{
"answer_id": 310638,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 10,
"selected": true,
"text": "array = [1, 2, 3, 4, 5, 6]\narray.each { |x| puts x }\n\n# Output:\n\n1\n2\n3\n4\n5\n6\n"
},
{
"answer_id": ... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25068/"
] |
310,642 | <p>I'm creating a list of the Slices in my Merb app, like this:</p>
<blockquote>
<p>Merb::Slices.each_slice do |slice|</p>
</blockquote>
<p>I'd like to get the list of dependencies for each of this slice, any idea how to access it?</p>
<p>I'm still reading merb code, solution might come soon ;)</p>
| [
{
"answer_id": 310671,
"author": "dylanfm",
"author_id": 38795,
"author_profile": "https://Stackoverflow.com/users/38795",
"pm_score": 0,
"selected": false,
"text": "/config/dependencies.rb"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16974/"
] |
310,650 | <p>I'm retrieving a gzipped web page via curl, but when I output the retrieved content to the browser I just get the raw gzipped data. How can I decode the data in PHP?</p>
<p>One method I found was to write the content to a tmp file and then ...</p>
<pre><code>$f = gzopen($filename,"r");
$content = gzread($filename,250000);
gzclose($f);
</code></pre>
<p>.... but man, there's got to be a better way.</p>
<p>Edit: This isn't a file, but a gzipped html page returned by a web server.</p>
| [
{
"answer_id": 2849331,
"author": "Jonas Lejon",
"author_id": 117283,
"author_profile": "https://Stackoverflow.com/users/117283",
"pm_score": 8,
"selected": true,
"text": "curl_setopt($ch, CURLOPT_ENCODING , \"gzip\");\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39539/"
] |
310,652 | <p>I am using the functions strpos(string, string) in javascript. In Firefox, Opera and IE the page loads fine, but in Chrome I get the error: Uncaught ReferenceError: strpos is not defined. The page I am working on is <a href="http://seniorproject.korykirk.com/0xpi2.php" rel="nofollow noreferrer">http://seniorproject.korykirk.com/0xpi2.php</a></p>
| [
{
"answer_id": 310665,
"author": "Artelius",
"author_id": 31945,
"author_profile": "https://Stackoverflow.com/users/31945",
"pm_score": 4,
"selected": false,
"text": "haystack.indexOf(needle)"
},
{
"answer_id": 3839607,
"author": "TRiG",
"author_id": 209139,
"author_p... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,664 | <p>I'm having some trouble with ASP.NET MVC Beta, and the idea of making routes, controller actions, parameters on those controller actions and Html.ActionLinks all work together. I have an application that I'm working on where I have a model object called a Plot, and a corresponding PlotController. When a user creates a new Plot object, a URL friendly name gets generated (<a href="https://stackoverflow.com/questions/37809/how-do-i-generate-a-friendly-url-in-c">i.e.</a>). I would then like to generate a "List" of the Plots that belong to the user, each of which would be a link that would navigate the user to a view of the details of that Plot. I want the URL for that link to look something like this: <a href="http://myapp.com/plot/my-plot-name" rel="nofollow noreferrer">http://myapp.com/plot/my-plot-name</a>. I've attempted to make that happen with the code below, but it doesn't seem to be working, and I can't seem to find any good samples that show how to make all of this work together.</p>
<p>My Route definition:</p>
<pre><code>routes.MapRoute( "PlotByName", "plot/{name}", new { controller = "Plot", action = "ViewDetails" } );
</code></pre>
<p>My ControllerAction:</p>
<pre><code>[Authorize]
public ActionResult ViewDetails( string plotName )
{
ViewData["SelectedPlot"] = from p in CurrentUser.Plots where p.UrlFriendlyName == plotName select p;
return View();
}
</code></pre>
<p>As for the ActionLink, I'm not really sure what that would look like to generate the appropriate URL.</p>
<p>Any assistance would be greatly appreciated.</p>
| [
{
"answer_id": 310709,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 2,
"selected": true,
"text": "<%= Html.ActionLink(\"Click Here\", \"ViewDetails\", \"Plot\", new { name=\"my-plot-name\" }, null)%>\n"
},
{
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18831/"
] |
310,669 | <p>Does anyone have any idea why the following code sample fails with an XmlException "Data at the root level is invalid. Line 1, position 1."</p>
<pre><code>var body = "<?xml version="1.0" encoding="utf-16"?><Report> ......"
XmlDocument bodyDoc = new XmlDocument();
bodyDoc.LoadXml(body);
</code></pre>
| [
{
"answer_id": 310708,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "MemoryStream stream = new MemoryStream();\n byte[] data = body.PayloadEncoding.GetBytes(body.Payload);\n ... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,685 | <p>Can someone explain the main benefits of different types of references in C#?</p>
<ul>
<li>Weak references</li>
<li>Soft references</li>
<li>Phantom references</li>
<li>Strong references.</li>
</ul>
<p>We have an application that is consuming a lot of memory and we are trying to determine if this is an area to focus on.</p>
| [
{
"answer_id": 21441743,
"author": "Artur A",
"author_id": 304371,
"author_profile": "https://Stackoverflow.com/users/304371",
"pm_score": 3,
"selected": false,
"text": "class BitmapWorkerTask extends AsyncTask<Integer, Void, Bitmap> {\n private final WeakReference<ImageView> imageVie... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
310,691 | <p>can anyone provide/refer a proper OO type helper class for managing a singleton of the SessionFactory and then also for managing Sessions?</p>
| [
{
"answer_id": 310824,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 2,
"selected": false,
"text": "public class BaseDataAccess\n{\n\n protected ISession m_session;\n\n public BaseDataAccess()\n {\n m_session ... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38574/"
] |
310,699 | <p>I'm using Emma in my ant build to perform coverage reporting. For those that have used Emma, is there a way to get the build to fail if the line coverage (or any type of coverage stat) does not meet a particular threshold? e.g. if the line coverage is not 100%</p>
| [
{
"answer_id": 310710,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 2,
"selected": true,
"text": "report.metrics"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30563/"
] |
310,700 | <p>Does anyone know what this means. Getting this in C# winforms applications:</p>
<blockquote>
<p>Not a legal OleAut date</p>
</blockquote>
| [
{
"answer_id": 362910,
"author": "lc.",
"author_id": 44853,
"author_profile": "https://Stackoverflow.com/users/44853",
"pm_score": 0,
"selected": false,
"text": "try\n{\n if (folderItem.ModifyDate.Year != 1899)\n {\n this.FileModifiedDate = folderItem.ModifyDate.ToShortDateS... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
310,714 | <p>On the PHP website, the only real checking they suggest is using <code>is_uploaded_file()</code> or <code>move_uploaded_file()</code>, <a href="http://ca.php.net/manual/en/features.file-upload.php" rel="noreferrer">here</a>. Of course you usually don't want user's uploading any type of file, for a variety of reasons.</p>
<p>Because of this, I have often used some "strict" mime type checking. Of course this is very flawed because often mime types are wrong and users can't upload their file. It is also very easy to fake and/or change. And along with all of that, each browser and OS deals with them differently.</p>
<p>Another method is to check the extension, which of course is even easier to change than mime type.</p>
<p>If you only want images, using something like <code>getimagesize()</code> will work.</p>
<p>What about other types of files? PDFs, Word documents or Excel files? Or even text only files?</p>
<p><strong>Edit:</strong> If you don't have <a href="http://php.net/manual/en/function.mime-content-type.php" rel="noreferrer">mime_content_type</a> or <a href="http://php.net/manual/en/function.finfo-file.php" rel="noreferrer">Fileinfo</a> and system("file -bi $uploadedfile") gives you the wrong file type, what other options are there?</p>
| [
{
"answer_id": 310740,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 6,
"selected": true,
"text": "system(\"file -bi $uploadedfile\")"
},
{
"answer_id": 370679,
"author": "Sudden Def",
"author_id": 28121,
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
310,720 | <p>I am using Maven (and the Maven Eclipse Integration) to manage the dependencies for my Java projects in Eclipse. The automatic download feature for JAR files from the Maven repositories is a real time saver. Unfortunately, it does not include API documentation and source code.</p>
<p>How can I set up Maven to automatically also get the source and javadoc attachments and register them properly with Eclipse?</p>
| [
{
"answer_id": 311229,
"author": "Stephen Denne",
"author_id": 11721,
"author_profile": "https://Stackoverflow.com/users/11721",
"pm_score": 7,
"selected": false,
"text": "mvn eclipse:eclipse -DdownloadSources=true\n"
},
{
"answer_id": 932681,
"author": "mrembisz",
"autho... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] |
310,729 | <p>For loading time considerations I am using a runtime css file in my Flex Application.</p>
<p>I am having a problem with a multi line text control :</p>
<pre><code><mx:Text id="txtDescription" selectable="false"
styleName="imageRolloverButtonTextDark" width="100%" textAlign="center"
text="{_rolloverText}"/>
</code></pre>
<p>When my CSS stylesheet has loaded the text style correctly changes, but the height is not recalculated. It appears to be just a single line field.</p>
<p>FYI: The control is not actually visible, and triggered by a rollover. So I dont really care if the stylesheet hasnt loaded and they get standard system text. I jsut want it to be the correct height when it has been loaded.</p>
| [
{
"answer_id": 1112649,
"author": "verveguy",
"author_id": 66753,
"author_profile": "https://Stackoverflow.com/users/66753",
"pm_score": 2,
"selected": false,
"text": "<mx:Canvas id=\"box\" width=\"100%\" backgroundColor=\"Red\">\n <mx:Text width=\"{box.width}\" text=\"{someReallyLong... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
310,732 | <p>Given a class:</p>
<pre><code>from django.db import models
class Person(models.Model):
name = models.CharField(max_length=20)
</code></pre>
<p>Is it possible, and if so how, to have a QuerySet that filters based on dynamic arguments? For example:</p>
<pre><code> # Instead of:
Person.objects.filter(name__startswith='B')
# ... and:
Person.objects.filter(name__endswith='B')
# ... is there some way, given:
filter_by = '{0}__{1}'.format('name', 'startswith')
filter_value = 'B'
# ... that you can run the equivalent of this?
Person.objects.filter(filter_by=filter_value)
# ... which will throw an exception, since `filter_by` is not
# an attribute of `Person`.
</code></pre>
| [
{
"answer_id": 310775,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": -1,
"selected": false,
"text": "'name'"
},
{
"answer_id": 310785,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "http... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] |
310,749 | <p>I'm having a problem with the WPF Tab View control that I was hoping someone here might be able to help me with.</p>
<p>I want my tab view control to use rounded corners for the tab headers, because I think rounded tabs look better.</p>
<p>To do this I modified the default control template for the tab by using the "Edit Copy" command in Expression Blend. I then just set the corner radius for the "border" of the tab header.</p>
<p>The problem with this approach, however, is that the "Edit Copy" command ends up generating literal color values for the gradient brushes used to display the "Active" and "Mouse Over" tab backgrounds.</p>
<p>This causes problems when "hi contrast" mode is enabled. Rather than switching to the hi contrast color scheme, like the other controls, the tab with the modified template will use the literal color values specified in the gradient brushes for the active and mouse-over tabs tabs. This ends up making those tabs unreadable, because the text on the tab header gets changed to "white" when the OS switches to hi contrast mode (white text on a gray background is unreadable).</p>
<p>I figured I might be able to switch back to square tabs when hi-contrast mode is enabled, That would fix this particular problem. However, I imagine there will be similar issues with users that have custom windows themes installed.</p>
<p>So, what I'm wondering is:</p>
<ol>
<li>Is there any way I can change the gradients to point to system resources rather than literal values so that the colors will be updated correctly when hi-contrast mode is enabled</li>
<li>Or, is there a way for me to set the corner radius on the border of the tab header without creating a new control template?</li>
</ol>
<p><strong>Edit:</strong></p>
<p>I think I should be a little more explicit about what I'm looking for.
I want a tab control that behaves exactly like the default tab control, except that the tab header corners are rounded. By default, a tab control will use gradients for the tab backgrounds and will "highlight" inactive tabs when the user mouses over them. It will also respond correctly and change it's colors and it's mouse over behavior when the OS switches to hi contrast mode. I still need this behavior.</p>
<p>Creating a copy of the default control template in Blend creates a control template that does not work correctly in hi contrast mode. I want to know what I need to do to the control template, or the code in my window, to get that generated control template to work correctly in hi-contrast mode.</p>
| [
{
"answer_id": 317965,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 2,
"selected": true,
"text": "Color=\"{DynamicResource {x:Static SystemColors.XXXX}\"\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737192/"
] |
310,753 | <p>Mac OS X stores some files with resource forks. I need to create a file with a resource fork. The trouble is, I need to create this file on the command line. Is anyone aware of how you can create a file with a resource fork on the command line in Mac OS X?</p>
| [
{
"answer_id": 310774,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 3,
"selected": false,
"text": "man Rez\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,770 | <p>This one is a bit tedious in as far as explaining, so here goes. I'm essentially populating a tableView on the iPhone with multiple sections, and potentially multiple rows per section. To my understanding, it's best to have an array of arrays so that you can simply determine how many sections one has by sending a message to the top level array of count, then for rows per section, doing the same for the inner array(s). My data is in the form of a dictionary. One of the key/value pairs in the dictionary determines where it will be displayed on the tableView. An example is the following:</p>
<pre><code>{
name: "bob",
location: 3
}
{
name: "jane",
location: 50
}
{
name: "chris",
location: 3
}
</code></pre>
<p>In this case I'd have an array with two subarrays. The first subarray would have two dictionaries containing bob and chris since they're both part of location 3. The second subarray would contain jane, since she is in location 50. What's my best bet in Cocoa populate this data structure? A hash table in C would probably do the trick, but I'd rather use the classes available in Cocoa.</p>
<p>Thanks and please let me know if I need to further clarify.</p>
| [
{
"answer_id": 310969,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 4,
"selected": true,
"text": "NSArray * arrayOfRecords = [NSArray arrayWithObjects:\n\n [NSDictionary dictionaryWithObjectsAndKeys:\n @\"bob\", @\... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,786 | <p>Does anyone know how to change the color of a row (or row background) in the UIPickerView control from the iPhone SDK? Similiar to the below title for row, however I would also like to change the color of the row:</p>
<pre><code>- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
</code></pre>
<p>Thank you.</p>
| [
{
"answer_id": 310863,
"author": "Sean",
"author_id": 29941,
"author_profile": "https://Stackoverflow.com/users/29941",
"pm_score": 4,
"selected": false,
"text": "- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UI... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29941/"
] |
310,787 | <p>I have an array (<code>arr</code>) of elements, and a function (<code>f</code>) that takes 2 elements and returns a number.</p>
<p>I need a permutation of the array, such that <code>f(arr[i], arr[i+1])</code> is as little as possible for each <code>i</code> in <code>arr</code>. (and it should loop, ie. it should also minimize <code>f(arr[arr.length - 1], arr[0])</code>)</p>
<p>Also, <code>f</code> works sort of like a distance, so <code>f(a,b) == f(b,a)</code></p>
<p>I don't need the optimum solution if it's too inefficient, but one that works reasonable well and is fast since I need to calculate them pretty much in realtime (I don't know what to length of <code>arr</code> is, but I think it could be something around 30)</p>
| [
{
"answer_id": 310811,
"author": "Purfideas",
"author_id": 4615,
"author_profile": "https://Stackoverflow.com/users/4615",
"pm_score": 0,
"selected": false,
"text": "g_i(p) = f(a^p[i], a^p[i+1]), and wrap around when i+1 > n\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1815/"
] |
310,801 | <p>When using a subdomain and trying to view anything related to current_user. user is sent to a new session page, the page shows the session is created and gives the option to logout. I can use no subdomain and it works fine.</p>
| [
{
"answer_id": 310830,
"author": "Kevin H",
"author_id": 20116,
"author_profile": "https://Stackoverflow.com/users/20116",
"pm_score": 1,
"selected": false,
"text": "ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update( :session_domain => '.domain.com')\n"
},
{
"answer_id... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,805 | <p>I've been knocking my head against this for some time now. I'm not really sure why it isn't working. I'm still pretty new to this whole WPF business. </p>
<p>Here's my XAML for the combobox</p>
<pre><code><ComboBox
SelectedValuePath="Type.FullName"
SelectedItem="{Binding Path=Type}"
Name="cmoBox" />
</code></pre>
<p>Here's what populates the ComboBox (myAssembly is a class I created with a list of possible types)</p>
<pre><code>cmoBox.ItemsSource = myAssembly.PossibleTypes;
</code></pre>
<p>I set the DataContext in a parent element of the ComboBox in the code behind like this:</p>
<pre><code>groupBox.DataContext = listBox.SelectedItem;
</code></pre>
<p>I want the binding to select the correct "possible type" from the combo box. It doesn't select anything. I have tried SelectedValue and SelectedItem. When I changed the DisplayMemberPath of the ComboBox to a different property it changed what was displayed so I know it's not completely broken. </p>
<p>Any ideas???</p>
| [
{
"answer_id": 310812,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 5,
"selected": true,
"text": "ItemsSource=\"{Binding}\""
},
{
"answer_id": 1866317,
"author": "TabbyCool",
"author_id": 226380,
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13688/"
] |
310,820 | <p>I want to do this in Actionscript:</p>
<pre><code>typeof(control1) != typeof(control2)
</code></pre>
<p>to test if two objects are of the same type. This would work just fine in C#, but in Actionscript it doesnt. In fact it returns <code>'object'</code> for both <code>typeof()</code> expressions because thats the way Actionscript works.</p>
<p>I couldn't seem to find an alternative by looking in the debugger, or on pages that describe <code>typeof()</code> in Actionscript.</p>
<p>Is there a way to get the actual runtime type?</p>
| [
{
"answer_id": 310879,
"author": "enobrev",
"author_id": 14651,
"author_profile": "https://Stackoverflow.com/users/14651",
"pm_score": 2,
"selected": false,
"text": " dynamic class A {}\n trace(A.prototype.constructor); // [class A]\n trace(A.prototype.constructor == A); // true\n... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
310,826 | <p>I am building a small device with its own CPU (AVR Mega8) that is supposed to connect to a PC. Assuming that the physical connection and passing of bytes has been accomplished, what would be the best protocol to use on top of those bytes? The computer needs to be able to set certain voltages on the device, and read back certain other voltages.</p>
<p>At the moment, I am thinking a completely host-driven synchronous protocol: computer send requests, the embedded CPU answers. Any other ideas?</p>
| [
{
"answer_id": 310848,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 3,
"selected": false,
"text": "Host --> [V02?] // Request voltage #2\nAVR --> [V02=2.34] // Reply with voltage #2\nHost --> [V06=3.12] // Se... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,833 | <p>In my views.py, i have a snippit of code like this:</p>
<pre><code>def clean_post_data(form):
for i in form.cleaned_data:
form.cleaned_data[i] = form.cleaned_data[i].rstrip()
def add_product(request):
form = ProductForm(request.POST, request.FILES or None)
image = Image.objects.all()
action = "Add"
if request.POST:
if form.is_valid():
clean_post_data(form)
form.save()
action = "Added new product"
return render_to_response('cms/admin/action.html', {'action' : action},context_instance=RequestContext(request))
else:
action = "There was an error. Please go back and try again"
return render_to_response('cms/admin/action.html', {'action' : action}, context_instance=RequestContext(request))
return render_to_response('cms/admin/editproduct.html', {'form' : form, 'action' : action, 'image' : image}, context_instance=RequestContext(request))
</code></pre>
<p>But when i run that, i get the following error <code>'list' object has no attribute 'rstrip'</code>. What am i doing wrong.</p>
<p>I originally had the <code>for i in form.cleaned_data:</code> loop directly in the view (not in another function) and it worked fine, but now when i try it i get the same error as above. <a href="http://dpaste.com/92836/" rel="nofollow noreferrer">http://dpaste.com/92836/</a></p>
| [
{
"answer_id": 311304,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": true,
"text": "clean_post_data"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310833",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2592/"
] |
310,870 | <p>What's the difference between</p>
<pre><code>var A = function () {
this.x = function () {
//do something
};
};
</code></pre>
<p>and</p>
<pre><code>var A = function () { };
A.prototype.x = function () {
//do something
};
</code></pre>
| [
{
"answer_id": 310895,
"author": "Matthew Crumley",
"author_id": 2214,
"author_profile": "https://Stackoverflow.com/users/2214",
"pm_score": 6,
"selected": false,
"text": "var A = function () {\n var private_var = ...;\n\n this.x = function () {\n return private_var;\n };... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39864/"
] |
310,888 | <p>Today I ran XtUnit at a part of my unit testing framework to to rollback database changes created while running a test case. This is a skeleton of how I have used it. The Test case ran successfully but the database state changed as a result. </p>
<pre><code>using NUnit.Framework;
using TeamAgile.ApplicationBlocks.Interception;
using TeamAgile.ApplicationBlocks.Interception.UnitTestExtensions;
namespace NameSpace.UnitTest
{
[TestFixture]
public class Test : InterceptableObject
{
[Test]
[DataRollBack]
public void CreateTest()
{
</code></pre>
<p>I use Nhibernate with Mysql. Am I missing something?</p>
| [
{
"answer_id": 354237,
"author": "Tom Lianza",
"author_id": 26624,
"author_profile": "https://Stackoverflow.com/users/26624",
"pm_score": 3,
"selected": true,
"text": "ExtensibleFixture"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22039/"
] |
310,889 | <p>I am taking my first foray into PHP programming and need to configure the environment for the first time. Can I use PHP with the built in VS web server or do I need to (and I hope not) use IIS locally?</p>
<p>In addition, any pointers on pitfalls to be avoided would be great.</p>
<p>Many thanks.</p>
<p><b>Update:</b> I should have made the question more explicit. I am developing a ASP.Net MVC application.</p>
<p><b>Update 2:</b> It's become clear that I haven't asked the question as cleanly as I would have liked. Here is what I am doing. I have an existing ASP.net MVC application that I am adding an e-mail form to. While researching, I came across this page: <a href="http://trevordavis.net/blog/tutorial/ajax-forms-with-jquery/" rel="nofollow noreferrer">Ajax Forms with jQuery</a> and I liked the interface he presented and thought I would try and adapt it. Calls are made to PHP functions and hence my question.</p>
<p>It is also clear that the confusion also could come from the fact that there is a better approach entirely. So, what is the way out of the maze, Alice?</p>
| [
{
"answer_id": 311491,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": true,
"text": "string mailTo = Request.Form[\"emailTo\"];\nstring mailFrom = Request.Form[\"emailFrom\"];\nstring subject = Request.Form[\... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13139/"
] |
310,911 | <p>Any good reason why $("p").html(0) makes all paragraphs empty as opposed to contain the character '0'?</p>
<p>Instead of assuming I found a bug in jQuery, it's probably a misunderstanding on my part.</p>
| [
{
"answer_id": 310918,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "if (newContent == false)"
},
{
"answer_id": 310920,
"author": "Eric Schoonover",
"author_id": 3957,
"autho... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
310,919 | <p>I've never liked wrapping the </p>
<pre><code>mysql_real_escape_string
</code></pre>
<p>function around input I expect to be integer for inclusion in a MySQL query.
Recently I came across the </p>
<pre><code>filter_var
</code></pre>
<p>function. Nice!</p>
<p>I'm currently using the code:</p>
<pre><code>if (isset($idUserIN)
&& filter_var($idUserIN, FILTER_VALIDATE_INT)
&& 0 < filter_var($idUserIN, FILTER_SANITIZE_NUMBER_INT)
) {
$idUser = filter_var($idUserIN, FILTER_SANITIZE_NUMBER_INT);
$sql = 'SELECT * FROM TABLE_NAME WHERE idUser = '.$idUser;
} else {
// handle invalid data
}
</code></pre>
<p>Does this leave any holes open?</p>
<p>('> 0' chosen rather than '>= 0' as its a table auto_increment field, so 0 would not be a normal value)</p>
| [
{
"answer_id": 310930,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 1,
"selected": false,
"text": "$sql = 'SELECT * FROM TABLE_NAME WHERE idUser = ' . intval($idUser);\n"
},
{
"answer_id": 310959,
"author": "K... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10648/"
] |
310,946 | <p>I want to send an email from my iPhone application. I have heard that the iOS SDK doesn't have an email API. I don't want to use the following code because it will exit my application:</p>
<pre><code>NSString *url = [NSString stringWithString: @"mailto:foo@example.com?cc=bar@example.com&subject=Greetings%20from%20Cupertino!&body=Wish%20you%20were%20here!"];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
</code></pre>
<p>So how can I send an email from my app?</p>
| [
{
"answer_id": 1513433,
"author": "PeyloW",
"author_id": 165059,
"author_profile": "https://Stackoverflow.com/users/165059",
"pm_score": 9,
"selected": false,
"text": "MFMailComposeViewController"
},
{
"answer_id": 12525746,
"author": "Kannan Prasad",
"author_id": 591843,... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39599/"
] |
310,947 | <p>Accepting the possibility of extreme ridicule, I must admit that I really miss sun Teamware's filemerge tool. I have switched from solaris to red hat linux, and find myself regularly missing filemerge (not to be confused with the Apple tool of the same name), as well as the solaris version of pstack (which worked on core files just as well as pids). </p>
<p>Do any experts out there have any advice of consolation? Better merging tools that incorporate ancestry? A single-line way to view the call stack of a core file?</p>
<p>Please help!</p>
| [
{
"answer_id": 6963805,
"author": "alvinabad",
"author_id": 293593,
"author_profile": "https://Stackoverflow.com/users/293593",
"pm_score": 1,
"selected": false,
"text": "kdiff3 x.A.cpp x.C.cpp x.P.cpp -o x.M.cpp\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/310947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39870/"
] |
310,964 | <p>I'm learning functional programming, and have tried to solve a couple problems in a functional style. One thing I experienced, while dividing up my problem into functions, was it seemed I had two options: use several disparate functions with similar parameter lists, or using nested functions which, as closures, can simply refer to bindings in the parent function. </p>
<p>Though I ended up going with the second approach, because it made function calls smaller and it seemed to "feel" better, from my reading it seems like I may be missing one of the main points of functional programming, in that this seems "side-effecty"? Now granted, these nested functions cannot modify the outer bindings, as the language I was using prevents that, but if you look at each individual inner function, you can't say "given the same parameters, this function will return the same results" because they do use the variables from the parent scope... am I right? </p>
<p>What is the desirable way to proceed? </p>
<p>Thanks!</p>
| [
{
"answer_id": 310971,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 2,
"selected": false,
"text": "(define (foo a)\n (define (bar b)\n (+ a b)) ; getting a from outer scope, not purely functional\n (bar 3))\n\n(... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38803/"
] |
310,974 | <p>Very simply, what is tail-call optimization?</p>
<p>More specifically, what are some small code snippets where it could be applied, and where not, with an explanation of why?</p>
| [
{
"answer_id": 310980,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 11,
"selected": true,
"text": "(define (fact x)\n (if (= x 0) 1\n (* x (fact (- x 1)))))\n\n(define (fact x)\n (define (fact-tail x accum)\n (i... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38812/"
] |
310,981 | <p>I am working on lock free structure with g++ compiler. It seems that with -o1 switch, g++ will change the execution order of my code. How can I forbid g++'s optimization on certain part of my code while maintain the optimization to other part? I know I can split it to two files and link them, but it looks ugly.</p>
| [
{
"answer_id": 310980,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 11,
"selected": true,
"text": "(define (fact x)\n (if (= x 0) 1\n (* x (fact (- x 1)))))\n\n(define (fact x)\n (define (fact-tail x accum)\n (i... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
310,996 | <p>I am calling a batch file from Javascript in this fashion:</p>
<pre><code>function runBatch(){
var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
exe.initWithPath("C:\\test.bat");
var run = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
run.init(exe);
var parameters = ["hi"];
run.run(false, parameters,parameters.length);
}
</code></pre>
<p>my test batch file is:</p>
<pre><code>echo on
echo %1
pause
exit
</code></pre>
<p>Each time I call a batch file, however, the command prompt is not displayed, as it would be if I simply ran the batch file from the desktop. How can I remedy this and display a command prompt for the batch file?</p>
<p><strong>Edit</strong>
To be clear, the cmd.exe process is launched - I can see it in the task bar. But no window gets displayed. This snippet behaves similarly:</p>
<pre><code>function runCmd(){
var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
exe.initWithPath("C:\\WINDOWS\\system32\\cmd.exe");
var run = Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
run.init(exe);
run.run(false, null,0);
}
</code></pre>
| [
{
"answer_id": 311940,
"author": "ng.mangine",
"author_id": 37784,
"author_profile": "https://Stackoverflow.com/users/37784",
"pm_score": 1,
"selected": false,
"text": "function runBatch(){\n var exe = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interface... | 2008/11/22 | [
"https://Stackoverflow.com/questions/310996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/525/"
] |
311,043 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/311054/how-do-i-select-last-5-rows-in-a-table-without-sorting">How do I select last 5 rows in a table without sorting?</a> </p>
</blockquote>
<p>I want to select the top 10 records from a table in SQL Server without arranging the table in ascending or descending order.</p>
| [
{
"answer_id": 311056,
"author": "smoothdeveloper",
"author_id": 17049,
"author_profile": "https://Stackoverflow.com/users/17049",
"pm_score": 4,
"selected": false,
"text": "select top 10 * from [tablename] order by newid()\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,050 | <p>I have a scrolling div with Three linkbuttons and three differents divs. I need to apply CSS to active linkbutton as soon as button is clicked.The codes used by me are:</p>
<pre><code>protected void btnNetwork_Click(object sender, EventArgs e)
{
this.btnForecast.CssClass = "li_1";
this.btnBlog.CssClass = "li_2";
this.btnNetwork.CssClass = "li_3_active";
this.btnNetwork.ForeColor = System.Drawing.Color.White;
lblMsg.Visible = false;
BindGW("-----------------------------------");
Forecast.Visible = false;
Blog.Visible = false;
Network.Visible = true;
}
</code></pre>
<p>Thanks & Regards,</p>
<p>Khushi</p>
| [
{
"answer_id": 311233,
"author": "Pradeep Kumar Mishra",
"author_id": 22710,
"author_profile": "https://Stackoverflow.com/users/22710",
"pm_score": 2,
"selected": false,
"text": "$get('btnId').setAttribute(\"class\", \"some_class_name\");\n"
},
{
"answer_id": 3167645,
"author... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39599/"
] |
311,051 | <p>I'm converting some Actionscript code from AS2 tp AS3, and I've eventually managed to get most of it to work again (it's allmost a totally different language, sharing just a little syntax similarity). One of the last things that still doesn't work, is the code for loading an external image.</p>
<p>Perhaps this has changed in AS3 but I really thought it was strange that to load an image you use <code>loadVideo</code>, why not loadImage? (on the other hand a flash application is constantly called a flash <em>video</em> even when it's not used for animation at all). This doesn't work anymore, and what I've found is a pretty complex code that is said to replace this oneliner <code>imageholder.loadVideo(url);</code> is this:</p>
<pre><code>var urlreq:URLRequest = new URLRequest(url);
var theloader:Loader = new URLLoader();
theloader.load(urlreq);
theloader.addEventListener(Event.COMPLETE, function(event:Event):void {
imageholder.addChild(theloader);
}
);
</code></pre>
<p>But this doesn't work.. What I am doing wrong, and is there a more suited function to load images in AS3?</p>
| [
{
"answer_id": 311157,
"author": "Stein G. Strindhaug",
"author_id": 26115,
"author_profile": "https://Stackoverflow.com/users/26115",
"pm_score": 0,
"selected": false,
"text": "for (i = 0; i<imgHolders.length; i++) {\n var loader:Loader = imgHolders[i].getChildByName(\"imgloader\"+i)... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26115/"
] |
311,052 | <p>I'm looking for a way to change the CSS rules for pseudo-class selectors (such as :link, :hover, etc.) from JavaScript.</p>
<p>So an analogue of the CSS code: <code>a:hover { color: red }</code> in JS.</p>
<p>I couldn't find the answer anywhere else; if anyone knows that this is something browsers do not support, that would be a helpful result as well.</p>
| [
{
"answer_id": 311437,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 8,
"selected": false,
"text": "#elid:hover { background: red; }\n"
},
{
"answer_id": 322240,
"author": "Nathaniel Reinhart",
"author_id":... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39882/"
] |
311,054 | <p>I want to select the last 5 records from a table in SQL Server without arranging the table in ascending or descending order.</p>
| [
{
"answer_id": 311059,
"author": "Stefan Mai",
"author_id": 13257,
"author_profile": "https://Stackoverflow.com/users/13257",
"pm_score": 2,
"selected": false,
"text": "SELECT TOP 5 * FROM [TableName]"
},
{
"answer_id": 311067,
"author": "Matt Hamilton",
"author_id": 615,... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,062 | <p>Which is the best method to make the browser use cached versions of js files (from the serverside)?</p>
| [
{
"answer_id": 311073,
"author": "Ken",
"author_id": 20074,
"author_profile": "https://Stackoverflow.com/users/20074",
"pm_score": 3,
"selected": false,
"text": "function OutputJs($Content) \n{ \n ob_start();\n echo $Content;\n $expires = DAY_IN_S; // 60 * 60 * 24 ... defined ... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] |
311,068 | <p>This is pretty trivial, but I noticed on SO that instead of an offset they are using page numbers. I know the difference is minor (multiply the page number by rows on a page or divide offset by rows on a page), but I'm wondering if one is recommended over the other.</p>
<p>Some sites, like Google, of course use a more complicated system because they need to track your actual search. But I'm thinking for a simple site where this doesn't matter.</p>
<p>What is the recommended technique?</p>
| [
{
"answer_id": 597684,
"author": "thomasrutter",
"author_id": 53212,
"author_profile": "https://Stackoverflow.com/users/53212",
"pm_score": 3,
"selected": false,
"text": "WHERE my_sortorder >= (some offset)\nLIMIT 10\n"
},
{
"answer_id": 45788241,
"author": "kbuilds",
"au... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
311,070 | <p>How to filter my datagridview by the value of my label.text on click event? That value is from my linq query:</p>
<pre><code>dataSet.Tables[0].AsEnumerable().Where(c => c.Field<int>("ageColumn") > 3 &&
c.Field<int>("ageColumn") < 5).Count();
</code></pre>
<p>Let's just say the above query gives me 12 (label.text = 12), now when I click "12", I want my datagridview to ONLY show those 12 rows that meet my above query.</p>
| [
{
"answer_id": 311139,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 0,
"selected": false,
"text": "dataSet.Tables[0].AsEnumerable().Where(c => c.Field<int>(\"ageColumn\") > 3 &&\n c.Field<int>(\"ageColumn\") < 5)\n"
},
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10385/"
] |
311,074 | <p>In my application I have a <code>Customer</code> class and an <code>Address</code> class. The <code>Customer</code> class has three instances of the <code>Address</code> class: <code>customerAddress</code>, <code>deliveryAddress</code>, <code>invoiceAddress</code>.</p>
<p><strong>Whats the best way to reflect this structure in a database?</strong></p>
<ul>
<li>The straightforward way would be a customer table and a separate address table. </li>
<li>A more denormalized way would be just a customer table with columns for every address (Example for "street": customer_street, delivery_street, invoice_street) </li>
</ul>
<p>What are your experiences with that? Are there any advantages and disadvantages of these approaches?</p>
| [
{
"answer_id": 311091,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 5,
"selected": true,
"text": "CREATE TABLE Customer\n(\n ID int not null IDENTITY(1,1) PRIMARY KEY,\n Name varchar(60) not null,\n customerA... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23368/"
] |
311,092 | <p>I am working on an app with an NSTextView. When I paste random bytes into it (say, from a compiled C program) it displays gibberish, as it should. However, when I -setShowsControlCharacters:YES, the same causes a crash and gives the following error multiple times:</p>
<p><code>2008-11-22 00:27:22.671 MyAppName[6119:10b] *** -[NSBigMutableString _getBlockStart:end:contentsEnd:forRange:stopAtLineSeparators:]: Range or index out of bounds</code></p>
<p>I created a new project with just an NSTextView with the same property and it does not have this problem.</p>
<p>My question is, how can I debug my app to find the cause of the error? I have no idea where the bug originates. I am not familiar with the debugger built in to Xcode. If anyone could point me in the right direction in terms of how to track down such a bug I would be very grateful. Thanks.</p>
| [
{
"answer_id": 312204,
"author": "Ashley Clark",
"author_id": 4556,
"author_profile": "https://Stackoverflow.com/users/4556",
"pm_score": 4,
"selected": true,
"text": "objc_exception_throw"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18091/"
] |
311,094 | <p>Some background: In Germany (at least) invoice numbers have to follow certain rules:</p>
<ol>
<li>The have to be ordered</li>
<li>They have to be continuous (may not have gaps)</li>
</ol>
<p>Since a few months they are allowed to contain characters. Some customers want to use that possibility and customers don't know that or are afraid and they insist on digit-only invoice numbers.</p>
<p>Additionally the customers don't want to start them at zero.</p>
<p>Is I can think of many ways to generate such a number I wonder: What's the best way to do this?</p>
| [
{
"answer_id": 311107,
"author": "Frode Lillerud",
"author_id": 33431,
"author_profile": "https://Stackoverflow.com/users/33431",
"pm_score": 4,
"selected": true,
"text": "static object _invoiceNumberLock = new object();\npublic static string GetInvoiceNumber()\n{\n lock(_invoiceNumbe... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23368/"
] |
311,102 | <p>For a system I need to convert a pointer to a long then the long back to the pointer type. As you can guess this is very unsafe. What I wanted to do is use dynamic_cast to do the conversion so if I mixed them I'll get a null pointer. This page says <a href="http://publib.boulder.ibm.com/infocenter/lnxpcomp/v7v91/index.jsp?topic=/com.ibm.vacpp7l.doc/language/ref/clrc05keyword_dynamic_cast.htm" rel="nofollow noreferrer">http://publib.boulder.ibm.com/infocenter/lnxpcomp/v7v91/index.jsp?topic=/com.ibm.vacpp7l.doc/language/ref/clrc05keyword_dynamic_cast.htm</a></p>
<blockquote>
<p>The dynamic_cast operator performs
type conversions at run time. The
dynamic_cast operator guarantees the
conversion of a pointer to a base
class to a pointer to a derived class,
or the conversion of an lvalue
referring to a base class to a
reference to a derived class. A
program can thereby use a class
hierarchy safely. This operator and
the typeid operator provide run-time
type information (RTTI) support in
C++.</p>
</blockquote>
<p>and I'd like to get an error if it's null so I wrote my own dynamic cast</p>
<pre><code>template<class T, class T2> T mydynamic_cast(T2 p)
{
assert(dynamic_cast<T>(p));
return reinterpret_cast<T>(p);
}
</code></pre>
<p>With MSVC I get the error "error C2681: 'long' : invalid expression type for dynamic_cast". It turns out this will only work with classes which have virtual functions... WTF! I know the point of a dynamic cast was for the up/down casting inheritance problem but I also thought it was to solve the type cast problem dynamically. I know I could use reinterpret_cast but that doesn't guarantee the same type of safety.</p>
<p>What should I use to check if my typecast are the same type? I could compare the two typeid but I would have a problem when I want to typecast a derived to its base. So how can I solve this?</p>
| [
{
"answer_id": 311106,
"author": "amit kumar",
"author_id": 19501,
"author_profile": "https://Stackoverflow.com/users/19501",
"pm_score": 2,
"selected": false,
"text": "dynamic_cast"
},
{
"answer_id": 311108,
"author": "Nicola Bonelli",
"author_id": 19630,
"author_pro... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,103 | <p>I need a map that has two keys, e.g.</p>
<pre><code>Map2<String /*ssn*/, String /*empId*/, Employee> _employees;
</code></pre>
<p>So that I can</p>
<pre><code>_employees.put(e.ssn(), e.empId(), e)
</code></pre>
<p>And later</p>
<pre><code>_employees.get1(someSsn);
_employees.get2(someImpId);
</code></pre>
<p>Or even</p>
<pre><code>_employees.remove1(someImpId);
</code></pre>
<p>I am not sure why I want to stop at two, why not more, probably because that's the case I am I need right now :-) But the type needs to handle fixed number of keys to be type-safe -- type parameters cannot be vararg :-)</p>
<p>Appreciate any pointers, or advice on why this is a bad idea.</p>
| [
{
"answer_id": 311110,
"author": "Stefan Mai",
"author_id": 13257,
"author_profile": "https://Stackoverflow.com/users/13257",
"pm_score": 2,
"selected": false,
"text": "Map< String, Map< String,Employee> > _employees;\n"
},
{
"answer_id": 311248,
"author": "Zach Scrivena",
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18573/"
] |
311,117 | <p>I need a type which can contain a position of an object in a 3D environment - my house.</p>
<p>I need to know the floor it is on, and the x and Y coordinates on that floor.</p>
<p>The System.Windows.Point(int, int) only represent a two-dimensional space, but does .NET have a type for three-dimensional space?</p>
<p>I realize that I could do something like</p>
<pre><code>List<int, Point<int, int>>
</code></pre>
<p>but I would like to have just a simple type instead. Something like:</p>
<pre><code>3DPoint<int, int, int>
</code></pre>
<p>Does the .NET Framework have this?</p>
| [
{
"answer_id": 311129,
"author": "Rune Grimstad",
"author_id": 30366,
"author_profile": "https://Stackoverflow.com/users/30366",
"pm_score": 3,
"selected": true,
"text": "public struct Vector3\n{\n public float x;\n public float y;\n public float z;\n} \n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33431/"
] |
311,131 | <p>I've written a WPF UserControl, and want to add one or more of it to my Window at runtime when I click a button. How can I do that?</p>
<p>Edit: Further specification
I want to add the usercontrols to a Canvas, and put in a absolute position. The canvas is a drawing of the floors in my house, and each usercontrol has properties to indicate where in the house it is positioned. So I want all the controls to be positioned in the correct position on the canvas.</p>
<p>I'm thinking something like this</p>
<pre><code>var light = new LightUserControl(2);
HouseCanvas.Children.Add(light); // this should be positioned in a specific place
</code></pre>
| [
{
"answer_id": 311136,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 2,
"selected": false,
"text": " _stackPanel.Children.Add(new YourControl()); \n"
},
{
"answer_id": 311815,
"author": "Ian Oakes",
"author... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33431/"
] |
311,154 | <p>I have a .fla file with some text that I want to get at. Is there a free app than you can use to open .fla files, or just a tool to dump strings and pics?</p>
| [
{
"answer_id": 311170,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 3,
"selected": false,
"text": "strings -n 10 \"D:\\Archives\\scrolling flash gallery with preloader.fla\" > str\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2942/"
] |
311,165 | <p>How can you convert a byte array to a hexadecimal string and vice versa?</p>
| [
{
"answer_id": 311179,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 12,
"selected": true,
"text": "Convert.ToHexString"
},
{
"answer_id": 311338,
"author": "Pure.Krome",
"author_id": 30674,
"author_pro... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19582/"
] |
311,166 | <p>When using the <a href="http://en.wikipedia.org/wiki/Pimpl_idiom" rel="nofollow noreferrer">pImpl idiom</a> is it preferable to use a <code>boost:shared_ptr</code> instead of a <code>std::auto_ptr</code>? I'm sure I once read that the boost version is more exception friendly?</p>
<pre><code>class Foo
{
public:
Foo();
private:
struct impl;
std::auto_ptr<impl> impl_;
};
class Foo
{
public:
Foo();
private:
struct impl;
boost::shared_ptr<impl> impl_;
};
</code></pre>
<p>[EDIT] Is it always safe to use std::auto_ptr<> or are there situations when an alternative boost smart pointer is required?</p>
| [
{
"answer_id": 311182,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 4,
"selected": false,
"text": "auto_ptr"
},
{
"answer_id": 311185,
"author": "kshahar",
"author_id": 33982,
"author_profile": "https:/... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311166",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] |
311,181 | <p>I'm looking for a open source .Net HTTP proxy library. Basically I want to develop something like Fiddler (so much lighter with less features).</p>
| [
{
"answer_id": 311200,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 1,
"selected": false,
"text": "RewriteRule ^(.*) http://www.testsiteXY.com$1 [P]\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,184 | <p>I'm using Oracle 10g and I'm trying to "stack" the conditions in a CASE statement, like I would do in C++ :</p>
<pre><code>case 1:
case 2:
// instructions
break;
</code></pre>
<p>i.e. having the same code block executed for two different successful conditions.</p>
<p>I've tried :</p>
<pre><code>WHEN 1, 2 THEN
WHEN 1 OR 2 THEN
</code></pre>
<p>... without luck.
Is it even possible ?</p>
<p><strong>EDIT</strong> - Full snippet</p>
<pre><code>CASE v_n
WHEN (1 OR 2) THEN
dbms_output.put_line('Case 1 or 2');
WHEN 3 THEN
dbms_output.put_line('Case 3');
END CASE;
</code></pre>
<p>Generates an <strong>expression is of wrong type</strong> error</p>
| [
{
"answer_id": 311208,
"author": "WW.",
"author_id": 14663,
"author_profile": "https://Stackoverflow.com/users/14663",
"pm_score": 6,
"selected": true,
"text": "CASE\n WHEN v_n = 1 OR v_n = 2 THEN\n dbms_output.put_line('Case 1 or 2');\n WHEN v_n = 3 THEN\n dbms_output.put_line('... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/77004/"
] |
311,188 | <p>I am using django 1.0 and I have created my models using the example in the Django book. I am able to perform the basic function of adding data; now I need a way of retrieving that data, loading it into a form (change_form?! or something), <b>EDIT</b> it and save it back to the DB. Secondly how do I <b>DELETE</b> the data that's in the DB? i.e. search, select and then delete!</p>
<p>Please show me an example of the code I need to write on my <code>view.py</code> and <code>urls.py</code> for perform this task.</p>
| [
{
"answer_id": 311191,
"author": "Vasil",
"author_id": 7883,
"author_profile": "https://Stackoverflow.com/users/7883",
"pm_score": 5,
"selected": false,
"text": "emp = Employee.objects.get(pk = emp_id)\nemp.name = 'Somename'\nemp.save()\n"
},
{
"answer_id": 57261909,
"author"... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20894/"
] |
311,193 | <p>I am migrating an application from .NET 1.1 to .NET 2.0. Should I remove all uses of CollectionBase? If so, what is the best strategy for migration?</p>
| [
{
"answer_id": 311195,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 6,
"selected": true,
"text": "public class MyClass\n{\n public List<MyItem> Items;\n}\n"
},
{
"answer_id": 311232,
"author": "krosenvold",
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
311,202 | <p>I'm looking for a production quality bloom filter implementation in Python to handle fairly large numbers of items (say 100M to 1B items with 0.01% false positive rate). </p>
<p><a href="http://www.imperialviolet.org/pybloom.html" rel="noreferrer">Pybloom</a> is one option but it seems to be showing its age as it throws DeprecationWarning errors on Python 2.5 on a regular basis. Joe Gregorio also has <a href="http://bitworking.org/news/380/bloom-filter-resources" rel="noreferrer">an implementation</a>. </p>
<p>Requirements are fast lookup performance and stability. I'm also open to creating Python interfaces to particularly good c/c++ implementations, or even to Jython if there's a good Java implementation.</p>
<p>Lacking that, any recommendations on a bit array / bit vector representation that can handle ~16E9 bits?</p>
| [
{
"answer_id": 311360,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "class Bit( object ):\n def __init__( self, size ):\n self.bits= array.array('B',[0 for i in range((size+7)//8)] )... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] |
311,206 | <p>I have these 2 vectors:</p>
<pre><code>alpha =
1 1 1 1 1 1 1 1 1
f_uv =
193 193 194 192 193 193 190 189 191
</code></pre>
<p>And when I do this:</p>
<pre><code>alphaf_uv = alpha * f_uv'
</code></pre>
<p>I get the error message:</p>
<pre><code>"??? Error using ==> mtimes
Integers can only be combined with integers of the same class, or scalar doubles."
</code></pre>
<p>The interesting part is that this error doesn't appear if I define the same vectors in the console and try the multiplication there.</p>
<p><code>alpha</code> is defined by me and <code>f_uv</code> is obtained from some pixels in a PNG image.</p>
| [
{
"answer_id": 311209,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 5,
"selected": true,
"text": "f_uv'"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38721/"
] |
311,221 | <p>If you had a 10 minute hands-on session to teach someone Emacs, what would you show them?</p>
<pre>
Start emacs: emacs
...
Quit emacs: C-x C-c
</pre>
<p>What else would you have them do between starting and quitting Emacs, while you stood behind them?</p>
| [
{
"answer_id": 311226,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 2,
"selected": false,
"text": "M-x"
},
{
"answer_id": 311239,
"author": "Miserable Variable",
"author_id": 18573,
"aut... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,242 | <p>I'm new to PHP and I'm trying to do something that may be bad practise and may well be impossible. I'm basically just hacking something together to test my knowledge and see what PHP can do.</p>
<p>I have one webpage with a form that collects data. That is submited to a PHP script that does a bunch of processing - but doesn't actually display anything important. What I want is that once the processing is done, the script then tells the browser to open another page, where the results are displayed. </p>
<p>I know I can use <em>header('Location: page.php');</em> but I can't work out how to provide POST data with this. How can I do that? Alternatively, is there another way to tell the browser to open another page?</p>
<p>EDIT: What I'm taking from the responses is that it's <em>possible</em> to do this using various hacks but I'd be better off to just have the processing and the display code in one file. I'm happy with that; this was an experiment more than anything.</p>
| [
{
"answer_id": 311269,
"author": "Tom Haigh",
"author_id": 22224,
"author_profile": "https://Stackoverflow.com/users/22224",
"pm_score": 4,
"selected": false,
"text": "session_start();\n$_SESSION['formdata'] = $_POST; //or whatever\n"
},
{
"answer_id": 311348,
"author": "Tom"... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39905/"
] |
311,243 | <p>I have a Java application and I would like to make it extensible. To create an extension, developers within our company will write a Java class that implements a certain interface. They may also wish to write associated helper classes. I would like to load these extensions into the application without an outage.</p>
<p>I would like to limit what this class can do to the following:</p>
<ol>
<li>Call methods in the application's API (this will be a parameter to the constructor)</li>
<li>Create instances of other objects within the same package (so the author of the extension class can use other classes to get the job done).</li>
</ol>
<p>When the class is invoked the API object that is passed in will already have a "customer" defined and stored as a member variable. It will use this to limit access via the API to that customer's data.</p>
<p>I do not want these classes doing things such as accessing the database, writing to disk, or otherwise doing things etc. This is mostly an effort at dependency management and encapsulation as the same team of developers will have access to write both extensions and the core system.</p>
<p>Is there a pattern for this? Am I on the right track?</p>
| [
{
"answer_id": 312001,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 4,
"selected": true,
"text": "grant codeBase \"file:/path/to/app/lib/*\" {\n permission java.io.FilePermission \"/path/to/app/-\", \"read\";\n permissio... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14663/"
] |
311,249 | <p>What are the hidden features of Maven2?</p>
| [
{
"answer_id": 311254,
"author": "Kuukage",
"author_id": 39907,
"author_profile": "https://Stackoverflow.com/users/39907",
"pm_score": 1,
"selected": false,
"text": "<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-dependency-plugin</artifactId>\n</plugin>\n... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39907/"
] |
311,250 | <p>Okay, I have a FormView with a couple of child controls in an InsertItemTemplate. One of them is a DropDownList, called DdlAssigned. I reference it in the Page's OnLoad method like so:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
((DropDownList)FrmAdd.FindControl("DdlAssigned")).SelectedValue =
((Guid)Membership.GetUser().ProviderUserKey).ToString();
}
</code></pre>
<p>Basically I'm just setting the default value of the DropDownList to the user currently logged in.</p>
<p>Anyway, when the page finishes loading the SelectedValue change isn't reflected on the page. I stepped through OnLoad and I can see the change reflected in my Watch list, but when all is said and done nothing's different on the page.</p>
| [
{
"answer_id": 312196,
"author": "Dusda",
"author_id": 36411,
"author_profile": "https://Stackoverflow.com/users/36411",
"pm_score": 3,
"selected": true,
"text": "protected void FrmAdd_DataBound(object sender, EventArgs e)\n{\n // This is the same code as before, but done in the FormV... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36411/"
] |
311,253 | <p>I have a .NET dll which needs to read it's config settings from it's config file. Usually, the config file is placed in the same directory as the DLL. But how do i read the config file if the DLL is GAC'ed, because I can put only the DLLs in the GAC, and not it's config files.</p>
| [
{
"answer_id": 311423,
"author": "netadictos",
"author_id": 31791,
"author_profile": "https://Stackoverflow.com/users/31791",
"pm_score": 4,
"selected": false,
"text": "System.Configuration.ExeConfigurationFileMap fileMap = new System.Configuration.ExeConfigurationFileMap();\nfileMap.Exe... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909/"
] |
311,268 | <p>In short: I want to monitor selected calls from an application to a DLL.</p>
<p>We have an old VB6 application for which we lost the source code (the company wasn't using source control back then..). This application uses a 3rd party DLL.</p>
<p>I want to use this DLL in a new C++ application. Unfortunately the DLL API is only partially documented, so I don't know how to call some functions. I do have the functions signature.</p>
<p>Since the VB6 application uses this DLL, I want to see how it calls several functions. So far I've tried or looked at -</p>
<ol>
<li><a href="http://www.codeproject.com/KB/DLL/apihijack.aspx" rel="noreferrer">APIHijack</a> - requires me to write C++ code for each function. Since I only need to log the values, it seems like an overkill.</li>
<li><a href="http://www.codeplex.com/easyhook" rel="noreferrer">EasyHook</a> - same as 1, but allows writing in the code in .NET language.</li>
<li><a href="http://www.ollydbg.de/" rel="noreferrer">OllyDbg</a> with <a href="http://oss.coresecurity.com/uhooker/doc/index.html" rel="noreferrer">uHooker</a> - I still have to write code for each function, this time in Python. Also, I have to do many conversions in Python using the <code>struct</code> module, since most functions pass values using pointers.</li>
</ol>
<p>Since I only need to log functions parameters I want a simple solution. Is there any automated tool, for which I could tell which functions to monitor and their signature, and then get a detailed log file?</p>
| [
{
"answer_id": 311349,
"author": "kshahar",
"author_id": 33982,
"author_profile": "https://Stackoverflow.com/users/33982",
"pm_score": 5,
"selected": true,
"text": "CustomApi.dll|void NameOfFunction(long param1, double& param2);\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33982/"
] |
311,274 | <p>If have a set of classes that all implement an interface. </p>
<pre><code>interface IMyinterface<T>
{
int foo(T Bar);
}
</code></pre>
<p>I want to shove them all in a list and enumerate through them. </p>
<pre><code> List<IMyinterface> list
foreach(IMyinterface in list)
// etc...
</code></pre>
<p>but the compiler wants to know what T is. Can I do this? How can I overcome this issue?</p>
| [
{
"answer_id": 311288,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 4,
"selected": true,
"text": "interface IMyinterface { ... }\n"
},
{
"answer_id": 311333,
"author": "KeesDijk",
"author_id": 6434,
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1116/"
] |
311,276 | <p>Just could not get this one and googling did not help much either.. </p>
<p>First something that I know: Given a string and a regex, how to replace all the occurrences of strings that matches this regular expression by a replacement string ? Use the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)" rel="nofollow noreferrer">replaceAll()</a> method in the String class.</p>
<p>Now something that I am unable to do. The regex I have in my code now is [^a-zA-Z] and I know for sure that this regex is definitely going to have a range. Only some more characters might be added to the list. What I <em>need</em> as output in the code below is <strong>Worksheet+blah</strong> but what I get using replaceAll() is <strong>Worksheet++++blah</strong></p>
<blockquote>
<pre><code>String homeworkTitle = "Worksheet%#5_blah";
String unwantedCharactersRegex = "[^a-zA-Z]";
String replacementString = "+";
homeworkTitle = homeworkTitle.replaceAll(unwantedCharactersRegex,replacementString);
System.out.println(homeworkTitle);
</code></pre>
</blockquote>
<p>What is the way to achieve the output that I wish for? Are there any Java methods that I am missing here? </p>
| [
{
"answer_id": 311286,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "[^a-zA-Z]+\n"
},
{
"answer_id": 311290,
"author": "The Archetypal Paul",
"author_id": 21755,
"author_profile... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27474/"
] |
311,297 | <p>I need a fast container with only two operations. Inserting keys on from a very sparse domain (all 32bit integers, and approx. 100 are set at a given time), and iterating over the inserted keys. It should deal with <em>a lot of</em> insertions which hit the same entries (like, 500k, but only 100 different ones).</p>
<p>Currently, I'm using a std::set (only insert and the iterating interface), which is decent, but still not fast enough. std::unordered_set was twice as slow, same for the Google Hash Maps. I wonder what data structure is optimized for this case?</p>
| [
{
"answer_id": 311396,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 2,
"selected": false,
"text": "array[hash(value)] = 1;"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39912/"
] |
311,299 | <p>I need to extract multiple text/dropdown list fields from an asp.net form and format appropriately ready for sending to recipient via email.</p>
<p>What's the best way of reading those fields without having to hard code each item such as: </p>
<pre><code>item1 = InputField1.Text;
item2 = InputField2.Text;
</code></pre>
<p>I will have about 10 or 20 items on the same input form.</p>
| [
{
"answer_id": 311312,
"author": "Chris",
"author_id": 34942,
"author_profile": "https://Stackoverflow.com/users/34942",
"pm_score": 0,
"selected": false,
"text": "foreach (string key in Request.Form.Keys) {\n string value = Request.Form[key];\n // format and use value here\n}\n"
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26809/"
] |
311,307 | <p>Is there an alternative to history.go(-1) for FireFox and Safari. Any Help would be greatly appreciated. </p>
| [
{
"answer_id": 311311,
"author": "Anteru",
"author_id": 39912,
"author_profile": "https://Stackoverflow.com/users/39912",
"pm_score": 4,
"selected": true,
"text": "history.back()"
},
{
"answer_id": 311319,
"author": "VonC",
"author_id": 6309,
"author_profile": "https:... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,332 | <p>I have an idea about what it is. My question is :-</p>
<p>1.) If i program my code which is amenable to Tail Call optimization(Last statement in a function[recursive function] being a function call only, no other operation there) then do i need to set any optimization level so that compiler does TCO. In what mode of optimization will compiler perform TCO, optimizer for space or time.</p>
<p>2.) How do i find out which all compilers (MSVC, gcc, ARM-RVCT) does support TCO</p>
<p>3.) Assuming some compiler does TCO, we enable it then, What is the way to find out that the compielr has actually done TCO? Will Code size, tell it or Cycles taken to execute it will tell that or both?</p>
<p>-AD</p>
| [
{
"answer_id": 311340,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 2,
"selected": false,
"text": "-foptimize-sibling-calls"
},
{
"answer_id": 313057,
"author": "orcmid",
"author_id": 33810,
"aut... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] |
311,346 | <p>Is there any reason to start a GUI program (application for Windows) written in VB.NET in the Sub Main of a module rather than directly in a form?</p>
<p>EDIT: The program won't take any command line parameters and it will be executed as a GUI program always.</p>
| [
{
"answer_id": 311352,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 2,
"selected": false,
"text": "Sub Main()\n If App.StartMode = vbSModeAutomation Then\n ...\n Else\n ...\n End If\nEnd Sub\n"
},
... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38561/"
] |
311,363 | <p>NDoc has an XML element <strong>inheritdoc</strong> which allows you to inherit documentation of a member from the parent class (or an implemented interface). However, Visual Studio (i.e. the C# compiler) does not understand this tag and complains about the documentation not being present or complete. So does StyleCop and some other tools. Is there an alternative approach? How do you go about keeping the docs complete, yet without duplicating the XML descriptions?</p>
| [
{
"answer_id": 1080418,
"author": "Alex Yakunin",
"author_id": 106042,
"author_profile": "https://Stackoverflow.com/users/106042",
"pm_score": 5,
"selected": false,
"text": "<see cref=\"Instance\" />"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15497/"
] |
311,389 | <p>I've created a login submit form in HTML but for some reason autocompletion does not work in firefox.</p>
<p>This is what happens in Firefox:
- I give username and password and click on the login button
- Firefox prompts me if I would like to remember the password. I press 'remember' and login works.
- I log out and return to the login page. I would expect the username and password field to be prefilled but that is not the case. Notice that I don't (want to) use cookies.</p>
<p>Here's the code for this page:</p>
<pre><code><form name="login_form" id="login_form" autocomplete="ON" onsubmit="javascript:xajax_action_login(document.getElementById('user_name').value, document.getElementById('password').value); return false;">
<div class="login_line">
<div class="login_line_left">name</div>
<div id="user_name_id" class="login_line_right"><input size="16" maxlength="16" name="user_name" id="user_name" type="text"></div>
</div> <!-- login_line -->
<div class="login_line">
<div class="login_line_left">password</div>
<div id="password_id" class="login_line_right"><input size="16" maxlength="16" name="password" id="password" type="password"></div>
</div> <!-- login_line -->
<div class="login_line">
<div class="login_line_left">&nbsp;</div>
<div class="login_line_right"><input class="button" value="login" type="submit"></div>
</div> <!-- login_line -->
</form> <!-- login_form -->
</code></pre>
<p>What is wrong with my code? How can I get autocompletion to work in FF with my code?</p>
<p>Autocompletion does work correct with for instance gmail. Each time I visit the login page of gmail, the email and password fields are correctly prefilled. I don't use the 'remember me on this computer' checkbox so no cookies are used.</p>
<p><strong>Update</strong> I'm using php and FF3</p>
<p>Thanks,
Jasper </p>
| [
{
"answer_id": 342520,
"author": "Már Örlygsson",
"author_id": 16271,
"author_profile": "https://Stackoverflow.com/users/16271",
"pm_score": 0,
"selected": false,
"text": "onsubmit=\"\""
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,399 | <p>Does anyone know where I can find an example of how to determine if the Maximize and/or Minimize buttons on a window are available and/or disabled?</p>
<p>The window will not be in the same process as my application. I have the hWnd and I have tried using GetMenuItemInfo, but I can't find any good samples for how to do this.</p>
<p>Thanks!</p>
| [
{
"answer_id": 311409,
"author": "Asher",
"author_id": 38265,
"author_profile": "https://Stackoverflow.com/users/38265",
"pm_score": 0,
"selected": false,
"text": "WINDOWINFO.dwStyle & WS_MAXIMIZEBOX != 0\n"
},
{
"answer_id": 311410,
"author": "splattne",
"author_id": 646... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39171/"
] |
311,408 | <p>I'm using hibernate 3 and want to stop it from dumping all the startup messages to the console. I tried commenting out the stdout lines in log4j.properties but no luck. I've pasted my log file below. Also I'm using eclipse with the standard project structure and have a copy of log4j.properties in both the root of the project folder and the bin folder.</p>
<pre>### direct log messages to stdout ###
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=warn, stdout
#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug
### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug
### log just the SQL
#log4j.logger.org.hibernate.SQL=debug
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug
### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug
### log cache activity ###
#log4j.logger.org.hibernate.cache=debug
### log transaction activity
#log4j.logger.org.hibernate.transaction=debug
### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug
### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trac5</pre>
| [
{
"answer_id": 311445,
"author": "Juha Syrjälä",
"author_id": 1431,
"author_profile": "https://Stackoverflow.com/users/1431",
"pm_score": 7,
"selected": true,
"text": "info"
},
{
"answer_id": 325747,
"author": "rresino",
"author_id": 41589,
"author_profile": "https://... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] |
311,432 | <p>With generics, is there ever a reason to create specific derived EventArg classes</p>
<p>It seems like now you can simply use them on the fly with a generic implementation.</p>
<p>Should i go thorugh all of my examples and remove my eventArg classes (StringEventArgs, MyFooEventArgs, etc . .)</p>
<pre><code>public class EventArgs<T> : EventArgs
{
public EventArgs(T value)
{
m_value = value;
}
private T m_value;
public T Value
{
get { return m_value; }
}
}
</code></pre>
| [
{
"answer_id": 311442,
"author": "Jonas Oberschweiber",
"author_id": 1522,
"author_profile": "https://Stackoverflow.com/users/1522",
"pm_score": 0,
"selected": false,
"text": "EventArgs<T>"
},
{
"answer_id": 311519,
"author": "dalle",
"author_id": 19100,
"author_profi... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
311,438 | <p>I have a simple web app, with a few jsp pages, servlets and pojo's. I want to initialise the connection pool before any requests are made. What is the best way to do this? Can it be done when the app is first deployed or do you have to wait till the first request comes in?</p>
| [
{
"answer_id": 311482,
"author": "Yoni",
"author_id": 36071,
"author_profile": "https://Stackoverflow.com/users/36071",
"pm_score": 3,
"selected": false,
"text": "<listener>\n <listener-class>\n com...ApplicationListener\n </listener-class>\n</listener>\n"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16684/"
] |
311,439 | <p>I am making a Color class, and provide a standard constructor like</p>
<pre><code>Color(int red, int green, int blue)
</code></pre>
<p>And then I want to provide an easy way to get the most common colors, like
Color.Blue, Color.Red. I see two possible options:</p>
<pre><code>public static readonly Color Red = new Color(255, 0, 0);
public static Color Red { get { return new Color(255, 0, 0); } }
</code></pre>
<p>What I don't fully understand is if there is an advantage of one over the other, and how exactly the static keyword works. My thoughts are: The first creates one instance, and then that instance stays in memory for the entire duration of the program, and every time Red is called, this instance is used. The latter only creates something when first used, but creates a new instance every time. If this is correct, then I would argue that if I supply a lot of predefined colors, then the first would use a lot of unnecessary memory? So it is memory usage vs the runtime overhead of instantiating an object every time I guess. </p>
<p>Is my reasoning correct? Any advice for best practices when designing classes and use of the static keyword would be great.</p>
| [
{
"answer_id": 311470,
"author": "Nidonocu",
"author_id": 483,
"author_profile": "https://Stackoverflow.com/users/483",
"pm_score": 1,
"selected": false,
"text": "Application.Current"
},
{
"answer_id": 311489,
"author": "Spoike",
"author_id": 3713,
"author_profile": "... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364245/"
] |
311,454 | <p>How would you format/indent this piece of code?</p>
<pre><code>int ID = Blahs.Add( new Blah( -1, -2, -3) );
</code></pre>
<p>or</p>
<pre><code>int ID = Blahs.Add( new Blah(
1,2,3,55
)
);
</code></pre>
<hr />
<h3>Edit:</h3>
<p>My class has lots of parameters actually, so that might effect your response.</p>
| [
{
"answer_id": 311459,
"author": "bugmagnet",
"author_id": 426,
"author_profile": "https://Stackoverflow.com/users/426",
"pm_score": 2,
"selected": false,
"text": "int ID = Blahs.Add( \n new Blah( 1, 2, 3, 55 ) \n );\n"
},
{
"answer_id": 311468,
"a... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,460 | <p>I'm trying to read data from a.csv file to ouput it on a webpage as text.</p>
<p>It's the first time I'm doing this and I've run into a nasty little problem.</p>
<p>My .csv file(which gets openened by Excel by default), has multiple rows and I read the entire thing as one long string.</p>
<p>like this:</p>
<pre><code>$contents = file_get_contents("files/data.csv");
</code></pre>
<p>In this example file I made, there are 2 lines.</p>
<blockquote>
<p>Paul Blueberryroad
85 us Flashlight,Bag November 20,
2008, 4:39 pm</p>
<p>Hellen Blueberryroad
85 us lens13mm,Flashlight,Bag,ExtraBatteries November
20, 2008, 16:41:32</p>
</blockquote>
<p>But the string read by PHP is this:</p>
<p>Paul;Blueberryroad 85;us;Flashlight,Bag;November 20, 2008, 4:39 pmHellen;Blueberryroad 85;us;lens13mm,Flashlight,Bag,ExtraBatteries;November 20, 2008, 16:41:32</p>
<p>I'm splitting this with:</p>
<pre><code>list($name[], $street[], $country[], $accessories[], $orderdate[]) = split(";",$contents);
</code></pre>
<p>What I want is for $name[] to contain "Paul" and "Hellen" as its contents. And the other arrays to receive the values of their respective columns.</p>
<p>Instead I get only Paul and the content of $orderdate[] is</p>
<blockquote>
<p>November 20, 2008, 4:39 pmHellen</p>
</blockquote>
<p>So all the rows are concatenated. Can someone show me how i can achieve what I need?</p>
<p>EDIT: solution found, just one werid thing remaining:</p>
<p>I've solved it now by using this piece of code:</p>
<pre><code>$fo = fopen("files/users.csv", "rb+");
while(!feof($fo)) {
$contents[] = fgetcsv($fo,0,';');
}
fclose($fo);
</code></pre>
<p>For some reason, allthough my CSV file only has 2 rows, it returns 2 arrays and 1 boolean. The first 2 are my data arrays and the boolean is 0.</p>
| [
{
"answer_id": 311467,
"author": "Davide Gualano",
"author_id": 28582,
"author_profile": "https://Stackoverflow.com/users/28582",
"pm_score": 1,
"selected": false,
"text": "$rows = array();\n$name = array();\n$street = array();\n$country = array();\n\n$rows = file(\"file.csv\");\nforeach... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] |
311,463 | <p>I can follow most of Apple's WiTap sample, but am sort of stumped on this bit in the send method:</p>
<pre><code>- (void) send:(const uint8_t)message
{
if (_outStream && [_outStream hasSpaceAvailable])
if([_outStream write:(const uint8_t *)&message maxLength:sizeof(const uint8_t)] == -1)
[self _showAlert:@"Failed sending data to peer"];
}
- (void) activateView:(TapView*)view
{
NSLog(@"ACTIVATE TAG: %d", [view tag]);
//[self send:[view tag] | 0x80];
[self send:[view tag]];
}
- (void) deactivateView:(TapView*)view
{
NSLog(@"DEACTIVATE TAG: %d", [view tag]);
//[self send:[view tag] & 0x7f];
[self send:[view tag]];
}
</code></pre>
<p>Note that I have changed the send: argument to just the tag of the views, which are numbered 1-9. Originally the code had the bitwise AND and OR adjustments.</p>
<p>WHY?</p>
<p>I get the fact that the send method needs a <code>uint8_t</code>, but is that why the bitwise stuff is there? To turn a NSInteger into a unint8_t?</p>
<p>The code doesn't work with my changes above. It will log fine and visually the client will function correctly, but the messages aren't being sent/received correctly from client to client.</p>
<p>Can someone explain in small words what the bitwise stuff is doing? Or am I correct?</p>
<p>Thanks! This is my first question to SO so please be kind. </p>
<hr>
<p>thanks for the response. I am still puzzled a bit. Get it?</p>
<p>Basically, why?</p>
<p>Is this just a geeky way of passing an identifier? Each of those views have a tag #, why not just pass that, and toggle the state (up/down) from the view class?</p>
<p>Is this just a case of "this is how the person who wrote it did it", or am I missing a crucial piece of the puzzle in that this is how I should also be structuring my code.</p>
<p>I would just want to pass a tag # and then have that tag decide what to do in a clearly readable function like <code>toggleUpOrDownState</code> or something.</p>
<p>This bitwise stuff always makes me feel stupid I guess, unless it is necessary, etc. Then I feel stupid but manage to muddle through somehow anyway. : )</p>
| [
{
"answer_id": 311487,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 3,
"selected": true,
"text": "[view tag] | 0x80"
}
] | 2008/11/22 | [
"https://Stackoverflow.com/questions/311463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39932/"
] |
311,479 | <p>Is there a less resource intensive / faster way of performing this query (which is partly based upon: <a href="https://stackoverflow.com/questions/311390/mysql-a-search-a-select-of-multiple-rows-joining-and-all-in-one-query">This StackOverflow question</a> ). Currently it takes 0.008 seconds searching through only a dozen or so rows per table.</p>
<pre><code>SELECT DISTINCT *
FROM (
(
SELECT DISTINCT ta.auto_id, li.address, li.title, GROUP_CONCAT( ta.tag ) , li.description, li.keyword, li.rating, li.timestamp
FROM tags AS ta
INNER JOIN links AS li ON ta.auto_id = li.auto_id
WHERE ta.user_id =1
AND (
ta.tag LIKE '%query%'
)
OR (
li.keyword LIKE '%query%'
)
GROUP BY li.auto_id
)
UNION DISTINCT (
SELECT DISTINCT auto_id, address, title, '', description, keyword, rating, `timestamp`
FROM links
WHERE user_id =1
AND (
keyword LIKE '%query%'
)
)
) AS total
GROUP BY total.auto_id
</code></pre>
<p>Thank you very much,</p>
<p>Ice</p>
| [
{
"answer_id": 311506,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "SELECT DISTINCT *\nFROM (\n (SELECT ta.auto_id, li.address, li.title, GROUP_CONCAT( ta.tag ),\n li.descript... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
311,501 | <p>If tan(x) = y and atan(y) = x why Math.Atan(Math.Tan(x)) != x?</p>
<p>I´m trying to calculate x in something like: </p>
<pre><code>tan(2/x +3) = 5
</code></pre>
<p>so </p>
<pre><code>atan(tan(2/x + 3) = atan(5)
</code></pre>
<p>and so on... but I´ve tried this: </p>
<pre><code>double d = Math.Atan(Math.Tan(10));
</code></pre>
<p>and d != 10. Why?</p>
| [
{
"answer_id": 311513,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 5,
"selected": false,
"text": "math.tan(math.atan(x)) == x "
},
{
"answer_id": 1940967,
"author": "Regent",
"author_id": 1077... | 2008/11/22 | [
"https://Stackoverflow.com/questions/311501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.