qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
159,034 | <p>Are C++ enums signed or unsigned? And by extension is it safe to validate an input by checking that it is <= your max value, and leave out >= your min value (assuming you started at 0 and incremented by 1)?</p>
| [
{
"answer_id": 159068,
"author": "Cristián Romo",
"author_id": 1256,
"author_profile": "https://Stackoverflow.com/users/1256",
"pm_score": 3,
"selected": false,
"text": "enum Fruit\n{\n Apple = 0,\n Banana,\n Pineapple,\n Orange,\n Kumquat\n};\n\nenum Fruit fruitVariable =... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17693/"
] |
159,038 | <p>Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to <strong><code>drop</code></strong> and then <strong>re-<code>create</code></strong> the constraints?</p>
| [
{
"answer_id": 159064,
"author": "ScottStonehouse",
"author_id": 2342,
"author_profile": "https://Stackoverflow.com/users/2342",
"pm_score": 9,
"selected": false,
"text": " -- Disable all table constraints\n ALTER TABLE MyTable NOCHECK CONSTRAINT ALL\n\n -- Enable all table constra... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
159,076 | <p>I have a c# application that runs as a windows service controlling socket connections and other things.
Also, there is another windows forms application to control and configure this service (systray with start, stop, show form with configuration parameters).</p>
<p>I'm using .net remoting to do the IPC and that was fine, but now I want to show some real traffic and other reports and remoting will not meet my performance requirements. So I want to combine both applications in one. </p>
<p>Here is the problem:</p>
<p>When I started the form from the windows service, nothing happened. Googling around I've found that I have to right click the service, go to Log on and check the "Allow service to interact with desktop" option. Since I don't want to ask my users to do that, I got some code googling again to set this option in the user's regedit during installation time. The problem is that even setting this option, it doesn't work. I have to open the Log On options of the service (it is checked), uncheck and check again.</p>
<p><strong>So, how to solve that? How is the best way to have a windows service with a systray control in the same process, available to any user logging in?</strong></p>
<p>UPDATE: Thanks for the comments so far, guys. I agree it is better to use IPC and I know that it is bad to mix windows services and user interfaces. Even though, I want to know how to do that.</p>
| [
{
"answer_id": 221705,
"author": "CoolMagic",
"author_id": 22641,
"author_profile": "https://Stackoverflow.com/users/22641",
"pm_score": 0,
"selected": false,
"text": "ref class RunWindow{\npublic:\n static void MakeWindow(Object^ data)\n {\n Application::EnableVisualStyles(... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22693/"
] |
159,087 | <p>I inherited a database built with the idea that composite keys are much more ideal than using a unique object ID field and that when building a database, a single unique ID should <b><em>never</em></b> be used as a primary key. Because I was building a Rails front-end for this database, I ran into difficulties getting it to conform to the Rails conventions (though it was possible using custom views and a few additional gems to handle composite keys).</p>
<p>The reasoning behind this specific schema design from the person who wrote it had to do with how the database handles ID fields in a non-efficient manner and when it's building indexes, tree sorts are flawed. This explanation lacked any depth and I'm still trying to wrap my head around the concept (I'm familiar with using composite keys, but not 100% of the time).</p>
<p>Can anyone offer opinions or add any greater depth to this topic? </p>
| [
{
"answer_id": 160085,
"author": "JeremyDWill",
"author_id": 12603,
"author_profile": "https://Stackoverflow.com/users/12603",
"pm_score": 7,
"selected": true,
"text": "\"SELECT InvoiceNumber FROM Invoice WHERE CustomerCode = 'XYZ123'\""
},
{
"answer_id": 161382,
"author": "H... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23909/"
] |
159,088 | <p>In WPF:</p>
<p>Can someone please explain the relationship between DependencyProperty and Databinding?</p>
<p>I have a property in my code behind I want to be the source of my databinding.
When does a DependencyProperty (or does it) come into play if I want to bind this object to textboxes on the XAML.</p>
| [
{
"answer_id": 159284,
"author": "Joel B Fant",
"author_id": 22211,
"author_profile": "https://Stackoverflow.com/users/22211",
"pm_score": 5,
"selected": true,
"text": "DependencyProperty"
},
{
"answer_id": 67103647,
"author": "james.lee",
"author_id": 9438258,
"autho... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2744/"
] |
159,097 | <p>Is there any way to output the contents of an XDocument without the BOM? When reading the output with Flash, it causes errors.</p>
| [
{
"answer_id": 159203,
"author": "Chris Wenham",
"author_id": 5548,
"author_profile": "https://Stackoverflow.com/users/5548",
"pm_score": 4,
"selected": true,
"text": "XmlWriter writer = XmlWriter.Create(\"foo.xml\");\nwriter.Settings.Encoding = new System.Text.UTF8Encoding(false);\nmyXD... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786/"
] |
159,118 | <p>For example, this regex</p>
<pre><code>(.*)<FooBar>
</code></pre>
<p>will match:</p>
<pre><code>abcde<FooBar>
</code></pre>
<p>But how do I get it to match across multiple lines?</p>
<pre><code>abcde
fghij<FooBar>
</code></pre>
| [
{
"answer_id": 159139,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 9,
"selected": true,
"text": "/(.*)<FooBar>/s\n"
},
{
"answer_id": 159140,
"author": "levik",
"author_id": 4465,
"author_profile": "h... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2108/"
] |
159,137 | <p>I need a cross platform method of determining the MAC address of a computer at run time. For windows the 'wmi' module can be used and the only method under Linux I could find was to run ifconfig and run a regex across its output. I don't like using a package that only works on one OS, and parsing the output of another program doesn't seem very elegant not to mention error prone. </p>
<p>Does anyone know a cross platform method (windows and linux) method to get the MAC address? If not, does anyone know any more elegant methods then those I listed above?</p>
| [
{
"answer_id": 159150,
"author": "camflan",
"author_id": 22445,
"author_profile": "https://Stackoverflow.com/users/22445",
"pm_score": 5,
"selected": false,
"text": "netifaces"
},
{
"answer_id": 159195,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile":... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9940/"
] |
159,148 | <p>Groovy adds the <code>execute</code> method to <code>String</code> to make executing shells fairly easy;</p>
<pre><code>println "ls".execute().text
</code></pre>
<p>but if an error happens, then there is no resulting output. <strong>Is there an easy way to get both the standard error and standard out?</strong> (other than creating a bunch of code to; create two threads to read both inputstreams, then using a parent stream to wait for them to complete then convert the strings back to text?)</p>
<p>It would be nice to have something like;</p>
<pre><code> def x = shellDo("ls /tmp/NoFile")
println "out: ${x.out} err:${x.err}"
</code></pre>
| [
{
"answer_id": 159244,
"author": "Joshua",
"author_id": 6013,
"author_profile": "https://Stackoverflow.com/users/6013",
"pm_score": 6,
"selected": false,
"text": "\"ls\".execute()"
},
{
"answer_id": 159270,
"author": "Bob Herrmann",
"author_id": 6580,
"author_profile"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6580/"
] |
159,152 | <p>Is there a way with SVN to check out from a remote repository to another remote location rather than my local file system? Something like:</p>
<pre><code>svn co http://myrepository/svn/project ssh me@otherlocation.net:/var/www/project
</code></pre>
| [
{
"answer_id": 159467,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 4,
"selected": true,
"text": "ssh me@other.net 'svn co http://repository/svn/project /var/www/project'\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] |
159,183 | <p>I want to resize the font of a SPAN element's style until it the SPAN's text is 7.5 inches wide when printed out on paper, but JavaScript only reports the SPAN's clientWidth property in pixels.</p>
<pre><code><span id="test">123456</span>
</code></pre>
<p>And then:</p>
<pre><code>#test {
font-size:1.2in; /* adjust this for yourself until printout measures 7.5in wide */
}
</code></pre>
<p>And then:</p>
<pre><code>console.log(document.getElementById('test').clientWidth);
</code></pre>
<p>I've determined experimentally on one machine that it uses approximately 90 DPI as a conversion factor, because the above code logs approximately 675, at least under Firefox 3.</p>
<p>This number is not necessarily the same under different browser, printer, screen, etc. configurations.</p>
<p>So, how do I find the DPI the browser is using? What can I call to get back "90" on my system?</p>
| [
{
"answer_id": 159316,
"author": "neonski",
"author_id": 17112,
"author_profile": "https://Stackoverflow.com/users/17112",
"pm_score": 1,
"selected": false,
"text": "<link rel=\"stylesheet\" type=\"text/css\" href=\"print.css\" media=\"print\" />\n"
},
{
"answer_id": 159322,
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] |
159,190 | <p>In Eclipse, its easy to specify buttons for your toolbar using the ActionSets extension point. However, when I need to specify some items programmatically, I can't get the same look. I don't believe that the framework is using native buttons for these, but so far, I can't find the right recipe to match the Eclipse look. I wanted to see if anyone has found the right snippet to duplicate this functionality in code.</p>
| [
{
"answer_id": 439165,
"author": "hudsonb",
"author_id": 53923,
"author_profile": "https://Stackoverflow.com/users/53923",
"pm_score": 4,
"selected": true,
"text": "IToolBarManager toolBarManager = actionBars.getToolBarManager();\ntoolBarManager.add(new ControlContribution(\"Toggle Chart... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16476/"
] |
159,237 | <p>I'm working in .Net 3.5sp1 in C# for an ASP.Net solution and I'm wondering if there's any way to turn on the Class Name and Method Name drop-downs in the text editor that VB.Net has at the top. It's one of the few things from VB that I actually miss.</p>
<p>Edit: Also, is there any way to get the drop downs to be populated with the possible events?</p>
<p>e.g. (Page Events) | (Declarations)</p>
| [
{
"answer_id": 159246,
"author": "casademora",
"author_id": 5619,
"author_profile": "https://Stackoverflow.com/users/5619",
"pm_score": 3,
"selected": true,
"text": "Tools -> Options -> Text Editor -> C# -> General -> Navigation Bar\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] |
159,240 | <p>The more we use RAII in C++, the more we find ourselves with destructors that do non-trivial deallocation. Now, deallocation (finalization, however you want to call it) can fail, in which case exceptions are really the only way to let anybody upstairs know of our deallocation problem. But then again, throwing-destructors are a bad idea because of the possibility of exceptions being thrown during stack unwinding. <code>std::uncaught_exception()</code> lets you know when that happens, but not much more, so aside from letting you log a message before termination there's not much you can do, unless you're willing to leave your program in an undefined state, where some stuff is deallocated/finalized and some not.</p>
<p>One approach is to have no-throw destructors. But in many cases that just hides a real error. Our destructor might, for example, be closing some RAII-managed DB connections as a result of some exception being thrown, and those DB connections might fail to close. This doesn't necessarily mean we're ok with the program terminating at this point. On the other hand, logging and tracing these errors isn't really a solution for every case; otherwise we would have had no need for exceptions to begin with.
With no-throw destructors we also find ourselves having to create "reset()" functions that are supposed to be called before destruction - but that just defeats the whole purpose of RAII.</p>
<p>Another approach is just to <a href="http://www.kolpackov.net/projects/c++/eh/dtor-1.xhtml" rel="noreferrer">let the program terminate</a>, as it's the most predictable thing you can do.</p>
<p>Some people suggest chaining exceptions, so that more than one error can be handled at a time. But I honestly never actually seen that done in C++ and I've no idea how to implement such a thing.</p>
<p>So it's either RAII or exceptions. Isn't it? I'm leaning toward no-throw destructors; mainly because it keeps things simple(r). But I really hope there's a better solution, because, as I said, the more we use RAII, the more we find ourselves using dtors that do non-trivial things.</p>
<p><strong>Appendix</strong></p>
<p>I'm adding links to interesting on-topic articles and discussions I've found:</p>
<ul>
<li><a href="http://www.kolpackov.net/projects/c++/eh/dtor-1.xhtml" rel="noreferrer">Throwing Destructors</a></li>
<li>StackOverflow discussion on the <a href="https://stackoverflow.com/questions/164372/is-there-a-good-way-around-the-problems-of-structured-exception-handling-try-ex">problems with SEH</a></li>
<li>StackOverflow discussion on <a href="https://stackoverflow.com/questions/130117/throwing-exceptions-out-of-a-destructor#130123">throwing-destructors</a> (thanks, Martin York)</li>
<li><a href="http://www.joelonsoftware.com/items/2003/10/13.html" rel="noreferrer">Joel on Exceptions</a></li>
<li><a href="http://blogs.msdn.com/larryosterman/archive/2004/09/10/228068.aspx" rel="noreferrer">SEH Considered Harmful</a> </li>
<li><a href="http://bartdesmet.net/blogs/bart/archive/2006/04/04/clr-exception-handling-from-a-to-z-everything-you-didn-t-want-to-know-about-try-catch-finally-fault-filter.aspx" rel="noreferrer">CLR Exception Handling</a> which also touches on exception chaining</li>
<li><a href="http://www.gotw.ca/gotw/047.htm" rel="noreferrer">Herb Sutter on std::uncaught_exception</a> and why it's not as useful as you think</li>
<li><a href="http://www.cpptalk.net/1-vt12438.html?postdays=0&postorder=asc&start=0" rel="noreferrer">Historical discussion</a> on the matter with interesting participants (long!)</li>
<li>Stroustrup explaining <a href="http://www.research.att.com/~bs/bs_faq2.html#finally" rel="noreferrer">RAII</a></li>
<li>Andrei Alexandrescu's <a href="http://www.ddj.com/cpp/184403758" rel="noreferrer">Scope Guard</a></li>
</ul>
| [
{
"answer_id": 159259,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 4,
"selected": false,
"text": "noexcept"
},
{
"answer_id": 159315,
"author": "puetzk",
"author_id": 14312,
"author_profile": "htt... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11208/"
] |
159,252 | <p>When I have a regular textbox in a UpdatePanel (not an ASP.NET control) with some JavaScript events on it, after the UpdatePanel updates my events are gone. Is there a way to re-attach my events after the update? (Preferably without putting my events inline).</p>
| [
{
"answer_id": 159260,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "setInterval()"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18926/"
] |
159,255 | <p>Bearing in mind that I'll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database?</p>
| [
{
"answer_id": 159275,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": -1,
"selected": false,
"text": "FLOAT"
},
{
"answer_id": 25120203,
"author": "Simon",
"author_id": 1226018,
"author_profile": "https://... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12037/"
] |
159,261 | <p>Does anyone have an example of script that can work reliably well across IE/Firefox to detect if the browser is capable of displaying embedded flash content. I say reliably because I know its not possible 100% of the time. </p>
| [
{
"answer_id": 4565606,
"author": "Andrew Ensley",
"author_id": 20801,
"author_profile": "https://Stackoverflow.com/users/20801",
"pm_score": 7,
"selected": false,
"text": "swfobject.js"
},
{
"answer_id": 5159190,
"author": "Jon Clark",
"author_id": 639959,
"author_pr... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7280/"
] |
159,282 | <pre><code>grant {
permission java.security.AllPermission;
};
</code></pre>
<p>This works.</p>
<pre><code>grant file:///- {
permission java.security.AllPermission;
};
</code></pre>
<p>This does not work. Could someone please explain to me why?</p>
| [
{
"answer_id": 159785,
"author": "David G",
"author_id": 3150,
"author_profile": "https://Stackoverflow.com/users/3150",
"pm_score": 1,
"selected": false,
"text": "file:///tmp/-"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
159,292 | <p>I am using Apache's Velocity templating engine, and I would like to create a custom Directive. That is, I want to be able to write "#doMyThing()" and have it invoke some java code I wrote in order to generate the text.</p>
<p>I know that I can register a custom directive by adding a line</p>
<pre><code>userdirective=my.package.here.MyDirectiveName
</code></pre>
<p>to my velocity.properties file. And I know that I can write such a class by extending the <a href="http://svn.apache.org/repos/asf/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Directive.java" rel="nofollow noreferrer">Directive class</a>. What I don't know is <em>how</em> to extend the Directive class -- some sort of documentation for the author of a new Directive. For instance I'd like to know if my getType() method return "BLOCK" or "LINE" and I'd like to know what should my setLocation() method should do?</p>
<p>Is there any documentation out there that is better than just "<a href="http://www.catb.org/jargon/html/U/UTSL.html" rel="nofollow noreferrer">Use the source, Luke</a>"?</p>
| [
{
"answer_id": 1012914,
"author": "gbegley",
"author_id": 76924,
"author_profile": "https://Stackoverflow.com/users/76924",
"pm_score": 2,
"selected": false,
"text": "import org.apache.velocity.runtime.directive.Directive;\nimport org.apache.velocity.runtime.RuntimeServices;\nimport org.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14570/"
] |
159,296 | <p>I've got a (poorly written) base class that I want to wrap in a proxy object. The base class resembles the following:</p>
<pre><code>public class BaseClass : SomeOtherBase
{
public BaseClass() {}
public BaseClass(int someValue) {}
//...more code, not important here
}
</code></pre>
<p>and, my proxy resembles:</p>
<pre><code>public BaseClassProxy : BaseClass
{
public BaseClassProxy(bool fakeOut){}
}
</code></pre>
<p>Without the "fakeOut" constructor, the base constructor is expected to be called. However, with it, I expected it to not be called. Either way, I either need a way to not call any base class constructors, or some other way to effectively proxy this (evil) class.</p>
| [
{
"answer_id": 159327,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 1,
"selected": false,
"text": "public BaseClassProxy (bool fakeOut) : base (10) {}\n"
},
{
"answer_id": 159342,
"author": "Jake Pearson",
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5619/"
] |
159,298 | <p>It looks like some work has been done to make <a href="http://sourceware.org/pthreads-win32/" rel="noreferrer">pthread-win32</a> work with x64, but there are no build instructions. I have tried simly building with the Visual Studio x64 Cross Tools Command Prompt, but when I try to link to the lib from an x64 application, it can't see any of the function exports. It seems like it is still compiling the lib as x86 or something.</p>
<p>I've even tried adding /MACHINE to the makefile in the appropriate places, but it doesn't help. Has anyone gotten this to work?</p>
| [
{
"answer_id": 16399440,
"author": "rogerdpack",
"author_id": 32453,
"author_profile": "https://Stackoverflow.com/users/32453",
"pm_score": 2,
"selected": false,
"text": "$ make clean GC-static \n"
},
{
"answer_id": 48095275,
"author": "Vladimir Fekete",
"author_id": 2282... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21784/"
] |
159,313 | <p>What is the scope of Runtime Callable Wrapper (RCW), when referencing unmanaged COM objects? According to the docs:</p>
<blockquote>
<p>The runtime creates exactly one RCW
for each COM object, regardless of the
number of references that exist on
that object.</p>
</blockquote>
<p>If I had to "guess" - this explanation should mean "one per process", but is it really? Any additional documentation will be very welcome.</p>
<p>My application runs in its own application domain (it is Outlook addin), and I would like to know what happens if I use Marshal.ReleaseComObject(x) in a loop until it's count reaches 0 (as recommended). Will it release references from other addins (running in other application domain in the same Outlook process)?</p>
<p>EDIT: Perfect - now the confusion is even bigger. Based on the 2 answers (from Lette and Ilya) we have 2 different answers. The official <a href="http://msdn.microsoft.com/en-us/library/8bwh56xe(VS.80).aspx" rel="nofollow noreferrer">MSDN doc</a> says per process (for ver. 2.0+), but it is missing this sentence for <a href="http://msdn.microsoft.com/en-us/library/8bwh56xe(VS.71).aspx" rel="nofollow noreferrer">ver. 1.1 of the doc</a>.</p>
<p>In the same time, in Mason Bendixen's article, it says it's per appdomain.</p>
<p>As his article is old (April 2007), I have send him an email asking for clarification, but if someone else has to add something, please do.</p>
<p>Thanks</p>
| [
{
"answer_id": 163151,
"author": "Christoffer Lette",
"author_id": 11808,
"author_profile": "https://Stackoverflow.com/users/11808",
"pm_score": 1,
"selected": false,
"text": "ReleaseComObject"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8220/"
] |
159,317 | <p>When should one do the following?</p>
<pre><code>class Foo : Control
{
protected override void OnClick(EventArgs e)
{
// new code here
}
}
</code></pre>
<p>As opposed to this?</p>
<pre><code>class Foo : Control
{
public Foo()
{
this.Click += new EventHandler(Clicked);
}
private void Clicked(object sender, EventArgs e)
{
// code
}
}
</code></pre>
| [
{
"answer_id": 160041,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 2,
"selected": false,
"text": "public class MyDataTable : DataTable\n{\n public override void EndInit()\n {\n base.EndInit();\n thi... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8505/"
] |
159,339 | <p>I'm not sure if the term's actually "Array Addition". </p>
<p>I'm trying to understand what does the following line do:</p>
<pre><code>int var[2 + 1] = {2, 1};
</code></pre>
<p>How is that different from <code>int var[3]</code>?</p>
<p>I've been using Java for several years, so I'd appreciate if explained using Java-friendly words.</p>
<p>Edit: Thousands of thanks to everyone who helped me out, Occam's Razor applies here. </p>
| [
{
"answer_id": 159352,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "int var[3]"
},
{
"answer_id": 159355,
"author": "Dima",
"author_id": 13313,
"author_profile": "ht... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24280/"
] |
159,351 | <p>ActiveReports seems like a powerful flexible tool, but if you make a mistake anywhere, you get an exception "data member not found. please check your datasource and datamember properties". </p>
<p>There is no indication as to which datasource/datamember is at fault or what subreport the problem lies in, but Active Reports must know this!</p>
<p>The stack trace is no use, as the error is thrown after the report.run() method is invoked from deep within code generated by Active Reports itself.</p>
<p>Does anybody have a solution other than commenting out one subreport after another and checking all fields in turn?</p>
| [
{
"answer_id": 6863977,
"author": "John Meyer",
"author_id": 868113,
"author_profile": "https://Stackoverflow.com/users/868113",
"pm_score": 2,
"selected": false,
"text": "Dim rpt as New ActiveReport"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
159,359 | <p>I know we cannot do this at class level but at method level we can always do this. </p>
<pre><code>var myList=new List<string> // or something else like this
</code></pre>
<p>This question came to my mind since wherever we declare variable like this. We always provide the type information at the RHS of the expression. So compiler doesn't need to do type guessing. (correct me if i am wrong).</p>
<p>so question remains WHY NOT at class level while its allowed at method level</p>
| [
{
"answer_id": 159559,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 1,
"selected": false,
"text": "var"
},
{
"answer_id": 159574,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https:... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22858/"
] |
159,362 | <p>If I avoid referencing assemblies that don't exist in the silverlight 2.0 runtime, will the.Net 2.0 library dlls I create with VS2008 work with silverlight <strong>without recompilation</strong> or other alteration?</p>
| [
{
"answer_id": 170936,
"author": "Jimmy",
"author_id": 25071,
"author_profile": "https://Stackoverflow.com/users/25071",
"pm_score": 0,
"selected": false,
"text": "#if SILVERLIGHT\n/* some code */\n#else // WPF\n/* some other code */\n#endif\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11356/"
] |
159,373 | <p>Using .Net 3.0 and VS2005. </p>
<p>The objects in question are consumed from a WCF service then serialized back into XML for a legacy API. So rather than serializing the TestObject, it was serializing .TestObject which was missing the [XmlRoot] attribute; however, all the [Xml*] attributes for the child elements were in the generated proxy code so they worked just fine. So all the child elements worked just fine, but the enclosing element did not because the [XmlRoot] attribute wasn't included in the generated proxy code. The original object that included the [XmlRoot] attribute serializes fine manually.</p>
<p><strong>Can I have the proxy code include the [XmlRoot] attribute so the generated proxy class serializes correctly as well?</strong> If I can't do that I suspect I'll have to use [XmlType] but that causes minor havoc requiring me to change other components so I would prefer the former. I also want to avoid having to manually edit the autogenerated proxy class.</p>
<p>Here is some sample code (I have included the client and the service in the same app because this is quick and for test purposes. Comment out the service referencing code and add the service reference while running the app, then uncomment the service code and run.)</p>
<pre><code>namespace SerializationTest {
class Program {
static void Main( string[] args ) {
Type serviceType = typeof( TestService );
using (ServiceHost host = new ServiceHost(
serviceType,
new Uri[] {
new Uri( "http://localhost:8080/" )
}
))
{
ServiceMetadataBehavior behaviour = new ServiceMetadataBehavior();
behaviour.HttpGetEnabled = true;
host.Description.Behaviors.Add( behaviour );
host.AddServiceEndpoint( serviceType, new BasicHttpBinding(), "TestService" );
host.AddServiceEndpoint( typeof( IMetadataExchange ), new BasicHttpBinding(), "MEX" );
host.Open();
TestServiceClient client = new TestServiceClient();
localhost.TestObject to = client.GetObject();
String XmlizedString = null;
using (MemoryStream memoryStream = new MemoryStream()) {
XmlSerializer xs = new XmlSerializer( typeof( localhost.TestObject ) );
using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream)) {
xs.Serialize( xmlWriter, to );
memoryStream = (MemoryStream)xmlWriter.BaseStream;
XmlizedString = Encoding.UTF8.GetString( memoryStream.ToArray() );
Console.WriteLine( XmlizedString );
}
}
}
Console.ReadKey();
}
}
[Serializable]
[XmlRoot( "SomethingElse" )]
public class TestObject {
private bool _worked;
public TestObject() { Worked = true; }
[XmlAttribute( AttributeName = "AttributeWorked" )]
public bool Worked {
get { return _worked; }
set { _worked = value; }
}
}
[ServiceContract]
public class TestService {
[OperationContract]
[XmlSerializerFormat]
public TestObject GetObject() {
return new TestObject();
}
}
}
</code></pre>
<p>Here is the Xml this generates.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<TestObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" AttributeWorked="true" />
</code></pre>
| [
{
"answer_id": 177169,
"author": "hurst",
"author_id": 10991,
"author_profile": "https://Stackoverflow.com/users/10991",
"pm_score": -1,
"selected": true,
"text": "XmlAttributeOverrides"
},
{
"answer_id": 1031423,
"author": "graffic",
"author_id": 15987,
"author_profi... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24279/"
] |
159,391 | <p>Did anyone of you ever find a way of getting the Microsoft Report Viewer Control (Web) to work from within an Ajax UpdatePanel?</p>
| [
{
"answer_id": 2673667,
"author": "user321101",
"author_id": 321101,
"author_profile": "https://Stackoverflow.com/users/321101",
"pm_score": 2,
"selected": false,
"text": " <assemblies> <add assembly=\"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B7... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23369/"
] |
159,393 | <p>I want to create a script that parses or makes sense of apache's error log to see what the most recent error was. I was wondering if anyone out there has something that does this or has any ideas where to start?</p>
| [
{
"answer_id": 159452,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 5,
"selected": true,
"text": "$contents = @file('/path/to/error.log', FILE_SKIP_EMPTY_LINES);\nif (is_array($contents)) {\n echo end($contents);\n}\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5261/"
] |
159,423 | <p>I'm currently writing a simple .sh script to parse an Exim log file for strings matching " o' ". Currently, when viewing output.txt, all that is there is a 0 printed on every line(606 lines). I'm guessing my logic is wrong, as awk does not throw any errors.</p>
<p>Here is my code(updated for concatenation and counter issues). Edit: I've adopted some new code from dmckee's answer that I'm now working with over the old code in favor of simplicity.</p>
<pre><code>awk '/o'\''/ {
line = "> ";
for(i = 20; i <= 33; i++) {
line = line " " $i;
}
print line;
}' /var/log/exim/main.log > output.txt
</code></pre>
<p>Any ideas? </p>
<p>EDIT: For clarity's sake, I'm grepping for "o'" in email addresses, because ' is an illegal character in email addresses(and in our databases, appears only with o'-prefixed names).</p>
<p>EDIT 2: As per commentary request, here is a sanitized sample of some desired output:</p>
<pre><code>[xxx.xxx.xxx.xxx] kathleen.o'toole@domain.com <kathleen.o'toole@domain.com> routing defer (-51): retry time not reached
[xxx.xxx.xxx.xxx] julie.o'brien@domain.com <julie.o'brien@domain.com> routing defer (-51): retry time not reached
[xxx.xxx.xxx.xxx] james.o'dell@domain.com <james.o'dell@domain.com> routing defer (-51): retry time not reached
[xxx.xxx.xxx.xxx] daniel_o'leary@domain.com <aniel_o'leary@domain.com> routing defer (-51): retry time not reached
</code></pre>
<p>The reason I'm starting at 20 in my loop is because everything before the 20th field is just standard log information that isn't needed for my purposes here. All I need is everything from the IP and beyond for this solution(the messages for each 550 error are different for each mail server in use out there. I'm compiling a list of common ones)</p>
| [
{
"answer_id": 159450,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 2,
"selected": false,
"text": "+"
},
{
"answer_id": 159501,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2153/"
] |
159,442 | <p>This seems like a pretty softball question, but I always have a hard time looking up this function because there seem there are so many variations regarding the referencing of char and tchar.</p>
| [
{
"answer_id": 159536,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "if (sizeof(TCHAR) != sizeof(wchar_t))\n{ .... }\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16260/"
] |
159,456 | <p>I have a database in the following format:</p>
<pre><code> ID TYPE SUBTYPE COUNT MONTH
1 A Z 1 7/1/2008
1 A Z 3 7/1/2008
2 B C 2 7/2/2008
1 A Z 3 7/2/2008
</code></pre>
<p>Can I use SQL to convert it into this:</p>
<pre><code>ID A_Z B_C MONTH
1 4 0 7/1/2008
2 0 2 7/2/2008
1 0 3 7/2/2008
</code></pre>
<p>So, the <code>TYPE</code>, <code>SUBTYPE</code> are concatenated into new columns and <code>COUNT</code> is summed where the <code>ID</code> and <code>MONTH</code> match.</p>
<p>Any tips would be appreciated. Is this possible in SQL or should I program it manually?</p>
<p>The database is SQL Server 2005. </p>
<p>Assume there are 100s of <code>TYPES</code> and <code>SUBTYPES</code> so and 'A' and 'Z' shouldn't be hard coded but generated dynamically.</p>
| [
{
"answer_id": 159488,
"author": "Bob Probst",
"author_id": 12424,
"author_profile": "https://Stackoverflow.com/users/12424",
"pm_score": 3,
"selected": false,
"text": "select id,\nsum(case when type = 'A' and subtype = 'Z' then [count] else 0 end) as A_Z,\nsum(case when type = 'B' and s... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23133/"
] |
159,469 | <p>Hopefully, I can explain this issue properly. I have 3 classes that deals with my entities.</p>
<pre><code>@MappedSuperclass
public abstract class Swab implements ISwab {
...
private Collection<SwabAccounts> accounts;
...
}
@Entity
@Table(name="switches")
@DiscriminatorColumn(name="type")
@DiscriminatorValue(value="DMS500")
public class DmsSwab extends Swab implements ISwab, Serializable {
...
private ObjectPool pool;
...
@Transient
public ObjectPool getPool(){
return pool;
}
...
}
@Entity(name="swab_accounts")
public class SwabAccounts implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int swab_account_id;
private int swab_id;
...
}
</code></pre>
<p>And in a EJB a query is being doing this way</p>
<pre><code> DmsSwab dms = em.find(DmsSwab.class, 2);
List<Swab> s = new ArrayList<Swab>(1);
s.add(dms);
</code></pre>
<p>My persistence.xml looks like this:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="dflow-pu" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>com.dcom.sap.dms.DmsSwab</class>
<class>com.dcom.sap.jpa.SwabAccounts</class>
<properties>
<property name="toplink.jdbc.user" value="dflow"/>
<property name="toplink.jdbc.password" value="dflow"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://itcd-400447:3306/dflow"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>
</code></pre>
<p>I get this error:</p>
<pre><code>java.lang.IllegalArgumentException: Unknown entity bean class: class com.dcom.sap.dms.DmsSwab, please verify that this class has been marked with the @Entity annotation.
com.dcom.sap.SwabException: java.lang.IllegalArgumentException: Unknown entity bean class: class com.dcom.sap.dms.DmsSwab, please verify that this class has been marked with the @Entity annotation.
Caused by: java.lang.IllegalArgumentException: Unknown entity bean class: class com.dcom.sap.dms.DmsSwab, please verify that this class has been marked with the @Entity annotation.
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.findInternal(EntityManagerImpl.java:306)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.find(EntityManagerImpl.java:148)
</code></pre>
<p>I am running netbeans 6.1 with the version of glassfish that comes with it. MySql 5.0.</p>
| [
{
"answer_id": 43619011,
"author": "Mario Barreto MX",
"author_id": 7921419,
"author_profile": "https://Stackoverflow.com/users/7921419",
"pm_score": 0,
"selected": false,
"text": "public void contextDestroyed(ServletContextEvent servletContextEvent) {\n try {\n logger.info(\"c... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22763/"
] |
159,470 | <p>I'm using an expander inside a <a href="http://kentb.blogspot.com/2007/04/resizer-wpf-control.html" rel="nofollow noreferrer">Resizer</a> (a ContentControl with a resize gripper), and it expands/collapses properly when the control initially comes up. Once I resize it, the Expander won't properly collapse, as documented below. I ran Snoop on my application, and I don't see any heights set on Expander or its constituents. </p>
<p>How would I go about convincing Expander to collapse properly again? Or modifying Resizer to not make Expander sad would work as well.</p>
<p>Expander documentation says:</p>
<blockquote>
<p>"For an Expander to work correctly, do not specify a Height on the Expander control when the ExpandDirection property is set to Down or Up. Similarly, do not specify a Width on the Expander control when the ExpandDirection property is set to Left or Right. When you set a size on the Expander control in the direction that the expanded content is displayed, the area that is defined by the size parameter is displayed with a border around it. This area displays even when the window is collapsed. To set the size of the expanded window, set size dimensions on the content of the Expander control or the ScrollViewer that encloses the content."</p>
</blockquote>
| [
{
"answer_id": 43619011,
"author": "Mario Barreto MX",
"author_id": 7921419,
"author_profile": "https://Stackoverflow.com/users/7921419",
"pm_score": 0,
"selected": false,
"text": "public void contextDestroyed(ServletContextEvent servletContextEvent) {\n try {\n logger.info(\"c... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9970/"
] |
159,476 | <p>Let's say I've got a website that works better if a client has installed and logged into a desktop application. I'd like to be able to do 2 things:</p>
<ul>
<li>Alter the website if they haven't installed the app (to make it easy for them to find a link to the installer)</li>
<li>If they've installed the app on a couple of machines, determine which machine they are browsing from</li>
</ul>
<p>I'd like something that works on Windows and OSX, on any of the major browsers. Linux is a bonus. </p>
<p>A few thoughts:</p>
<ul>
<li>Websites can detect if you've got Flash installed. How does that work and could it be used for both of my goals? </li>
<li>Could I just let the client serve HTTP on localhost and do some javascript requests to fetch a local ID? I know google desktop search did something like this at one point. Is this a standard practice? </li>
</ul>
<p>Thanks!</p>
| [
{
"answer_id": 159518,
"author": "vaske",
"author_id": 16039,
"author_profile": "https://Stackoverflow.com/users/16039",
"pm_score": 0,
"selected": false,
"text": ".swf"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23524/"
] |
159,487 | <p>Well, this is my first post here and really enjoying the site.</p>
<p>I have a very basic (ugly as sin) site I have started and for some reason, I can not get the CSS Sticky footer to work for FireFox. IE works but FF shows it halfway up the page.</p>
<p>The URL is <a href="http://dev.aipoker.co.uk" rel="nofollow noreferrer">http://dev.aipoker.co.uk</a></p>
<p>I know I should be developing in FF and bug fixing in IE so I am guessing I might have actually made a mistake and somehow it works in IE but nowhere else.</p>
<p>Can anyone help put me out of my misery please?</p>
<p>Thanks, guys and gals.</p>
| [
{
"answer_id": 159558,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 2,
"selected": false,
"text": "footer { \n display: block; \n position: absolute; \n width: 100%; \n bottom: 0px; \n}\n"
},
{
"answer_id": 15966... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] |
159,506 | <p>Can I programatically set the position of a WPF ListBox's scrollbar? By default, I want it to go in the center.</p>
| [
{
"answer_id": 159565,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 2,
"selected": false,
"text": "Dim cnt as Integer = myListBox.Items.Count\nDim midPoint as Integer = cnt\\2\nmyListBox.ScrollIntoView(myListBox.Items(midP... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] |
159,521 | <p>I mean 100+ MB big; such text files can push the envelope of editors.</p>
<p>I need to look through a large XML file, but cannot if the editor is buggy.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 159537,
"author": "Nick Ryberg",
"author_id": 21275,
"author_profile": "https://Stackoverflow.com/users/21275",
"pm_score": 12,
"selected": true,
"text": "tail"
},
{
"answer_id": 1343576,
"author": "Roboprog",
"author_id": 63369,
"author_profile": "http... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17865/"
] |
159,523 | <p>When I call <code>Response.Redirect(someUrl)</code> I get the following HttpException:</p>
<blockquote>
<p>Cannot redirect after HTTP headers have been sent.</p>
</blockquote>
<p>Why do I get this? And how can I fix this issue?</p>
| [
{
"answer_id": 159529,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": false,
"text": "HTTP/1.x 3xx Redirect Reason"
},
{
"answer_id": 159538,
"author": "Samuel Meacham",
"author_id": 23886,
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23886/"
] |
159,541 | <p>I'm running a Django site using the fastcgi interface to nginx. However, some pages are being served truncated (i.e. the page source just stops, sometimes in the middle of a tag). How do I fix this (let me know what extra information is needed, and I'll post it)</p>
<p>Details:</p>
<p>I'm using flup, and spawning the fastcgi server with the following command:</p>
<pre><code>python ./manage.py runfcgi umask=000 maxchildren=5 maxspare=1 minspare=0 method=prefork socket=/path/to/runfiles/django.sock pidfile=/path/to/runfiles/django.pid
</code></pre>
<p>The nginx config is as follows:</p>
<pre><code># search and replace this: {project_location}
pid /path/to/runfiles/nginx.pid;
worker_processes 2;
error_log /path/to/runfiles/error_log;
events {
worker_connections 1024;
use epoll;
}
http {
# default nginx location
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size 256;
client_header_buffer_size 1k;
large_client_header_buffers 4 2k;
request_pool_size 4k;
output_buffers 4 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
keepalive_timeout 75 20;
tcp_nodelay on;
client_max_body_size 10m;
client_body_buffer_size 256k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
client_body_temp_path /path/to/runfiles/client_body_temp;
proxy_temp_path /path/to/runfiles/proxy_temp;
fastcgi_temp_path /path/to/runfiles/fastcgi_temp;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain text/html application/x-javascript text/xml text/css;
ignore_invalid_headers on;
server {
listen 80;
server_name alpha2.sonyalabs.com;
index index.html;
root /path/to/django-root/static;
# static resources
location ~* ^/static/.*$
{
root /path/to/django-root;
expires 30d;
break;
}
location / {
# host and port to fastcgi server
fastcgi_pass unix:/path/to/runfiles/django.sock;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
}
location /403.html {
root /usr/local/nginx;
access_log off;
}
location /401.html {
root /usr/local/nginx;
access_log off;
}
location /404.html {
root /usr/local/nginx;
access_log off;
}
location = /_.gif {
empty_gif;
access_log off;
}
access_log /path/to/runfiles/localhost.access_log main;
error_log /path/to/runfiles/localhost.error_log;
}
}
</code></pre>
| [
{
"answer_id": 4515898,
"author": "dwc",
"author_id": 57301,
"author_profile": "https://Stackoverflow.com/users/57301",
"pm_score": 3,
"selected": false,
"text": ".../nginx/tmp/..."
},
{
"answer_id": 6033063,
"author": "rewritten",
"author_id": 384417,
"author_profile... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2933/"
] |
159,549 | <p>I want to log to the console when I'm using un-minimized JavaScript files.</p>
<p>Comments are taken out already when I minimize JavaScript. I'm wondering if there's a way I can write a command that isn't commented out but will still be taken out when I minimize the JavaScript file. </p>
| [
{
"answer_id": 161133,
"author": "Gene",
"author_id": 22673,
"author_profile": "https://Stackoverflow.com/users/22673",
"pm_score": 2,
"selected": true,
"text": "function doLogging(object){}"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9106/"
] |
159,554 | <p>I'm looking for a built-in function/extended function in T-SQL for string manipulation similar to the <code>String.Format</code> method in .NET.</p>
| [
{
"answer_id": 836894,
"author": "jj.",
"author_id": 103131,
"author_profile": "https://Stackoverflow.com/users/103131",
"pm_score": 2,
"selected": false,
"text": "FORMATMESSAGE()"
},
{
"answer_id": 1153194,
"author": "Josh",
"author_id": 123234,
"author_profile": "ht... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
159,567 | <p>How do I parse the first, middle, and last name out of a fullname field with SQL? </p>
<p>I need to try to match up on names that are not a direct match on full name. I'd like to be able to take the full name field and break it up into first, middle and last name. </p>
<p>The data does not include any prefixes or suffixes. The middle name is optional. The data is formatted 'First Middle Last'.</p>
<p>I'm interested in some practical solutions to get me 90% of the way there. As it has been stated, this is a complex problem, so I'll handle special cases individually.</p>
| [
{
"answer_id": 159628,
"author": "neonski",
"author_id": 17112,
"author_profile": "https://Stackoverflow.com/users/17112",
"pm_score": 3,
"selected": false,
"text": "SUBSTRING ( expression , start , length )\n"
},
{
"answer_id": 159664,
"author": "Lasse V. Karlsen",
"auth... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/73794/"
] |
159,590 | <p>I've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory/speed problems.</p>
<p>So, sometime in the very far past I went to try and find if there existed any "pattern" or text-book way of transforming a common recursion approach to iteration and found nothing. Or at least nothing that I can remember it would help.</p>
<ul>
<li>Are there general rules?</li>
<li>Is there a "pattern"?</li>
</ul>
| [
{
"answer_id": 159649,
"author": "Andrew Stein",
"author_id": 13029,
"author_profile": "https://Stackoverflow.com/users/13029",
"pm_score": 2,
"selected": false,
"text": "void foo(Node* node)\n{\n if(node == NULL)\n return;\n // Do something with node...\n foo(node->left);... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] |
159,594 | <p>I've organized my code hierarchically and I find myself crawling up the tree using code like the following.</p>
<pre><code>File clientFolder = task.getActionPlan().getClientFile().getClient().getDocumentsFolder();
</code></pre>
<p>I'm not drilling down into the <code>task</code> object; I'm drilling up to its parents, so I don't think I'm losing anything in terms of encapsulation; but a flag is going off in the back of my mind telling me there's something dirty about doing it this way.</p>
<p>Is this wrong?</p>
| [
{
"answer_id": 159622,
"author": "Chris Cudmore",
"author_id": 18907,
"author_profile": "https://Stackoverflow.com/users/18907",
"pm_score": 0,
"selected": false,
"text": "ActionPlan AP = task.getActionPlan();\nClientFile CF = AP.getClientFile();\nClient C = CF.getClient();\nDocFolder DF... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
159,599 | <p>I have a .net project that has a web reference to a service. I would like to update that web reference as part of every build. Is that possible?</p>
| [
{
"answer_id": 159751,
"author": "Vivek",
"author_id": 7418,
"author_profile": "https://Stackoverflow.com/users/7418",
"pm_score": 5,
"selected": true,
"text": " <Target Name=\"UpdateWebReference\">\n <Message Text=\"Updating Web Reference...\"/>\n <Exec Command=\"wsdl.exe /o &quo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15903/"
] |
159,615 | <p>When running command-line queries in MySQL you can optionally use '<strong>\G</strong>' as a statement terminator, and instead of the result set columns being listed horizontally across the screen, it will list each column vertically, which the corresponding data to the right. Is there a way to the same or a similar thing with the DB2 command line utility?</p>
<p>Example regular MySQL result</p>
<pre><code>mysql> select * from tagmap limit 2;
+----+---------+--------+
| id | blog_id | tag_id |
+----+---------+--------+
| 16 | 8 | 1 |
| 17 | 8 | 4 |
+----+---------+--------+
</code></pre>
<p>Example Alternate MySQL result:</p>
<pre><code>mysql> select * from tagmap limit 2\G
*************************** 1. row ***************************
id: 16
blog_id: 8
tag_id: 1
*************************** 2. row ***************************
id: 17
blog_id: 8
tag_id: 4
2 rows in set (0.00 sec)
</code></pre>
<p>Obviously, this is much more useful when the columns are large strings, or when there are many columns in a result set, but this demonstrates the formatting better than I can probably explain it.</p>
| [
{
"answer_id": 27618935,
"author": "Bimal Jha",
"author_id": 4177130,
"author_profile": "https://Stackoverflow.com/users/4177130",
"pm_score": -1,
"selected": false,
"text": "db2 => connect to coldb\n\n Database Connection Information\n\n Database server = DB2/LINUXX8664 10.5.5\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8636/"
] |
159,627 | <p>We just did a move from storing all files locally to a network drive. Problem is that is where my VS projects are also stored now. (No versioning system yet, working on that.) I know I heard of problems with doing this in the past, but never heard of a work-around. Is there a work around?</p>
<p>So my VS is installed locally. The files are on a network drive. How can I get this to work?</p>
<p>EDIT: I know what SHOULD be done, but is there a band-aid I can put on right now to fix this and maintain the network drive?</p>
<p>EDIT 2: I am sure I am not understanding something, but <a href="https://stackoverflow.com/questions/159627/keeping-visual-studio-projects-on-a-network-drive#159702">Bob King</a> has the right idea. I'll work with the lead web developer when he gets back into the office to figure out a temporary solution until we get some sort of version control setup. Thanks for the ideas.</p>
| [
{
"answer_id": 10217072,
"author": "fschaper",
"author_id": 1021169,
"author_profile": "https://Stackoverflow.com/users/1021169",
"pm_score": 4,
"selected": false,
"text": "<loadFromRemoteSources enabled=\"true\"/>\n"
},
{
"answer_id": 49927622,
"author": "josh",
"author_... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2535/"
] |
159,704 | <p>What options are there for serialization when returning instances of custom classes from a WebService?</p>
<p>We have some classes with a number of child collection class properties as well as other properties that may or may not be set depending on usage. These objects are returned from an ASP.NET .asmx WebService decorated with the ScriptService attribute, so are serialized via JSON serialization when returned by the various WebMethods.</p>
<p>The problem is that the out of the box serialization returns all public properties, regardless of whether or not they are used, as well as returning class name and other information in a more verbose manner than would be desired if you wanted to limit the amount of traffic.</p>
<p>Currently, for the classes being returned we have added custom javascript converters that handle the JSON serializtion, and added them to the web.config as below:</p>
<pre><code><system.web.extensions>
<scripting>
<webServices>
<jsonSerialization>
<converters>
<add name="CustomClassConverter" type="Namespace.CustomClassConverter" />
</converters>
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
</code></pre>
<p>But this requires a custom converter for each class. Is there any other way to change the out of the box JSON serialization, either through extending the service, creating a custom serializer or the like?</p>
<p><b>Follow Up</b><br>
@marxidad:</p>
<p>We are using the DataContractJsonSerializer class in other applications, however I have been unable to figure out how to apply it to these services. Here's an example of how the services are set-up:</p>
<pre><code>[ScriptService]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
public CustomClass GetCustomClassMethod
{
return new customClass();
}
}
</code></pre>
<p>The WebMethods are called by javascript and return data serialized in JSON. The only method we have been able to change the serialization is to use the javascript converters as referenced above? </p>
<p>Is there a way to tell the WebService to use a custom DataContractJsonSerializer? Whether it be by web.config configuration, decorating the service with attributes, etc.? </p>
<p><b>Update</b><br>
Well, we couldn't find any way to switch the out of the box JavaScriptSerializer except for creating individual JavaScriptConverters as above.</p>
<p>What we did on that end to prevent having to create a separate converter was create a generic JavaScriptConverter. We added an empty interface to the classes we wanted handled and the SupportedTypes which is called on web-service start-up uses reflection to find any types that implement the interface kind of like this:</p>
<pre><code>public override IEnumerable<Type> SupportedTypes
{
get
{
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
AssemblyBuilder dynamicAssemblyCheck = assembly as AssemblyBuilder;
if (dynamicAssemblyCheck == null)
{
foreach (Type type in assembly.GetExportedTypes())
{
if (typeof(ICustomClass).IsAssignableFrom(type))
{
yield return type;
}
}
}
}
}
}
</code></pre>
<p>The actual implementation is a bit different so that the type are cached, and we will likely refactor it to use custom attributes rather than an empty interface.</p>
<p>However with this, we ran into a slightly different problem when dealing with custom collections. These typically just extend a generic list, but the custom classes are used instead of the List<> itself because there is generally custom logic, sorting etc. in the collection classes.</p>
<p>The problem is that the Serialize method for a JavaScriptConverter returns a dictionary which is serialized into JSON as name value pairs with the associated type, whereas a list is returned as an array. So the collection classes could not be easily serialized using the converter. The solution for this was to just not include those types in the converter's SupportedTypes and they serialize perfectly as lists.</p>
<p>So, serialization works, but when you try to pass these objects the other way as a parameter for a web service call, the deserialization breaks, because they can't be the input is treated as a list of string/object dictionaries, which can't be converted to a list of whatever custom class the collection contains. The only way we could find to deal with this is to create a generic class that is a list of string/object dictionaries which then converts the list to the appropriate custom collection class, and then changing any web service parameters to use the generic class instead.</p>
<p>I'm sure there are tons of issues and violations of "best practices" here, but it gets the job done for us without creating a ton of custom converter classes.</p>
| [
{
"answer_id": 159811,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 0,
"selected": false,
"text": "System.Runtime.Serialization.Json."
},
{
"answer_id": 159911,
"author": "Ty.",
"author_id": 8873,
"a... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4299/"
] |
159,705 | <p>I am checking whether the new name already exists or not.</p>
<p>Code 1</p>
<pre><code>if(cmbxExistingGroups.Properties.Items.Cast<string>().ToList().Exists(txt => txt==txtNewGroup.Text.Trim())) {
MessageBox.Show("already exists.", "Add new group");
}
</code></pre>
<p>Otherwise I could have written:</p>
<p>Code 2</p>
<pre><code>foreach(var str in cmbxExistingGroups.Properties.Items)
{
if(str==txtNewGroup.Text) {
MessageBox.Show("already exists.", "Add new group");
break;
}
}
</code></pre>
<p>I wrote these two and thought I was exploiting language features in code 1.</p>
<p>...and yes: both of them work for me ... I am wondering about the performance :-/</p>
| [
{
"answer_id": 159776,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "cmbxExistingGroups.Properties.Items.Contains(text) \n"
},
{
"answer_id": 159790,
"author": "FlySwat",
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22858/"
] |
159,720 | <p>Coming from a C# background the naming convention for variables and method names are usually either camelCase or PascalCase:</p>
<pre class="lang-cs prettyprint-override"><code>// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod()
</code></pre>
<p>In Python, I have seen the above but I have also seen underscores being used:</p>
<pre class="lang-py prettyprint-override"><code># python example
this_is_my_variable = 'a'
def this_is_my_function():
</code></pre>
<p>Is there a more preferable, definitive coding style for Python?</p>
| [
{
"answer_id": 159798,
"author": "André",
"author_id": 9683,
"author_profile": "https://Stackoverflow.com/users/9683",
"pm_score": 5,
"selected": false,
"text": "SomeClass.doSomething()"
},
{
"answer_id": 160830,
"author": "unmounted",
"author_id": 11596,
"author_prof... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
159,721 | <p>I would like to handle an OracleException thrown when my network/database connection is interrupted, where can I find out what error codes I might can receive?</p>
<p>I guess since we are talking about a connection interruption these would be technically TNS errors such as ORA-12560 "TNS:protocol adapter error." But I have noticed a couple others depending on where exactly the connection is lost and would like to get a full list.</p>
| [
{
"answer_id": 159770,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 1,
"selected": false,
"text": "ORA-12154 TNS:could not resolve service name\"\nORA-12203 TNS:unable to connect to destination\"\nORA-12500 TNS:listener ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
159,769 | <p>I have a complex query with group by and order by clause and I need a sorted row number (1...2...(n-1)...n) returned with every row. Using a ROWNUM (value is assigned to a row after it passes the predicate phase of the query but before the query does any sorting or aggregation) gives me a non-sorted list (4...567...123...45...). I cannot use application for counting and assigning numbers to each row.</p>
| [
{
"answer_id": 159779,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 5,
"selected": true,
"text": "SELECT rownum, a.* \n FROM (<<your complex query including GROUP BY and ORDER BY>>) a\n"
},
{
"answer_id": 159... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4235/"
] |
159,797 | <p>Wikipedia says Ruby is a functional language, but I'm not convinced. Why or why not?</p>
| [
{
"answer_id": 35512080,
"author": "Elias Perez",
"author_id": 5712328,
"author_profile": "https://Stackoverflow.com/users/5712328",
"pm_score": 4,
"selected": false,
"text": "mode"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] |
159,821 | <p>In an app I'm working on, I have a plain style UITableView that can contain a section containing zero rows. I want to be able to scroll to this section using scrollToRowAtIndexPath:atScrollPosition:animated: but I get an error when I try to scroll to this section due to the lack of child rows.</p>
<p>Apple's calendar application is able to do this, if you look at your calendar in list view, and there are no events in your calendar for today, an empty section is inserted for today and you can scroll to it using the Today button in the toolbar at the bottom of the screen. As far as I can tell Apple may be using a customized UITableView, or they're using a private API...</p>
<p>The only workaround I can think of is to insert an empty UITableCell in that's 0 pixels high and scroll to that. But it's my understanding that having cells of varying heights is really bad for scrolling performance. Still I'll try it anyway, maybe the performance hit won't be too bad.</p>
<p><strong>Update</strong></p>
<p>Since there seems to be no solution to this, I've filed a bug report with apple. If this affects you too, file a duplicate of rdar://problem/6263339 (<a href="http://openradar.appspot.com/radar?id=283" rel="noreferrer">Open Radar link)</a> if you want this to get this fixed faster.</p>
<p><strong>Update #2</strong></p>
<p>I have a decent workaround to this issue, take a look at my answer below.</p>
| [
{
"answer_id": 351109,
"author": "Mike Akers",
"author_id": 17188,
"author_profile": "https://Stackoverflow.com/users/17188",
"pm_score": 8,
"selected": true,
"text": "NSIndexPath"
},
{
"answer_id": 10782747,
"author": "Simon Tillson",
"author_id": 1416291,
"author_pr... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17188/"
] |
159,842 | <p>Often times when mixing jQuery with asp.net I need to use asp .net angle bracket percent, <% %>, syntax within a jQuery selector.</p>
<p>If I would like to separate the JavaScript from markup into different files is there still a way to evaluate my JavaScript file so the angle bracket percents are interpolated before reaching the client browser?</p>
| [
{
"answer_id": 159865,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 2,
"selected": false,
"text": "jQuery('#<%=MainPanel.ClientId%>').hide('slow');\n"
},
{
"answer_id": 159871,
"author": "Mark Cidade",
"autho... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4521/"
] |
159,853 | <p>I have some local changes to an open source project which uses Subversion as its source control. (I do not have commit access on the original project repository.)</p>
<p>My change adds a file, but this file is not included in the output of "svn diff". (It may be worth noting that the new file is a binary, not plain text.)</p>
<p>How can I make a <a href="http://en.wikipedia.org/wiki/Patch_(Unix)" rel="nofollow noreferrer">patch</a> which includes the new files?</p>
<hr>
<pre><code> $ svn st
A tests/foo.zip
$ svn diff
$
</code></pre>
| [
{
"answer_id": 1051396,
"author": "Balázs Pozsár",
"author_id": 119797,
"author_profile": "https://Stackoverflow.com/users/119797",
"pm_score": 4,
"selected": false,
"text": "svn diff --force --diff-cmd /usr/bin/diff -x -au\n"
},
{
"answer_id": 2255846,
"author": "Jason Favor... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17732/"
] |
159,856 | <p>I am running NUnit with the project named AssemblyTest.nunit. The test calls another assembly which uses the log4net assembly. This is using nunit version 2.4.3 with the .net 2.0 framework.</p>
<p>In TestFixtureSetup I am calling log4net.Config.XmlConfigurator.Configure( ) and am getting the following error:</p>
<pre>
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section log4net. (C:\path\to\assembly.dll.config line 7)
</pre>
<p>Is there a way to fix this without renaming the config file to 'AssemblyTest.config'?</p>
| [
{
"answer_id": 9032281,
"author": "Christoph Brückmann",
"author_id": 909980,
"author_profile": "https://Stackoverflow.com/users/909980",
"pm_score": 4,
"selected": false,
"text": "<configuration>\n <configSections>\n <section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurati... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24174/"
] |
159,862 | <p>Short of cutting and pasting, is there a way to sort the methods in my classes in Visual Studio 2008? I like orderly code.</p>
| [
{
"answer_id": 2539697,
"author": "Handcraftsman",
"author_id": 102536,
"author_profile": "https://Stackoverflow.com/users/102536",
"pm_score": 2,
"selected": false,
"text": "<!--Fixture Setup/Teardown-->\n<Entry>\n <Match>\n <And>\n <Kind Is=\"method\"/>\n <Or>\n <H... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16415/"
] |
159,864 | <p>I'm working on a control to tie together the view from one ListView to another so that when the master ListView is scrolled, the child ListView view is updated to match. </p>
<p>So far I've been able to get the child ListViews to update their view when the master scrollbar buttons are clicked. The problem is that when clicking and dragging the ScrollBar itself, the child ListViews are not updated. I've looked at the messages being sent using Spy++ and the correct messages are getting sent. </p>
<p>Here is my current code:</p>
<pre><code>public partial class LinkedListViewControl : ListView
{
[DllImport("User32.dll")]
private static extern bool SendMessage(IntPtr hwnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
[DllImport("User32.dll")]
private static extern bool ShowScrollBar(IntPtr hwnd, int wBar, bool bShow);
[DllImport("user32.dll")]
private static extern int SetScrollPos(IntPtr hWnd, int wBar, int nPos, bool bRedraw);
private const int WM_HSCROLL = 0x114;
private const int SB_HORZ = 0;
private const int SB_VERT = 1;
private const int SB_CTL = 2;
private const int SB_BOTH = 3;
private const int SB_THUMBPOSITION = 4;
private const int SB_THUMBTRACK = 5;
private const int SB_ENDSCROLL = 8;
public LinkedListViewControl()
{
InitializeComponent();
}
private readonly List<ListView> _linkedListViews = new List<ListView>();
public void AddLinkedView(ListView listView)
{
if (!_linkedListViews.Contains(listView))
{
_linkedListViews.Add(listView);
HideScrollBar(listView);
}
}
public bool RemoveLinkedView(ListView listView)
{
return _linkedListViews.Remove(listView);
}
private void HideScrollBar(ListView listView)
{
//Make sure the list view is scrollable
listView.Scrollable = true;
//Then hide the scroll bar
ShowScrollBar(listView.Handle, SB_BOTH, false);
}
protected override void WndProc(ref Message msg)
{
if (_linkedListViews.Count > 0)
{
//Look for WM_HSCROLL messages
if (msg.Msg == WM_HSCROLL)
{
foreach (ListView view in _linkedListViews)
{
SendMessage(view.Handle, WM_HSCROLL, msg.WParam, IntPtr.Zero);
}
}
}
}
}
</code></pre>
<p>Based on <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3111420&SiteID=1" rel="nofollow noreferrer">this post</a> on the MS Tech Forums I tried to capture and process the SB_THUMBTRACK event:</p>
<pre><code> protected override void WndProc(ref Message msg)
{
if (_linkedListViews.Count > 0)
{
//Look for WM_HSCROLL messages
if (msg.Msg == WM_HSCROLL)
{
Int16 hi = (Int16)((int)msg.WParam >> 16);
Int16 lo = (Int16)msg.WParam;
foreach (ListView view in _linkedListViews)
{
if (lo == SB_THUMBTRACK)
{
SetScrollPos(view.Handle, SB_HORZ, hi, true);
int wParam = 4 + 0x10000 * hi;
SendMessage(view.Handle, WM_HSCROLL, (IntPtr)(wParam), IntPtr.Zero);
}
else
{
SendMessage(view.Handle, WM_HSCROLL, msg.WParam, IntPtr.Zero);
}
}
}
}
// Pass message to default handler.
base.WndProc(ref msg);
}
</code></pre>
<p>This will update the location of the child ListView ScrollBar but does not change the actual view in the child.</p>
<p>So my questions are: </p>
<ol>
<li>Is it possible to update the child ListViews when the master ListView ScrollBar is dragged?</li>
<li>If so, how?</li>
</ol>
| [
{
"answer_id": 167089,
"author": "Rob Allen",
"author_id": 149,
"author_profile": "https://Stackoverflow.com/users/149",
"pm_score": 1,
"selected": false,
"text": "masterList.Scroll += new ScrollEventHandler(this.masterList_scroll);\n"
},
{
"answer_id": 175553,
"author": "Jer... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1314/"
] |
159,886 | <p>I've seen this is various codebases, and wanted to know if this generally frowned upon or not.</p>
<p>For example:</p>
<pre><code>public class MyClass
{
public int Id;
public MyClass()
{
Id = new Database().GetIdFor(typeof(MyClass));
}
}
</code></pre>
| [
{
"answer_id": 159921,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 3,
"selected": false,
"text": "public class MyClass : IDisposable\n{\n private Database db;\n private int? _id;\n\n public MyClass()\n {\n ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5619/"
] |
159,888 | <p>You're stepping through C/C++ code and have just called a Win32 API that has failed (typically by returning some unhelpful generic error code, like 0). Your code doesn't make a subsequent GetLastError() call whose return value you could inspect for further error information.</p>
<p>How can you get the error value without recompiling and reproducing the failure? Entering "GetLastError()" in the Watch window doesn't work ("syntax error").</p>
| [
{
"answer_id": 159898,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": 3,
"selected": false,
"text": "ERR,hr"
},
{
"answer_id": 160024,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4994/"
] |
159,889 | <p>I'm developing an iPhone app that uses the built-in SQLite database. I'm trying to view and open the database via the <code>sqlite3</code> command line tool so I can execute arbitrary SQL against it.</p>
<p>When I run my app in the simulator, the <code>.sqlite</code> file it creates is located at <code>~/Library/Application Support/iPhone Simulator/User/Applications/</code>.</p>
<p>How can I see that file on the physical iPhone?</p>
| [
{
"answer_id": 14472700,
"author": "abbood",
"author_id": 766570,
"author_profile": "https://Stackoverflow.com/users/766570",
"pm_score": 1,
"selected": false,
"text": "which sqlite3"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] |
159,910 | <p>Is there a way my program can determine when it's running on a Remote Desktop (Terminal Services)?</p>
<p>I'd like to enable an "inactivity timeout" on the program when it's running on a Remote Desktop session. Since users are notorious for leaving Remote Desktop sessions open, I want my program to terminate after a specified period of inactivity. But, I don't want the inactivity timeout enabled for non-RD users.</p>
| [
{
"answer_id": 241176,
"author": "Ian Boyd",
"author_id": 12597,
"author_profile": "https://Stackoverflow.com/users/12597",
"pm_score": 4,
"selected": false,
"text": "/// <summary>\n/// Indicates if we're running in a remote desktop session.\n/// If we are, then you MUST disable animatio... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8752/"
] |
159,914 | <p>Does anybody know a way with JavaScript or CSS to basically grey out a certain part of a form/div in HTML?</p>
<p>I have a '<em>User Profile</em>' form where I want to disable part of it for a '<em>Non-Premium</em>' member, but want the user to see what is behind the form and place a '<em>Call to Action</em>' on top of it.</p>
<p>Does anybody know an easy way to do this either via CSS or JavaScript?</p>
<p>Edit: I will make sure that the form doesn't work on server side so CSS or JavaScript will suffice.</p>
| [
{
"answer_id": 159962,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 6,
"selected": false,
"text": "<div id=\"darkLayer\" class=\"darkClass\" style=\"display:none\"></div>\n"
},
{
"answer_id": 159989,
"author"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8534/"
] |
159,924 | <p>I'm slowly moving all of my <code>LAMP websites</code> from <code>mysql_</code> functions to <code>PDO</code> functions and I've hit my first brick wall. I don't know how to loop through results with a parameter. I am fine with the following:</p>
<pre><code>foreach ($database->query("SELECT * FROM widgets") as $results)
{
echo $results["widget_name"];
}
</code></pre>
<p>However if I want to do something like this:</p>
<pre><code>foreach ($database->query("SELECT * FROM widgets WHERE something='something else'") as $results)
{
echo $results["widget_name"];
}
</code></pre>
<p>Obviously the 'something else' will be dynamic.</p>
| [
{
"answer_id": 159967,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 3,
"selected": false,
"text": "$sql = \"SELECT * FROM widgets WHERE something='something else'\";\nforeach ($database->query($sql) as $row) {\n echo ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] |
159,926 | <p>My company unwittingly switched from cvs to subversion and now we're all wishing we had cvs back.
I know there's tools to migrate history and changes from cvs to svn and there's no equivalent to do the reverse.
Any suggestions or ideas on how to do this?</p>
| [
{
"answer_id": 2641628,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 1,
"selected": false,
"text": "git svn clone http://thesvnserver ourrepo\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12386/"
] |
159,928 | <p>I want to change/animate the Foreground property of a custom button control template depending on the control's state.</p>
<p>Pre-RC0, I set the Foreground of the ContentPresenter, gave it an x:Name, and referenced it in the VisualStateManager transitions.</p>
<p>Now, ContentPresenter no longer has a Foreground, since it doesn't inherit from Control anymore. Usually, I would set the Foreground in the Style which is applied to the templated control. But I cannot reference that from the VisualStateManager transitions / states. I also cannot wrap it in a TextBlock which has the Foreground property set, and (<strong>edit:</strong>) Border has no Foreground property.</p>
<p>Help is greatly appreciated.</p>
<h3>Update:</h3>
<p>I can solve the problem for some of the removed properties with a Border, but not those relating to font/text, including Foreground.</p>
<p>Since it doesn't seem possible, in my particular case I was able to replace the ContentPresenter with a TextBlock.</p>
| [
{
"answer_id": 1232348,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<ControlTemplate TargetType=\"{x:Type ButtonBase}\">\n <ContentControl Content=\"{TemplateBinding Content}\" Foreground=\"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23222/"
] |
159,934 | <p>How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have a one to many from the sire or dame to its offspring. I would be inclined to something like this:</p>
<pre><code>ID INT NOT NULL PRIMARY KEY
SIRE_ID INT
DAME_ID INT
</code></pre>
<p>and record a null value for those animals which were purchased and added to the breeding stock and an ID in the table for the rest. </p>
<p>So:</p>
<ol>
<li>Can someone point me to an
article/web page that discusses
modeling this sort of relationship?</li>
<li>Should the ID be an INT or some sort
of String? A NULL in the INT would
indicate that the animal has no
parents in the database but a String
with special flag values could be
used to indicate the same thing.</li>
<li><p>Would this possibly be best modeled
via two tables? I mean one table
for the animals and a separate
table solely indicating kinship e. g.:</p>
<p>Animal</p>
<p>ID INT NOT NULL PRIMARY KEY</p>
<p>Kinship</p>
<p>ID INT NOT NULL PRIMARY KEY FOREIGN KEY</p>
<p>SIRE_ID INT PRIMARY KEY FOREIGN KEY</p>
<p>DAME_ID INT PRIMARY KEY FOREIGN KEY</p></li>
</ol>
<p>I apologize for the above: my SQL is rusty. I hope it sort of conveys what I'm thinking about. </p>
| [
{
"answer_id": 159997,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 2,
"selected": false,
"text": "ID INT NOT NULL PRIMARY KEY\nSIRE_ID INT REFERENCES TABLENAME (ID)\nDAME_ID INT REFERENCES TABLENAME (ID)\n"
},
{
"a... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] |
159,950 | <p>How do I change the system-wide short date format in Ubuntu? For example, Thunderbird is showing dates in the DD/MM/YY format, and I would like to change it to MM/DD/YY or YYYY-MM-DD.</p>
<p>The best information I can find so far is in this thread:</p>
<p><a href="http://ubuntuforums.org/showthread.php?t=193916" rel="noreferrer">http://ubuntuforums.org/showthread.php?t=193916</a></p>
<p>Edit: I want to change the system-wide date format, so that all my applications use this new date format.</p>
| [
{
"answer_id": 160036,
"author": "agnul",
"author_id": 6069,
"author_profile": "https://Stackoverflow.com/users/6069",
"pm_score": 1,
"selected": false,
"text": "LC_TIME"
},
{
"answer_id": 46157865,
"author": "Nishi",
"author_id": 211369,
"author_profile": "https://St... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24311/"
] |
159,978 | <p>What are differences between declaring a method in a base type "<code>virtual</code>" and then overriding it in a child type using the "<code>override</code>" keyword as opposed to simply using the "<code>new</code>" keyword when declaring the matching method in the child type? </p>
| [
{
"answer_id": 159993,
"author": "albertein",
"author_id": 23020,
"author_profile": "https://Stackoverflow.com/users/23020",
"pm_score": 9,
"selected": true,
"text": "public class Foo\n{\n public bool DoSomething() { return false; }\n}\n\npublic class Bar : Foo\n{\n public new bo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9898/"
] |
159,983 | <p>In C++, on Linux, how can I write a function to return a temporary filename that I can then open for writing?</p>
<p>The filename should be as unique as possible, so that another process using the same function won't get the same name.</p>
| [
{
"answer_id": 160008,
"author": "twk",
"author_id": 23524,
"author_profile": "https://Stackoverflow.com/users/23524",
"pm_score": 3,
"selected": false,
"text": " #include <stdio.h>\n\n FILE *tmpfile(void);\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/159983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16976/"
] |
159,990 | <p>I've done some Python but have just now starting to use Ruby<br>
I could use a good explanation of the difference between "self" in these two languages. </p>
<p><strong>Obvious on first glance:</strong><br>
Self is not a keyword in Python, but there is a "self-like" value no matter what you call it.<br>
Python methods receive self as an explicit argument, whereas Ruby does not.<br>
Ruby sometimes has methods explicitly defined as part of self using dot notation.</p>
<p><strong>Initial Googling reveals</strong><br>
<a href="http://rubylearning.com/satishtalim/ruby_self.html" rel="noreferrer">http://rubylearning.com/satishtalim/ruby_self.html</a><br>
<a href="http://www.ibiblio.org/g2swap/byteofpython/read/self.html" rel="noreferrer">http://www.ibiblio.org/g2swap/byteofpython/read/self.html</a> </p>
| [
{
"answer_id": 160017,
"author": "interstar",
"author_id": 8482,
"author_profile": "https://Stackoverflow.com/users/8482",
"pm_score": 3,
"selected": false,
"text": "class X :\n def __init__(a,val) :\n a.x = val\n def p(b) :\n print b.x\n\nx = X(6)\nx.p()\n"
},
{
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2242/"
] |
160,009 | <p>I went to all the documentation, also I went to the IRC channel (BTW a great community) and they told me that is not possible to create a model and limit choices in a field where the 'current user' is in a ForeignKey.
I will try to explain this with an example:</p>
<pre><code>class Project(models.Model):
name = models.CharField(max_length=100)
employees = models.ManyToManyField(Profile, limit_choices_to={'active': '1'})
class TimeWorked(models.Model):
project = models.ForeignKey(Project, limit_choices_to={'user': user})
hours = models.PositiveIntegerField()
</code></pre>
<p>Of course that code doesn't work because there is no 'user' object, but that was my idea and I was trying to send the object 'user' to the model to just limit the choices where the current user has projects, I don't want to see projects where I'm not in.</p>
<p>Thank you very much if you can help me or give me any advice, I don't want to you write all the app, just a tip how to deal with that. I have 2 days with this in my head and I can't figure it out :(</p>
<p><strong>UPDATE</strong>: The solution is here: <a href="http://collingrady.wordpress.com/2008/07/24/useful-form-tricks-in-django/" rel="noreferrer">http://collingrady.wordpress.com/2008/07/24/useful-form-tricks-in-django/</a> sending <code>request.user</code> to a model.</p>
| [
{
"answer_id": 160421,
"author": "ilvar",
"author_id": 1215136,
"author_profile": "https://Stackoverflow.com/users/1215136",
"pm_score": 2,
"selected": false,
"text": "choices"
},
{
"answer_id": 161615,
"author": "Dmitry Shevchenko",
"author_id": 7437,
"author_profile... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16342/"
] |
160,016 | <p>Following the development of Ruby very closely I learned that detailed character encoding is implemented in Ruby 1.9. My question for now is: How may Ruby be used at the moment to talk to a database that stores all data in UTF8?</p>
<p>Background: I am involved in a new project where Ruby/RoR is at least an option. But the project needs to rely on an internationalized character set (it's spread over many countries), preferably UTF8.</p>
<p>So how do you deal with that? Thanks in advance.</p>
| [
{
"answer_id": 160372,
"author": "A. Morrow",
"author_id": 10140,
"author_profile": "https://Stackoverflow.com/users/10140",
"pm_score": 0,
"selected": false,
"text": "file.txt:\n¡Hola! ¿Como estás? Leí el artículo. ¡Fue muy excellente!\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/160016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13209/"
] |
160,022 | <p>Is there anyway to determine if a ResourceManager contains a named resource? Currently I am catching the MissingManifestResourceException but I hate having to use Exceptions for non-exceptional situations. There must be some way to enumerate the name value pairs of a ResourceManager through reflection, or something?</p>
<p><strong>EDIT</strong>: A little more detail. The resources are not in executing assembly, however the ResourceManager is working just fine. If I try <code>_resourceMan.GetResourceSet(_defaultCuture, false, true)</code> I get null, whereas if I try <code>_resourceMan.GetString("StringExists")</code> I get a string back.</p>
| [
{
"answer_id": 162013,
"author": "Jonathan C Dickinson",
"author_id": 24064,
"author_profile": "https://Stackoverflow.com/users/24064",
"pm_score": 6,
"selected": true,
"text": " // At startup.\n ResourceManager mgr = Resources.ResourceManager;\n List<string> keys = new List<str... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3798/"
] |
160,030 | <p>Is there a macro that does it? Which DTE objects to use?</p>
| [
{
"answer_id": 160839,
"author": "Andrei Belogortseff",
"author_id": 17037,
"author_profile": "https://Stackoverflow.com/users/17037",
"pm_score": -1,
"selected": false,
"text": "#define WANT_BREAK_IN_EVERY_FUNCTION\n\n#ifdef WANT_BREAK_IN_EVERY_FUNCTION\n#define DEBUG_BREAK DebugBreak()... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20310/"
] |
160,045 | <p>Is there a way to place a watch on variable and only have Visual Studio break when that value changes?</p>
<p>It would make it so much easier to find tricky state issues.</p>
<p>Can this be done?</p>
<p>Breakpoint conditions still need a breakpoint set, and I'd rather set a watch and let Visual Studio set the breakpoints at state changes.</p>
| [
{
"answer_id": 160074,
"author": "AShelly",
"author_id": 10396,
"author_profile": "https://Stackoverflow.com/users/10396",
"pm_score": 8,
"selected": true,
"text": "&myVariable\n"
},
{
"answer_id": 160107,
"author": "Michael Petrotta",
"author_id": 23897,
"author_prof... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
160,051 | <p>I'm working on a database that needs to represent computers and their users. Each computer can have multiple users and each user can be associated with multiple computers, so it's a classic many-to-many relationship. However, there also needs to be a concept of a "primary" user. I have to be able to join against the primary user to list all computers with their primary users. I'm not sure what the best way structure this in the database:</p>
<p>1) As I'm currently doing: linking table with a boolean IsPrimary column. Joining requires something like ON (c.computer_id = l.computer_id AND l.is_primary = 1). It works, but it feels wrong because it's not easy to constrain the data to only have one primary user per computer.</p>
<p>2) A field on the computer table that points directly at a user row, all rows in the user table represent non-primary users. This represents the one-primary-per-computer constraint better, but makes getting a list of computer-users harder.</p>
<p>3) A field on the computer table linking to a row in the linking table. Feels strange...</p>
<p>4) Something else?</p>
<p>What is the 'relational' way to describe this relationship?</p>
<p>EDIT:
@Mark Brackett: The third option seems a lot less strange to me now that you've shown how nice it can look. For some reason I didn't even think of using a compound foreign key, so I was thinking I'd have to add an identity column on the linking table to make it work. Looks great, thanks! </p>
<p>@j04t: Cool, I'm glad we agree on #3 now.</p>
| [
{
"answer_id": 160073,
"author": "Swati",
"author_id": 12682,
"author_profile": "https://Stackoverflow.com/users/12682",
"pm_score": 0,
"selected": false,
"text": "computer_id"
},
{
"answer_id": 160108,
"author": "Simurr",
"author_id": 3478,
"author_profile": "https:/... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9617/"
] |
160,082 | <p>There are a ton of drivers & famous applications that are not available in 64-bit. Adobe for instance does not provider a 64-bit Flash player plugin for Internet Explorer. And because of that, even though I am running 64-bit Vista, I have to run 32-bit IE. Microsoft Office, Visual Studio also don't ship in 64-bit AFAIK.</p>
<p>Now personally, I haven't had much problems building my applications in 64-bit. I just have to remember a few rules of thumb, e.g. always use SIZE_T instead of UINT32 for string lengths etc.</p>
<p>So my question is, what is preventing people from building for 64-bit?</p>
| [
{
"answer_id": 160139,
"author": "jvasak",
"author_id": 5840,
"author_profile": "https://Stackoverflow.com/users/5840",
"pm_score": 4,
"selected": false,
"text": "long"
},
{
"answer_id": 160192,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15071/"
] |
160,097 | <p>Pardon my ASP ignorance, but what's the difference?</p>
| [
{
"answer_id": 160117,
"author": "Swati",
"author_id": 12682,
"author_profile": "https://Stackoverflow.com/users/12682",
"pm_score": 5,
"selected": true,
"text": "<%# %>"
},
{
"answer_id": 160205,
"author": "wangzq",
"author_id": 10564,
"author_profile": "https://Stac... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] |
160,104 | <p>I've been using this long command:</p>
<pre><code>svn st | awk '/\?/ {print $2}' | xargs svn add
</code></pre>
<p>Similarly, to svn rm files I accidentally deleted with normal rm with :</p>
<pre><code>svn st | awk '/\!/ {print $2}' | xargs svn rm --force
</code></pre>
<p>I guess I can write a bash function to do these two, but I'd prefer an interactive add/rm like the one git has.</p>
| [
{
"answer_id": 160177,
"author": "Brandon DuRette",
"author_id": 17834,
"author_profile": "https://Stackoverflow.com/users/17834",
"pm_score": 3,
"selected": false,
"text": "svnapply.sh"
},
{
"answer_id": 1515401,
"author": "Mark Shust",
"author_id": 183810,
"author_p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13200/"
] |
160,105 | <p>How do you change controls' Z-order in MFC <strong>at design time</strong> - i.e. I can't use SetWindowPos or do this at runtime - I want to see the changed z-order in the designer (even if I have to resort to direct-editing the .rc code).</p>
<p>I have an MFC dialog to which I am adding controls. If there is overlap between the edges of the controls, I want to bring one to the front of the other. In Windows Forms or WPF, etc. I can Bring to Front, Send to Back, Bring Forward, Send Back. I don't find these options in MFC, nor can I tell how it determines what is in front, as a control just added is often behind a control that was there previously. How can I manipulate the Z-order in MFC? Even if I have to manipulate the .rc file code directly (i.e. end-run around the designer).</p>
| [
{
"answer_id": 160119,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 3,
"selected": false,
"text": "GetDlgItem(IDC_MYCONTROL)->SetWindowPos(HWND_TOP,\n 0, 0, 0, 0,\n ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8787/"
] |
160,106 | <p>What is the correct way to implement the "find as you type" behavior on a TComboBox descendant component whose style is csOwnerDrawFixed?</p>
| [
{
"answer_id": 161065,
"author": "John Thomas",
"author_id": 22599,
"author_profile": "https://Stackoverflow.com/users/22599",
"pm_score": 1,
"selected": false,
"text": "with timIncSearch do\n begin\n Enabled:=False;\n Enabled:=True;\n end;"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/160106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16120/"
] |
160,118 | <p>I have a class with both a static and a non-static interface in C#. Is it possible to have a static and a non-static method in a class with the same name and signature?</p>
<p>I get a compiler error when I try to do this, but for some reason I thought there was a way to do this. Am I wrong or is there no way to have both static and non-static methods in the same class?</p>
<p>If this is not possible, is there a good way to implement something like this that can be applied generically to any situation?</p>
<p><strong>EDIT</strong><br>
From the responses I've received, it's clear that there is no way to do this. I'm going with a different naming system to work around this problem.</p>
| [
{
"answer_id": 160133,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": false,
"text": "class Foo\n{\n static void Bar()\n {\n }\n\n void Fizz()\n {\n Bar();\n }\n}\n"
},
{
"a... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
160,141 | <p>C# novice here, when the int 'max' below is 0 I get a divide by zero error, I can see why this happens but how should I handle this when max is 0? position is also an int.</p>
<pre><code> private void SetProgressBar(string text, int position, int max)
{
try
{
int percent = (100 * position) / max; //when max is 0 bug hits
string txt = text + String.Format(". {0}%", percent);
SetStatus(txt);
}
catch
{
}
}
</code></pre>
| [
{
"answer_id": 160146,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": 4,
"selected": false,
"text": "int percent = 0\nif (max != 0) percent = (100*position) / max\n"
},
{
"answer_id": 160148,
"author": "palehorse"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
160,144 | <p>How can I find the XY coordinates of an HTML element (DIV) from JavaScript if they were not explicitly set?</p>
| [
{
"answer_id": 160189,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 3,
"selected": false,
"text": "myPos = findPos(document.getElementById('something'))\nx = myPos[0]\ny = myPos[1]\n\nfunction findPos(o... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
160,147 | <p>Here's a curious one. I have a class A. It has an item of class B, which I want to initialize in the constructor of A using an initializer list, like so:</p>
<pre><code>class A {
public:
A(const B& b): mB(b) { };
private:
B mB;
};
</code></pre>
<p>Is there a way to catch exceptions that might be thrown by mB's copy-constructor while still using the initializer list method? Or would I have to initialize mB within the constructor's braces in order to have a try/catch?</p>
| [
{
"answer_id": 160164,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 8,
"selected": true,
"text": "C::C()\ntry : init1(), ..., initn()\n{\n // Constructor\n}\ncatch(...)\n{\n // Handle exception\n}\n"
},
{
"ans... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12193/"
] |
160,175 | <p>If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have
$f->{$x}{$y}, I want something like</p>
<pre><code>foreach ($x, $y) (deep_keys %{$f})
{
}
</code></pre>
<p>instead of </p>
<pre><code>foreach $x (keys %f)
{
foreach $y (keys %{$f->{$x})
{
}
}
</code></pre>
| [
{
"answer_id": 160210,
"author": "Axeman",
"author_id": 11289,
"author_profile": "https://Stackoverflow.com/users/11289",
"pm_score": 1,
"selected": false,
"text": "\"$level1_key.$level2_key.$level3_key\""
},
{
"answer_id": 160270,
"author": "Zan Lynx",
"author_id": 13422... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14167/"
] |
160,204 | <p>I'm a Linux guy and I'm used to copying directory trees with <code>cp -a</code>. OS X doesn't have <code>-a</code> option on <code>cp</code>... but it does have the <code>ditto</code> command. I'm reading the man on <code>ditto</code> now, but is there anything I should specifically be looking out for?</p>
| [
{
"answer_id": 160242,
"author": "wprl",
"author_id": 17847,
"author_profile": "https://Stackoverflow.com/users/17847",
"pm_score": 0,
"selected": false,
"text": "cp -pR"
},
{
"answer_id": 160260,
"author": "joelhardi",
"author_id": 11438,
"author_profile": "https://S... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601671/"
] |
160,214 | <p>I am trying to get the value of some ListViewSubItems, but I have no idea what values it uses for its keys. I have some simple code:</p>
<pre><code> protected override void OnItemDrag(ItemDragEventArgs e)
{
base.OnItemDrag(e);
ListViewItem item = e.Item as ListViewItem;
string val = item.SubItems[???].ToString();
}
</code></pre>
<p>The ??? part is where I am having a problem. I cannot figure out what the keys are. I have tried the column names of the ListView with no luck. I would like to use this method instead of using numeric indices. </p>
| [
{
"answer_id": 160235,
"author": "dguaraglia",
"author_id": 2384,
"author_profile": "https://Stackoverflow.com/users/2384",
"pm_score": 0,
"selected": false,
"text": "protected override void OnItemDrag(ItemDragEventArgs e)\n{\n base.OnItemDrag(e); \n ListViewItem item = ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1053/"
] |
160,216 | <p>I'd like something like this:</p>
<pre><code>each[i_, {1,2,3},
Print[i]
]
</code></pre>
<p>Or, more generally, to destructure arbitrary stuff in the list you're looping over, like:</p>
<pre><code>each[{i_, j_}, {{1,10}, {2,20}, {3,30}},
Print[i*j]
]
</code></pre>
<p>Usually you want to use <code>Map</code> or other purely functional constructs and eschew a non-functional programming style where you use side effects. But here's an example where I think a for-each construct is supremely useful: </p>
<p>Say I have a list of options (rules) that pair symbols with expressions, like</p>
<pre><code>attrVals = {a -> 7, b -> 8, c -> 9}
</code></pre>
<p>Now I want to make a hash table where I do the obvious mapping of those symbols to those numbers. I don't think there's a cleaner way to do that than</p>
<pre><code>each[a_ -> v_, attrVals, h[a] = v]
</code></pre>
<h2>Additional test cases</h2>
<p>In this example, we transform a list of variables:</p>
<pre><code>a = 1;
b = 2;
c = 3;
each[i_, {a,b,c}, i = f[i]]
</code></pre>
<p>After the above, <code>{a,b,c}</code> should evaluate to <code>{f[1],f[2],f[3]}</code>. Note that that means the second argument to <code>each</code> should be held unevaluated if it's a list.</p>
<p>If the unevaluated form is not a list, it should evaluate the second argument. For example:</p>
<pre><code>each[i_, Rest[{a,b,c}], Print[i]]
</code></pre>
<p>That should print the values of <code>b</code> and <code>c</code>.</p>
<p><strong>Addendum</strong>: To do for-each properly, it should support <code>Break[]</code> and <code>Continue[]</code>. I'm not sure how to implement that. Perhaps it will need to somehow be implemented in terms of For, While, or Do since those are the only loop constructs that support <code>Break[]</code> and <code>Continue[]</code>.</p>
<p>And another problem with the answers so far: they eat <code>Return[]</code>s. That is, if you are using a ForEach loop in a function and want to return from the function from within the loop, you can't. Issuing Return inside the ForEach loop seems to work like <code>Continue[]</code>. This just (wait for it) threw me for a loop.</p>
| [
{
"answer_id": 160219,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": false,
"text": "Scan"
},
{
"answer_id": 1260797,
"author": "Pillsy",
"author_id": 85467,
"author_profile": "https://Stac... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] |
160,218 | <p>I'm personally an advocate of the <a href="https://en.wikipedia.org/wiki/%3F:" rel="nofollow noreferrer">ternary operator</a>: <code>() ? : </code></p>
<p>I do realize that it has its place, but I have come across many programmers that are completely against ever using it, and some that use it too often.</p>
<p>What are your feelings on it? What interesting code have you seen using it?</p>
| [
{
"answer_id": 160231,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 3,
"selected": false,
"text": "var e = new XElement(\"Something\",\n param == null ? new XElement(\"Value\", \"Default\")\n : new... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21804/"
] |
160,222 | <p>I have a simple web form that has a several fields and a gridview on it. I also have a save and cancel button. </p>
<p>I would like a way to undo what was done to the data on the form when the user presses cancel. This is simple enough with the fields however since changes to the gridview happen in real time against the database I do not know how to get undo functionality.</p>
<p>I have thought of storing the changes to gridview in viewstate but I would rather not because of the extra space requirement. </p>
<p>I have also thought of a temporary table that would stored the changes then roll them back as needed.</p>
<p>Does anyone have an idea how to get undo functionality from the form?</p>
| [
{
"answer_id": 160285,
"author": "Keith Williams",
"author_id": 20376,
"author_profile": "https://Stackoverflow.com/users/20376",
"pm_score": 0,
"selected": false,
"text": "(MyObject)Session[\"MyObject\"]"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/160222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22264/"
] |
160,233 | <p>I tried this in mysql:</p>
<pre><code>mysql> alter table region drop column country_id;
</code></pre>
<p>And got this:</p>
<pre><code>ERROR 1025 (HY000): Error on rename of './product/#sql-14ae_81' to
'./product/region' (errno: 150)
</code></pre>
<p>Any ideas? Foreign key stuff?</p>
| [
{
"answer_id": 179501,
"author": "Harrison Fisk",
"author_id": 16111,
"author_profile": "https://Stackoverflow.com/users/16111",
"pm_score": 7,
"selected": false,
"text": "shell$ perror 150\nMySQL error code 150: Foreign key constraint is incorrectly formed\n"
},
{
"answer_id": 1... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601671/"
] |
160,245 | <p>I'm trying:</p>
<pre><code>import commands
print commands.getoutput("ps -u 0")
</code></pre>
<p>But it doesn't work on os x.
os instead of commands gives the same output:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND</p>
<p>nothing more</p>
| [
{
"answer_id": 160271,
"author": "jmissao",
"author_id": 20883,
"author_profile": "https://Stackoverflow.com/users/20883",
"pm_score": 0,
"selected": false,
"text": "import os\nprint os.system(\"ps -u 0\")\n"
},
{
"answer_id": 160284,
"author": "Thomas Wouters",
"author_i... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] |
160,250 | <p>Just that, if you embed an icon:</p>
<pre><code>[Embed(source='icons/checkmark.png')]
private static var CheckMark:Class;
</code></pre>
<p>You end up with a dynamic class. You can pretty easily assign the icon to a button at runtime by calling the setStyle method:</p>
<pre><code>var btn:Button = new Button();
btn.setStyle("icon", CheckMark);
</code></pre>
<p>But what if you wanted to alter the icon at runtime, like changing it's alpha value or even redrawing pixels, before assigning it to the button?</p>
<p>So far I can't find a satisfactory answer...</p>
| [
{
"answer_id": 163586,
"author": "Aaron",
"author_id": 23965,
"author_profile": "https://Stackoverflow.com/users/23965",
"pm_score": 0,
"selected": false,
"text": "button.setStyle(\"customIconAlpha\", .4);\n"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/160250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16258/"
] |
160,290 | <p>After I call <code>getpwuid(uid)</code>, I have a reference to a pointer. Should I free that pointer when I don't use it anymore? Reading the man pages, it says that it makes reference to some static area, that may be overwritten by subsequent calls to the same functions, so I'm not sure if I should touch that memory area.</p>
<p>Thanks.</p>
| [
{
"answer_id": 162233,
"author": "Steve Baker",
"author_id": 13566,
"author_profile": "https://Stackoverflow.com/users/13566",
"pm_score": 3,
"selected": false,
"text": "*_r"
}
] | 2008/10/01 | [
"https://Stackoverflow.com/questions/160290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11384/"
] |
160,292 | <p>I'm writing a library which is to be dynamically loaded in C++. </p>
<p>I'd like to read argc and argv (for debugging reasons) from within my code, however I do not have access to the main function. Is there any way to retrieve the command line (both Windows and Linux solution would be nice).</p>
<p>Thanks,
Dan</p>
| [
{
"answer_id": 160632,
"author": "Shadow2531",
"author_id": 1697,
"author_profile": "https://Stackoverflow.com/users/1697",
"pm_score": 1,
"selected": false,
"text": "\n#include <windows.h>\n#include <string>\n#include <vector>\n#include <cwchar>\n#include <cstdio>\n#include <clocale>\nu... | 2008/10/01 | [
"https://Stackoverflow.com/questions/160292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.