qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
311,504
<p>In Firefox and Safari, pages that are centered move a few pixels when the page is long enough for the scrollbar to appear. If you navigate through a site that has long and short pages, the page seems to "jump" around.</p> <p>IE7 tends to leave the scroll bar visible all of the time but disables it when the page is not long enough. Since the width of the HTML window never changes the centering of the page doesn't change.</p> <p>Is there a workaround or a way to style the page so it doesn't jump around in Firefox and Safari?</p> <p>Thanks.</p>
[ { "answer_id": 311514, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 5, "selected": true, "text": "html{\n overflow: scroll;\n}\n" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30552/" ]
311,543
<p>Edit:</p> <p>I don't know what this user originally wanted, and hopefully they'll edit their question to let us know, but otherwise, let's use this question to answer (or give links to) the following common console window issues:</p> <ul> <li>How do you capture the output of a console application in your program (for instance, running a build process and getting the output in your IDE)?</li> <li>How do you get your console application to hang around long enough to see the output when you hit "run" in the IDE? (ie, getch for C, some IDEs have options to set, what common/popular pause and wait for keypress routines do you use to keep the console window open long enough to see the output? This applies to lots of languages - list your method)</li> </ul> <p>Original question:</p> <blockquote> <p>How to view console application output screen(black screen).Please mention in detail.</p> </blockquote>
[ { "answer_id": 311552, "author": "Adam Davis", "author_id": 2915, "author_profile": "https://Stackoverflow.com/users/2915", "pm_score": 1, "selected": false, "text": "#include <iostream>\n#include <limits>\n\nint main() {\n\n // Rest of the code \n\n //Clean the stream and ask for i...
2008/11/22
[ "https://Stackoverflow.com/questions/311543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,576
<p>Given say 11/13/2008 - 12/11/2008 as the value posted back in TextBox, what would be the best way to parse out the start and end date using C#?</p> <p>I know I could use:</p> <pre><code>DateTime startDate = Convert.ToDateTime(TextBoxDateRange.Text.Substring(0, 10)); DateTime endDate = Convert.ToDateTime(TextBoxDateRange.Text.Substring(13, 10)); </code></pre> <p>Is there a better way?</p>
[ { "answer_id": 311583, "author": "Bryan Watts", "author_id": 37815, "author_profile": "https://Stackoverflow.com/users/37815", "pm_score": 4, "selected": true, "text": "var dates = TextBoxDateRange.Text.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);\n\nvar startDate = ...
2008/11/22
[ "https://Stackoverflow.com/questions/311576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25335/" ]
311,579
<p>I have a web page with 3 forms on it. Not nested, just one after the other (they are almost identical, just one hidden variable that's different). A user will only fill in one form, and I'd like to validate/etc all the forms with only one JS script.</p> <p>So how, when a user clicks the submit button of form#1, do I make my js script only deal with the fields in form1? I gather it has something to do with $(this).parents , but I am not sure what to do with it. </p> <p>My validation script (which I used elsewhere, with only a single form) looks something like so:</p> <pre> <code> $(document).ready(function(){ $("#submit").click(function(){ $(".error").hide(); var hasError = false; var nameVal = $("#name").val(); if(nameVal == '') { $("#name").after('Please enter your name.'); hasError = true; } if(hasError == false) {blah blah do all the processing stuff} </code> </pre> <p>So do I need to replace things like $("#name").val() with $(this).parents('form').name.val() ? Or is there a better way to go about this?</p> <p>Thanks!</p>
[ { "answer_id": 311589, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 9, "selected": true, "text": "$(\"#submit\").click(function(){\n var form = $(this).parents('form:first');\n ...\n});\n" }, { "answer...
2008/11/22
[ "https://Stackoverflow.com/questions/311579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,588
<p>List comprehensions can be useful in certain situations, but they can also be rather horrible to read.. As a slightly exaggerated example, how would you indent the following?</p> <pre><code>allUuids = [x.id for x in self.db.query(schema.allPostsUuid).execute(timeout = 20) if x.type == "post" and x.deleted is not False] </code></pre>
[ { "answer_id": 311590, "author": "Eli Bendersky", "author_id": 8206, "author_profile": "https://Stackoverflow.com/users/8206", "pm_score": 1, "selected": false, "text": "allUuids = [x.id for x in self.db.query(schema.allPostsUuid).execute(timeout = 20) \n if (x.type == ...
2008/11/22
[ "https://Stackoverflow.com/questions/311588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
311,599
<p>I like generics a lot and use them whereever I can. Every now and then I need to use one of my classes in another project which has to run on an old JVM (before 5.0), needs to run on JavaME (where generics are not allowed neither) or in Microsoft J# (which has VERY poor Support for generics).</p> <p>At the moment, I remove all generics manually, which means inserting many casts as well.</p> <p>Since generics are said to be compile-time-only, and every piece of generic code could possibly converted to non-generic code automatically, I wonder if there is any tool which can do this for me.</p> <p>If there is no such tool, how else could I solve the problem? Should I completely stop using generics?</p> <p>There already are answers related to <em>bytecode compability</em>. What if I need <em>source code compability</em> for some reason?</p>
[ { "answer_id": 311715, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "https://Stackoverflow.com/users/9815", "pm_score": 4, "selected": true, "text": "java.lang.reflect.Type" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39946/" ]
311,601
<p>I'm working in a windows environment (my laptop!) and I need a couple of scripts that run other programs, pretty much like a windows batch file.</p> <p>how can I run a command from python such that the program when run, will replace the script? The program is interactive (for instance, unison) and keeps printing lines and asking for user input all the time. </p> <p>So, just running a program and printing the output won't suffice. The program has to takeover the script's input/output, pretty mcuh like running the command from a .bat file. </p> <p>I tried os.execl but it keeps telling me "invalid arguments", also, it doesn't find the program name (doesn't search the PATH variable); I have to give it the full path ..?!</p> <p>basically, in a batch script I can write: unison profile</p> <p>how can I achieve the same effect in python?</p> <p>EDIT:</p> <p>I found out it can be done with <code>os.system( ... )</code> and since I cannot accept my own answer, I'm closing the question.</p> <hr> <p>EDIT: this was supposed to be a comment, but when I posted it I didn't have much points.</p> <p>Thanks Claudiu, that's pretty much what I want, except for a little thing: I want the function to end when the program exits, but when I try it on unison, it doesn't return control to the python script, but to the windows command line environment</p> <pre><code>&gt;&gt;&gt; os.execlp("unison") C:\&gt;Usage: unison [options] or unison root1 root2 [options] or unison profilename [options] For a list of options, type "unison -help". For a tutorial on basic usage, type "unison -doc tutorial". For other documentation, type "unison -doc topics". C:\&gt; C:\&gt; C:\&gt; </code></pre> <p>how to get around this?</p>
[ { "answer_id": 311613, "author": "Piotr Lesnicki", "author_id": 38796, "author_profile": "https://Stackoverflow.com/users/38796", "pm_score": 4, "selected": false, "text": "import os\nimport subprocess\nunison = os.path.join(os.path.curdir, \"unison\")\np = subprocess.Popen(unison)\np.wa...
2008/11/22
[ "https://Stackoverflow.com/questions/311601", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35364/" ]
311,605
<pre><code>var A = { x : function () { } }; var b = function (method) { //want to know method's "parent" here }; b(A.x); </code></pre> <p>I want to know that x is defined in A when I call the b(A.x). Is this possible?</p>
[ { "answer_id": 311617, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 2, "selected": false, "text": "x.parent = A;\n" }, { "answer_id": 311624, "author": "Eugene Yokota", "author_id": 3827, "author_profil...
2008/11/22
[ "https://Stackoverflow.com/questions/311605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,621
<p>I got ahead of myself and downloaded and installed the OSX Python 2.6 package from www.python.org/download/ on my OSX 10.5.5 Intel Mac and installed the full package contents. Only after this did I come across <a href="http://wiki.python.org/moin/MacPython/Leopard" rel="nofollow noreferrer">http://wiki.python.org/moin/MacPython/Leopard</a> stating that you should do a partial install of the package to avoid interfering with the system install.</p> <p>I'm afraid I've already overwritten the system framework through that installer and I remember reading somewhere after discovering this that I'd lose certain elements included in the OSX system install and not Python distributions.</p> <p>Is there any way to reverse this or restore anything I may have lost? What exactly have I lost and is it going to be a problem? </p>
[ { "answer_id": 311682, "author": "unmounted", "author_id": 11596, "author_profile": "https://Stackoverflow.com/users/11596", "pm_score": 3, "selected": false, "text": "/usr/bin" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311621", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39951/" ]
311,626
<p>I've been thinking lately, would it be a good form of syntactic sugar in languages like Java and C#, to include a "duck" type as a method parameter type? This would look as follows:</p> <pre><code>void myFunction(duck foo) { foo.doStuff(); } </code></pre> <p>This could be syntactic sugar for invoking doStuff() via reflection, or it could be implemented differently. Foo could be any type. If foo does not have a doStuff() method, this would throw a runtime exception. The point is that you would have the benefits of the more rigid pre-specified interface paradigm (performance, error checking) when you want them, i.e. most of the time. At the same time, you'd have a simple, clean-looking backdoor to duck typing, which would allow you to cleanly make changes not foreseen in the initial design without massive refactoring. Furthermore, it would likely be 100% backwards compatible and mesh cleanly with existing language constructs. I think this might help cut down on the overengineered just-in-case programming style that leads to confusing, cluttered APIs. Do you believe that something like this would be a good or bad thing in static OO languages like C# and Java?</p>
[ { "answer_id": 311632, "author": "Bryan Watts", "author_id": 37815, "author_profile": "https://Stackoverflow.com/users/37815", "pm_score": 4, "selected": true, "text": "dynamic" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
311,627
<p>This is my code:</p> <pre><code>import datetime today = datetime.date.today() print(today) </code></pre> <p>This prints: <code>2008-11-22</code> which is exactly what I want.</p> <p>But, I have a list I'm appending this to and then suddenly everything goes "wonky". Here is the code:</p> <pre><code>import datetime mylist = [] today = datetime.date.today() mylist.append(today) print(mylist) </code></pre> <p>This prints the following: </p> <pre><code>[datetime.date(2008, 11, 22)] </code></pre> <p>How can I get just a simple date like <code>2008-11-22</code>?</p>
[ { "answer_id": 311635, "author": "Simon Johnson", "author_id": 854, "author_profile": "https://Stackoverflow.com/users/854", "pm_score": 3, "selected": false, "text": "datetime" }, { "answer_id": 311636, "author": "HanClinto", "author_id": 26933, "author_profile": "ht...
2008/11/22
[ "https://Stackoverflow.com/questions/311627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15250/" ]
311,630
<p>I have two entities Foo and Bar with a Many to Many relationship between them.</p> <p>Let's say there is no semantic argument for why Foo might be "responsible" for the many to many relationship, but we arbitrarily decide that Foo is responsible for the relation (I.e., in NHibernate we would mark Bar as Inverse)</p> <p>That's all well and good from a DB perspective, but my entity APIs reveal a problem.</p> <pre><code> // Responsible for the relation public class Foo { List&lt;Bar&gt; Bars = new List&lt;Bar&gt;(); public void AddBar(Bar bar) { Bars.Add(bar); bar.AddFoo(this); } } public class Bar { List&lt;Foo&gt; Foos = new List&lt;Foo&gt;(); // This shouldn't exist. public void AddFoo(Foo foo) { Foos.Add(foo); foo.AddBar(this); // Inf Recursion } } </code></pre> <p>If we've decided that Foo is responsible for this relationship, how do I update the associated collection in Bar without creating a public Bar.AddFoo() method which shouldn't even exist?</p> <p>I feel like I should be able to maintain the integrity of my domain model without resorting to having to reload these entities from the DB after an operation such as this.</p> <p>UPDATE: Code tweak inspired by commenter. </p>
[ { "answer_id": 311679, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": -1, "selected": false, "text": "public class Foo\n{\n List<Bar> Bars = new List<Bar>();\n\n public void AddBar(Bar bar)\n {\n Bars.Add(bar);\n ...
2008/11/22
[ "https://Stackoverflow.com/questions/311630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3285/" ]
311,644
<p>I'm loading an html snippet using </p> <pre><code>$("#TemplateDump").load("Themes/default.template", function() { processTemplate() }) </code></pre> <p>The html i am loading contains</p> <pre><code>&lt;div&gt; `hello ##name##, your age is ##age##. your page is &lt;a href="##website##"&gt;here&lt;/a&gt; &lt;/div&gt; </code></pre> <p>I need to replace the ## placeholders with "joe","112" and "www.whatever.com". Is there a more jquery way of doing this rather than using straight javascript .replace? Are there any place holder replacement plugins around? using .replace in IE on the url placeholder just doesnt work either. Dont know why. By the way, the templates cant be changed.</p>
[ { "answer_id": 311679, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": -1, "selected": false, "text": "public class Foo\n{\n List<Bar> Bars = new List<Bar>();\n\n public void AddBar(Bar bar)\n {\n Bars.Add(bar);\n ...
2008/11/22
[ "https://Stackoverflow.com/questions/311644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39655/" ]
311,656
<p>Do you know any resources that teach to good habits of working in UNIX command line?</p> <p>EDIT: I don't mean general books about shell or man pages. I mean the things that you can only see watching professionals working with command line. For example when changing frequently between two directories they use "pushd" command, when repeating a command they use "history". I can read about these commands but I want to make it a habit to use them effectively.</p>
[ { "answer_id": 311660, "author": "flolo", "author_id": 36472, "author_profile": "https://Stackoverflow.com/users/36472", "pm_score": 1, "selected": false, "text": "bash" }, { "answer_id": 311869, "author": "Will Hartung", "author_id": 13663, "author_profile": "https:/...
2008/11/22
[ "https://Stackoverflow.com/questions/311656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1692070/" ]
311,657
<p>Is there any way to get the time down to the Millisecond in MySQL?</p>
[ { "answer_id": 311664, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "NOW()" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
311,662
<p>I was just wondering if there are any good work-arounds for Deserializing private fields/properties using XmlSerializer.Deserialize() ?</p> <p>Currently, I Deserialize my XML to a simple disposable type with all public properties, then I load the complex type that has private properties like this:</p> <pre><code>ComplexType complex = new ComplexType(SimpleType); </code></pre> <p>and the constructor of ComplexType looks like this:</p> <pre><code>public ComplexType(SimpleType simpleType){ this.Property1 = simpleType.Property1; this.Property2 = simpleType.Property2; ..... } </code></pre> <p>Anyone has a better way of doing this?</p>
[ { "answer_id": 311664, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "NOW()" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311662", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37794/" ]
311,666
<p>I am trying to write a unix command line utility that will extract the "application" icon from a Windows Mobile executable. When I look inside the .exe with <a href="http://www.nongnu.org/icoutils/" rel="nofollow noreferrer">wrestool</a> from the icoutils package, I see multiple icon and group_icon resources. I am trying to figure out which icon the Windows Mobile Programs view would choose to display to the end user.</p> <p>At first, I figured it would be the icon with name 32512 (IDI_APPLICATION), but then I found several Windows Mobile binaries that lacked this icon resource, but sure enough had visible icons in the Programs view.</p> <p>Is there a simple but correct algorithm? like lowest resource id? Is there another resource in the .exe that tells me what is the application icon? Is there something obvious that I am missing?</p> <p>Any insight would be appreciated.</p>
[ { "answer_id": 311664, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 4, "selected": true, "text": "NOW()" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,672
<p>I've seen a related question on this website regarding a Linux system. I have the same question on a Windows XP OS. I bought a Winchester USB external HD, and found out from technical support that the sleep feature is in the firmware and cannot be turned off. I'm looking for an application that will automatically read/write to that drive periodically to keep that timer resetting (every 5 minutes?). Is anyone aware of a small application for Windows XP that will do that?</p> <p>Thanks for your help.</p>
[ { "answer_id": 311765, "author": "Will Dean", "author_id": 987, "author_profile": "https://Stackoverflow.com/users/987", "pm_score": 1, "selected": false, "text": "@echo off\n:start\ncopy c:\\windows\\notepad.exe g:\\ (Or whatever your external drive is)\nchoice /N /D Y /T 120 ...
2008/11/22
[ "https://Stackoverflow.com/questions/311672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,677
<p>can anybody please explain the following c# behaviour? I have written a small console application just to learn about CAS, but I can not seem to understand why the following lines of code work like they do:</p> <pre><code>string[] myRoles = new string[] { "role1", "role2", "role3" }; GenericIdentity myIdentity = new GenericIdentity("myUsername", "customAuthType"); GenericPrincipal myPrincipal = new GenericPrincipal(myIdentity, myRoles); System.Threading.Thread.CurrentPrincipal = myPrincipal; Console.WriteLine(SecurityManager.IsGranted(new PrincipalPermission(null, "role1"))); Console.WriteLine(SecurityManager.IsGranted(new PrincipalPermission(null, "roleX"))); </code></pre> <p>The output is "true" for both SecurityManager.IsGranted() calls.</p> <p>If I then add the following lines:</p> <pre><code> new PrincipalPermission(null, "role1").Demand(); new PrincipalPermission(null, "roleX").Demand(); </code></pre> <p>the first demand call passes, but the second one (as expected) causes a SecurityException. </p> <p>Why does not the SecurityManager.IsGranted()-call return false for the "roleX" permission?</p>
[ { "answer_id": 312498, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 0, "selected": false, "text": "SecurityManager.IsGranted" }, { "answer_id": 17082239, "author": "Kiquenet", "author_id": 206730, ...
2008/11/22
[ "https://Stackoverflow.com/questions/311677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,691
<p>I feel like this is a stupid question because it seems like common sense . . . but no google search I can put together seems to be able to give me the answer! </p> <p>I know how to get data OUT of a sqlite3 database using the .dump command. But now that I have this ASCII file titled export.sqlite3.sql . . . I can't seem to get it back INTO the database I want. </p> <p>My goal was to transfer the data I had in one rails app to another so I didn't have to take all sorts of time creating dummy data again . . . so I dumped the data from my first app, got rid of all the CREATE TABLE statements, and made sure my schema on my second app matches . . . now I just have to get it IN there. </p> <p>Would anyone mind helping me out? And when you find a way, will you tell me what you plugged into the google, 'cause I am beating my head open with a spoon right now over what I thought would be an easy find. </p>
[ { "answer_id": 311718, "author": "Ali Afshar", "author_id": 28380, "author_profile": "https://Stackoverflow.com/users/28380", "pm_score": 7, "selected": true, "text": "cat dumpfile.sql | sqlite3 my_database.sqlite\n" }, { "answer_id": 494626, "author": "Noah", "author_id"...
2008/11/22
[ "https://Stackoverflow.com/questions/311691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34568/" ]
311,696
<p>According to the documentation, the <a href="http://msdn.microsoft.com/en-us/library/zy06z30k.aspx" rel="noreferrer"><code>decimal.Round</code></a> method uses a round-to-even algorithm which is not common for most applications. So I always end up writing a custom function to do the more natural round-half-up algorithm:</p> <pre><code>public static decimal RoundHalfUp(this decimal d, int decimals) { if (decimals &lt; 0) { throw new ArgumentException("The decimals must be non-negative", "decimals"); } decimal multiplier = (decimal)Math.Pow(10, decimals); decimal number = d * multiplier; if (decimal.Truncate(number) &lt; number) { number += 0.5m; } return decimal.Round(number) / multiplier; } </code></pre> <p>Does anybody know the reason behind this framework design decision?</p> <p>Is there any built-in implementation of the round-half-up algorithm into the framework? Or maybe some unmanaged Windows API?</p> <p>It could be misleading for beginners that simply write <code>decimal.Round(2.5m, 0)</code> expecting 3 as a result but getting 2 instead.</p>
[ { "answer_id": 311707, "author": "Michael Stum", "author_id": 91, "author_profile": "https://Stackoverflow.com/users/91", "pm_score": 7, "selected": false, "text": "Math.Round" }, { "answer_id": 6562018, "author": "Ostemar", "author_id": 106649, "author_profile": "htt...
2008/11/22
[ "https://Stackoverflow.com/questions/311696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29407/" ]
311,703
<p>I am trying to test the likelihood that a particular clustering of data has occurred by chance. A robust way to do this is Monte Carlo simulation, in which the associations between data and groups are randomly reassigned a large number of times (e.g. 10,000), and a metric of clustering is used to compare the actual data with the simulations to determine a p value.</p> <p>I've got most of this working, with pointers mapping the grouping to the data elements, so I plan to randomly reassign pointers to data. THE QUESTION: what is a fast way to sample without replacement, so that every pointer is randomly reassigned in the replicate data sets?</p> <p>For example (these data are just a simplified example):</p> <blockquote> <p>Data (n=12 values) - Group A: 0.1, 0.2, 0.4 / Group B: 0.5, 0.6, 0.8 / Group C: 0.4, 0.5 / Group D: 0.2, 0.2, 0.3, 0.5</p> </blockquote> <p>For each replicate data set, I would have the same cluster sizes (A=3, B=3, C=2, D=4) and data values, but would reassign the values to the clusters.</p> <p>To do this, I could generate random numbers in the range 1-12, assign the first element of group A, then generate random numbers in the range 1-11 and assign the second element in group A, and so on. The pointer reassignment is fast, and I will have pre-allocated all data structures, but the sampling without replacement seems like a problem that might have been solved many times before.</p> <p>Logic or pseudocode preferred.</p>
[ { "answer_id": 311716, "author": "John D. Cook", "author_id": 25188, "author_profile": "https://Stackoverflow.com/users/25188", "pm_score": 5, "selected": false, "text": "void SampleWithoutReplacement\n(\n int populationSize, // size of set sampling from\n int sampleSize, ...
2008/11/22
[ "https://Stackoverflow.com/questions/311703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18484/" ]
311,706
<p>I recently completed development of a mid-traficked(?) website (peak 60k hits/hour), however, the site only needs to be updated once a minute - and achieving the required performance can be summed up by a single word: "caching".</p> <p>For a site like SO where the data feeding the site changes <em>all the time</em>, I would imagine a different approach is required. </p> <p>Page cache times presumably need to be short or non-existent, and updates need to be propogated across all the webservers very rapidly to keep all users up to date. </p> <p>My guess is that you'd need a distributed cache to control the serving of data and pages that is updated on the order of a few seconds, with perhaps a distributed cache above the database to mediate writes?</p> <p>Can those more experienced that I outline some of the key architectural/design principles they employ to ensure highly interactive websites like SO are performant? </p>
[ { "answer_id": 311716, "author": "John D. Cook", "author_id": 25188, "author_profile": "https://Stackoverflow.com/users/25188", "pm_score": 5, "selected": false, "text": "void SampleWithoutReplacement\n(\n int populationSize, // size of set sampling from\n int sampleSize, ...
2008/11/22
[ "https://Stackoverflow.com/questions/311706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38522/" ]
311,710
<p>I have a List&lt; int[] > myList, where I know that all the int[] arrays are the same length - for the sake of argument, let us say I have 500 arrays, each is 2048 elements long. I'd like to sum all 500 of these arrays, to give me a single array, 2048 elements long, where each element is the sum of all the same positions in all the other arrays.</p> <p>Obviously this is trivial in imperative code:</p> <pre><code>int[] sums = new int[myList[0].Length]; foreach(int[] array in myList) { for(int i = 0; i &lt; sums.Length; i++) { sums[i] += array[i]; } } </code></pre> <p>But I was wondering if there was a nice Linq or Enumerable.xxx technique?</p>
[ { "answer_id": 311720, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "var results = myList.SelectMany(array => array.Select(\n (value, index) =>...
2008/11/22
[ "https://Stackoverflow.com/questions/311710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/987/" ]
311,725
<p>I have a table that has, in essence, this structure:</p> <pre> key value ------ ------ 2 val1 3 val2 5 val3</pre> <p>The keys are sequential integers from 1 up to (currently) 1 million, increasing by several thousand each day. Gaps in the keys occur when records have been deleted.</p> <p>I'm looking for an SQL query that returns this:</p> <pre> key value ------ ------ 1 2 val1 3 val2 4 5 val3</pre> <p>I can see how to do this with joining to a second table that has a complete list of keys. However I'd prefer a solution that uses standard SQL (no stored procedures or a second table of keys), and that will work no matter what the upper value of the key is. </p>
[ { "answer_id": 311746, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 2, "selected": false, "text": "CREATE TABLE n (d NUMERIC);\nINSERT INTO n VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);\n" }, { "a...
2008/11/22
[ "https://Stackoverflow.com/questions/311725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39965/" ]
311,730
<p>I need a simple window with three input boxes and three labels (login name, password, and server node) and a button to execute the script. I do not want any third party programs that need to be installed on Windows. If it can be installed on Cygwin that would be great.</p>
[ { "answer_id": 311770, "author": "Bryan Oakley", "author_id": 7432, "author_profile": "https://Stackoverflow.com/users/7432", "pm_score": 3, "selected": true, "text": "package require Tk 8.5\nproc main {} {\n ttk::frame .f\n ttk::label .l1 -text \"Username:\" -anchor e\n ttk::la...
2008/11/22
[ "https://Stackoverflow.com/questions/311730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34531/" ]
311,734
<p>I am creating a custom WPF control that let's say for simplicity sake has a vertical stack panel with a "title" TextBlock, followed by a ContentPresenter. I want the font size for the "title" to be 5 Points LARGER than the size used in the content, which is inherited by whatever container the user places this control in.</p> <p>How can I specify a font size in the control template for the header element using a relative value without exposing a property like "TitleFontSize" to the user? I want do "add 5".</p> <p>I tried using a ScaleTransform on the header text block with mixed results (the text block scaled fine but the orientation was modified - I had the text right-justified and it moved "off the control" area when scaled). Also, I am not sure if scale transform would be approprite here. </p>
[ { "answer_id": 311774, "author": "Bill", "author_id": 17595, "author_profile": "https://Stackoverflow.com/users/17595", "pm_score": 4, "selected": true, "text": "public class FontSizeConverter : IValueConverter\n{\n\n #region IValueConverter Members\n\n public object Convert(object...
2008/11/22
[ "https://Stackoverflow.com/questions/311734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17595/" ]
311,735
<p>i need to convert pointers to long (SendMessage()) and i want to safely check if the variable is correct on the otherside. So i was thinking of doing dynamic_cast but that wont work on classes that are not virtual. Then i thought of doing typeid but that will work until i pass a derived var as its base.</p> <p>Is there any way to check if the pointer is what i am expecting during runtime? Is there a way i can use typeid to see if a pointer is a type derived from a particular base?</p>
[ { "answer_id": 311758, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 0, "selected": false, "text": "UINT_PTR" }, { "answer_id": 311764, "author": "Rob Kennedy", "author_id": 33732, "autho...
2008/11/22
[ "https://Stackoverflow.com/questions/311735", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,763
<p>I have a friend who is finishing up his masters degree in aerospace engineering. For his final project, he is on a small team tasked with writing a program for tracking weather balloons, rockets and satellites. The program receives input from a GPS device, does calculations with the data, and uses the results of those calculations to control a series of motors designed to orientate a directional communication antenna, so the balloon, rocket or satellite always stays in focus.</p> <p>Though somewhat of a (eternal) beginner myself, I have more programming experience than my friend. So when he asked me for advice, I convinced him to write the program in Python, my language of choice.</p> <p>At this point in the project, we are working on the code that parses the input from the GPS device. Here is some example input, with the data we need to extract in bold:</p> <p>$GPRMC,092204.999,<strong>4250.5589,S,14718.5084,E</strong>,1,12,24.4,<strong>89.6</strong>,M,,,0000*1F $GPRMC,093345.679,<strong>4234.7899,N,11344.2567,W</strong>,3,02,24.5,<strong>1000.23</strong>,M,,,0000*1F $GPRMC,044584.936,<strong>1276.5539,N,88734.1543,E</strong>,2,04,33.5,<strong>600.323</strong>,M,,,*00 $GPRMC,199304.973,<strong>3248.7780,N,11355.7832,W</strong>,1,06,02.2,<strong>25722.5</strong>,M,,,*00 $GPRMC,066487.954,<strong>4572.0089,S,45572.3345,W</strong>,3,09,15.0,<strong>35000.00</strong>,M,,,*1F</p> <p>Here is some further explanation of the data:</p> <blockquote> <p>"I looks like I'll need five things out of every line. And bear in mind that any one of these area's may be empty. Meaning there will be just two commas right next to each other. Such as ',,,' There are two fields that may be full at any time. Some of them only have two or three options that they may be but I don't think I should be counting on that."</p> </blockquote> <p>Two days ago my friend was able to acquire the full log from the GPS receiver used to track a recent weather balloon launch. The data is quite long, so I put it all in <a href="http://pastebin.com/f5f5cf9ab" rel="noreferrer">this pastebin</a>.</p> <p>I am still rather new with regular expressions myself, so I am looking for some assistance.</p>
[ { "answer_id": 311769, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 3, "selected": false, "text": ">>> line=\"$GPRMC,092204.999,4250.5589,S,14718.5084,E,1,12,24.4,89.6,M,,,0000*1F \"\n>>> line.split(',')\n['$GPRMC', '09220...
2008/11/22
[ "https://Stackoverflow.com/questions/311763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33383/" ]
311,768
<p>I want to select about 4-5 rows from a table, then form a space separated string.</p> <p>All of this is to be done in a stored procedure (SQL server 2005).</p> <p>Is this possible?</p> <p>I will then use this space-separated string and save it to another table.</p> <p><b>Update</b></p> <pre><code>SELECT * FROM Users WHERE userID &lt; 10 </code></pre> <p>output:</p> <pre><code>john jake blah sam </code></pre> <p>So, put this in a space separated string:</p> <p>'john jake blah sam'</p> <p>and save that string to another row in a table.</p> <p>All this has to be done in a stored procedure (if possible).</p>
[ { "answer_id": 311780, "author": "Micky McQuade", "author_id": 12908, "author_profile": "https://Stackoverflow.com/users/12908", "pm_score": 0, "selected": false, "text": "DECLARE @whatever varchar(max) -- or varchar(1000) or whatever size\nSET @whatever = ''\n\nSELECT @whatever = @what...
2008/11/22
[ "https://Stackoverflow.com/questions/311768", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,775
<p>Code like this often happens:</p> <pre><code>l = [] while foo: # baz l.append(bar) # qux </code></pre> <p>This is really slow if you're about to append thousands of elements to your list, as the list will have to be constantly resized to fit the new elements.</p> <p>In Java, you can create an ArrayList with an initial capacity. If you have some idea how big your list will be, this will be a lot more efficient.</p> <p>I understand that code like this can often be refactored into a list comprehension. If the <em>for</em>/<em>while</em> loop is very complicated, though, this is unfeasible. Is there an equivalent for us Python programmers?</p>
[ { "answer_id": 311783, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 7, "selected": false, "text": "l = [None] * 1000 # Make a list of 1000 None's\nfor i in xrange(1000):\n # baz\n l[i] = bar\n # qux\n" }...
2008/11/22
[ "https://Stackoverflow.com/questions/311775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
311,801
<p>i’m trying to create a url string that works like this:</p> <pre><code>/app/process/example.com/index.html </code></pre> <p>so in other words,</p> <pre><code>/app/process/$URL </code></pre> <p>i then retrieve the url with </p> <pre><code>$this-&gt;uri-&gt;segment(3); </code></pre> <p>the forward slashes in the URL will of course be a problem accessing uri segments, so i’ll go ahead and url encode the URL portion:</p> <pre><code>/app/process/example.com%2Findex.html </code></pre> <p>.. but now I just get a 404 saying ...</p> <pre><code>Not Found The requested URL /app/process/example.com/index.html was not found on this server. </code></pre> <p>it appears that my url encoding of forward slashes breaks CI’s URI parser.</p> <p>what can i do to get around this problem?</p>
[ { "answer_id": 311806, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 1, "selected": false, "text": "<?php\nclass App extends Controller {\n function process($a, $b) {\n // at this point $a is \"example.com\" and $...
2008/11/22
[ "https://Stackoverflow.com/questions/311801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,807
<p>I don't think that this is specific to a language or framework, but I am using xUnit.net and C#.</p> <p>I have a function that returns a random date in a certain range. I pass in a date, and the returning date is always in range of 1 to 40 years before the given date.</p> <p>Now I just wonder if there is a good way to unit test this. The best approach seems to be to create a loop and let the function run i.e. 100 times and assert that every of these 100 results are in the desired range, which is my current approach.</p> <p>I also realize that unless I am able to control my Random generator, there will not be a perfect solution (after all, the result IS random), but I wonder what approaches you take when you have to test functionality that returns a random result in a certain range?</p>
[ { "answer_id": 311829, "author": "Brian Genisio", "author_id": 36687, "author_profile": "https://Stackoverflow.com/users/36687", "pm_score": 6, "selected": false, "text": "public interface IRandomGenerator\n{\n double Generate(double max);\n}\n\npublic class SomethingThatUsesRandom\n{...
2008/11/22
[ "https://Stackoverflow.com/questions/311807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
311,816
<p>When I generate CSS or JavaScript files using PHP I like to use .js.php or .css.php file extensions. so that I know what's going on.</p> <p>Is there a way of associating these "compound" file extensions to their respective languages?</p>
[ { "answer_id": 375087, "author": "itsadok", "author_id": 7581, "author_profile": "https://Stackoverflow.com/users/7581", "pm_score": 3, "selected": false, "text": "<?php if(0) { ?><script><?php } ?>\n# code goes here\n<?php if(0) { ?></script><?php } ?>\n" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2443/" ]
311,818
<p>How should I tell SDL to maximize the application window?</p> <p>I'm creating the window with these flags: SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE.</p>
[ { "answer_id": 312217, "author": "MattyT", "author_id": 7405, "author_profile": "https://Stackoverflow.com/users/7405", "pm_score": -1, "selected": false, "text": "flags |= SDL_FULLSCREEN;\nscreen = SDL_SetVideoMode(..., flags);\n" }, { "answer_id": 315226, "author": "Judge M...
2008/11/22
[ "https://Stackoverflow.com/questions/311818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38256/" ]
311,840
<p>I am looking for a tool like <a href="http://linux.die.net/man/1/ltrace" rel="noreferrer">ltrace</a> or <a href="http://linux.die.net/man/1/strace" rel="noreferrer">strace</a> that can trace locally defined functions in an executable. ltrace only traces dynamic library calls and strace only traces system calls. For example, given the following C program:</p> <pre><code>#include &lt;stdio.h&gt; int triple ( int x ) { return 3 * x; } int main (void) { printf("%d\n", triple(10)); return 0; } </code></pre> <p>Running the program with <code>ltrace</code> will show the call to <code>printf</code> since that is a standard library function (which is a dynamic library on my system) and <code>strace</code> will show all the system calls from the startup code, the system calls used to implement printf, and the shutdown code, but I want something that will show me that the function <code>triple</code> was called. Assuming that the local functions have not been inlined by an optimizing compiler and that the binary has not been stripped (symbols removed), is there a tool that can do this?</p> <p><strong>Edit</strong></p> <p>A couple of clarifications:</p> <ul> <li>It is okay if the tool also provides trace information for non-local functions.</li> <li>I don't want to have to recompile the program(s) with support for specific tools, the symbol information in the executable should be enough.</li> <li>I would be really nice if I could use the tool to attach to existing processes like I can with ltrace/strace.</li> </ul>
[ { "answer_id": 311912, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 7, "selected": true, "text": "#include <iostream>\n\nint fac(int n) {\n if(n == 0)\n return 1;\n return n * fac(n-1);\n}\n\ni...
2008/11/22
[ "https://Stackoverflow.com/questions/311840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25222/" ]
311,857
<p>I'm embedding MSBuild directly into a more complex build tool. The relevant code looks roughly like this:</p> <pre><code>// assume 'using Microsoft.Build.BuildEngine;' Engine e = Engine(); BuildPropertyGroup props = new BuildPropertyGroup(); props.SetProperty( "Configuration", Config.BuildConfig ); e.BuildProjectFile( projectFile, new string[] { "Build" }, props ) </code></pre> <p>My question is how to cancel this build once it's started, without doing something drastic like terminating the thread. Also, if the project being built is a C++ project, the build will involve at least one sub-process, so canceling the thread isn't even going to really cancel the build.</p> <p>I don't see any cancel method on the Engine class - does someone know of a way?</p>
[ { "answer_id": 319064, "author": "Charlie", "author_id": 18529, "author_profile": "https://Stackoverflow.com/users/18529", "pm_score": 1, "selected": true, "text": "CreateToolhelp32Snapshot( ToolHelp.SnapshotFlags.Process, 0 );\n" } ]
2008/11/22
[ "https://Stackoverflow.com/questions/311857", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18529/" ]
311,873
<p><strong>NOTE: the original question is moot but scan to the bottom for something relevant.</strong></p> <p>I have a query I want to optimize that looks something like this:</p> <pre><code>select cols from tbl where col = "some run time value" limit 1; </code></pre> <p>I want to know what keys are being used but whatever I pass to explain, it is able to optimize the where clause to nothing ("Impossible WHERE noticed...") because I fed it a constant.</p> <ul> <li>Is there a way to tell mysql to not do constant optimizations in explain?</li> <li>Am I missing something?</li> <li>Is there a better way to get the info I need?</li> </ul> <p>Edit: <code>EXPLAIN</code> seems to be giving me the query plan that will result from constant values. As the query is part of a stored procedure (and IIRC query plans in spocs are generated before they are called) this does me no good because the value are not constant. What I want is to find out what query plan the optimizer will generate when it doesn't known what the actual value will be.</p> <p>Am I missing soemthing?</p> <p>Edit2: Asking around elsewhere, it seems that MySQL always regenerates query plans unless you go out of your way to make it re-use them. Even in stored procedures. From this it would seem that my question is moot.</p> <p><strong>However that doesn't make what I really wanted to know moot:</strong> <em>How do you optimize a query that contains values that are constant within any specific query but where I, the programmer, don't known in advance what value will be used?</em> -- For example say my client side code is generating a query with a number in it's <code>where</code> clause. Some times the number will result in an <em>impossible where clause</em> other times it won't. How can I use explain to examine how well optimized the query is?</p> <p>The best approach I'm seeing right off the bat would be to run <code>EXPLAIN</code> on it for the full matrix of exist/non-exist cases. Really that isn't a very good solution as it would be both hard and error prone to do by hand.</p>
[ { "answer_id": 311914, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": false, "text": "col = col" }, { "answer_id": 821864, "author": "Quassnoi", "author_id": 55159, "author_profile":...
2008/11/22
[ "https://Stackoverflow.com/questions/311873", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
311,876
<p>Hey everyone. I'm trying to make a swing GUI with a button and a label on it. im using a border layout and the label ( in the north field ) shows up fine, but the button takes up the rest of the frame (it's in the center field). any idea how to fix this?</p>
[ { "answer_id": 311878, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 5, "selected": true, "text": "public static void main( String [] args ) {\n JLabel label = new JLabel(\"Some info\");\n JButton button = new JButt...
2008/11/22
[ "https://Stackoverflow.com/questions/311876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39984/" ]
311,882
<p>I often hear the terms 'statically linked' and 'dynamically linked', often in reference to code written in <a href="http://en.wikipedia.org/wiki/C_%28programming_language%29" rel="noreferrer">C</a>, <a href="https://en.wikipedia.org/wiki/C++" rel="noreferrer">C++</a> or <a href="http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29" rel="noreferrer">C#</a>. What are they, what exactly are they talking about, and what are they linking?</p>
[ { "answer_id": 311889, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 10, "selected": true, "text": "main.c" }, { "answer_id": 311932, "author": "Artelius", "author_id": 31945, "author_profile": "https...
2008/11/22
[ "https://Stackoverflow.com/questions/311882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
311,883
<p>I've got a method JSNI that calls a Java method that take a Hasmap as input. I've tried </p> <pre><code>handler.@com.mypackage::myMethod(Ljava/util/Hashmap;)(myHashMap); handler.@com.mypackage::myMethod(Ljava/util/Hashmap&lt;Ljava/lang/String,Ljava/lang/String&gt;;)(myHashMap); </code></pre> <p>I'm can't seem to define the correct type signature to include the Strings or find if this usage is even allowed. </p> <p>Since I'm doing this in gwt I though it might be the implementation of hashmap and the alternative approach I've though takes a String[][] array as input </p> <p>I was hoping for somwthing like</p> <p>handler.@com.mypackage::myMethod([[Ljava/lang/String;)(myArray);</p> <p>However, I hit another issue of finding the correct JNSI sntax for the 2nd dimension of the array </p> <p>A single dimension array ie. <code>[Ljava/lang/String;</code> is fine but I need the 2nd dimension.</p> <p>Any help/ideas or links to good jnsi doc appreciated.</p>
[ { "answer_id": 318896, "author": "sre", "author_id": 21387, "author_profile": "https://Stackoverflow.com/users/21387", "pm_score": 0, "selected": false, "text": "handler.@com.mypackage::myMethod(Ljava/util/Hashmap;)(myHashMap);\n" }, { "answer_id": 332157, "author": "Mark Ren...
2008/11/22
[ "https://Stackoverflow.com/questions/311883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21387/" ]
311,888
<p>I have a syntax highlighting function in vb.net. I use regular expressions to match "!IF" for instance and then color it blue. This works perfect until I tried to figure out how to do comments. </p> <p>The language I'm writing this for a comment can either be if the line starts with a single quote ' OR if anywhere in the line there is two single quotes</p> <pre><code>'this line is a comment !if StackOverflow = "AWESOME" ''this is also a comment </code></pre> <p>Now i know how to see if it starts with a single line ^' but i need to to return the string all the way to the end of the line so i can color the entire comment green and not just the single quotes.</p> <p>You shouldn't need the code but here is a snippet just in case it helps. </p> <pre><code> For Each pass In frmColors.lbRegExps.Items RegExp = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass)) For Each RegExpMatch In RegExp rtbMain.Select(RegExpMatch.Index, RegExpMatch.Length) rtbMain.SelectionColor = ColorTranslator.FromHtml(frmColors.lbHexColors.Items(PassNumber)) Next PassNumber += 1 Next </code></pre>
[ { "answer_id": 311895, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 4, "selected": true, "text": "^(\\'[^\\r\\n]+)$|(''[^\\r\\n]+)$\n" }, { "answer_id": 311908, "author": "Boaz", "author_id": 2892, "author_...
2008/11/22
[ "https://Stackoverflow.com/questions/311888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39143/" ]
311,936
<p>I've read a few instances in reading mathematics and computer science that use the equivalence symbol <strong><code>≡</code></strong>, (basically an '=' with three lines) and it always makes sense to me to read this as if it were equality. What is the difference between these two concepts?</p>
[ { "answer_id": 311941, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": false, "text": "int i = 3;\ndouble d = 3.0;\n" }, { "answer_id": 311942, "author": "Eugene Yokota", "author_id": 382...
2008/11/23
[ "https://Stackoverflow.com/questions/311936", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
311,939
<p>So the following rewrite rules always seem to fire. This has the effect of hiding another domain that I am hosting on the server?</p> <p>I can't seem to figure out what's wrong and it is time to call in the experts:</p> <pre><code>RewriteEngine on RewriteCond %{HTTP_HOST} ^danielhonig.com RewriteRule ^(.*)$ http://www.danielhonig.com/$1 [R=permanent,L] RedirectMatch ^/$ http://www.danielhonig.com/gravl Options None </code></pre>
[ { "answer_id": 311945, "author": "mthurlin", "author_id": 39991, "author_profile": "https://Stackoverflow.com/users/39991", "pm_score": 2, "selected": false, "text": "<VirtualHost>" }, { "answer_id": 329778, "author": "rojoca", "author_id": 41967, "author_profile": "h...
2008/11/23
[ "https://Stackoverflow.com/questions/311939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1129162/" ]
311,948
<p>How do I make gdb print functions of interest as they are called, indented according to how deep in the stack they are?</p> <p>I want to be able to say something like (made up):</p> <pre><code>(gdb) trace Foo* Bar* printf </code></pre> <p>And have gdb print all functions which begin with Foo or Bar, as they are called. Kind of like gnu cflow, except using the debugging symbols and only printing functions which actually get called, not all possible call flows.</p> <p>Tools which won't help include cachegrind, callgrind and oprofile, which order the results by which functions were called most often. I need the order of calling preserved.</p> <p>The wildcarding (or equivalent) is essential, as there are a lot of Foo and Bar funcs. Although I would settle for recording absolutely every function. Or, perhaps telling gdb to record all functions in a particular library.</p> <p>Some GDB wizard must have a script for this common job!</p>
[ { "answer_id": 312279, "author": "qrdl", "author_id": 28494, "author_profile": "https://Stackoverflow.com/users/28494", "pm_score": 0, "selected": false, "text": "gdb" }, { "answer_id": 1500442, "author": "alesplin", "author_id": 135917, "author_profile": "https://Sta...
2008/11/23
[ "https://Stackoverflow.com/questions/311948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,949
<p>Is there any good way to unit test destructors? Like say I have a class like this (contrived) example:</p> <pre><code>class X { private: int *x; public: X() { x = new int; } ~X() { delete x; } int *getX() {return x;} const int *getX() const {return x;} }; </code></pre> <p>Is there any good way to unit test this to make sure x gets deleted without cluttering up my hpp file with #ifdef TESTs or breaking encapsulation? The main problem that I'm seeing is that it's difficult to tell if x really got deleted, especially because the object is out of scope at the time the destructor is called.</p>
[ { "answer_id": 311976, "author": "Matthew Crumley", "author_id": 2214, "author_profile": "https://Stackoverflow.com/users/2214", "pm_score": 0, "selected": false, "text": "void testDestructor()\n{\n int *my_x;\n {\n X object;\n my_x = object.getX();\n }\n CPPUNI...
2008/11/23
[ "https://Stackoverflow.com/questions/311949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
311,955
<p>I have an application which is a relatively old. Through some minor changes, it builds nearly perfectly with Visual C++ 2008. One thing that I've noticed is that my "debug console" isn't quite working right. Basically in the past, I've use <code>AllocConsole()</code> to create a console for my debug output to go to. Then I would use <code>freopen</code> to redirect <code>stdout</code> to it. This worked perfectly with both C and C++ style IO.</p> <p>Now, it seems that it will only work with C style IO. What is the proper way to redirect things like <code>cout</code> to a console allocated with <code>AllocConsole()</code>?</p> <p>Here's the code which used to work:</p> <pre><code>if(AllocConsole()) { freopen("CONOUT$", "wt", stdout); SetConsoleTitle("Debug Console"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); } </code></pre> <p><strong>EDIT</strong>: one thing which occurred to me is that I could make a custom streambuf whose overflow method writes using C style IO and replace <code>std::cout</code>'s default stream buffer with it. But that seems like a cop-out. Is there a proper way to do this in 2008? Or is this perhaps something that MS overlooked?</p> <p><strong>EDIT2</strong>: OK, so I've made an implementaiton of the idea I spelled out above. Basically it looks like this:</p> <pre><code>class outbuf : public std::streambuf { public: outbuf() { setp(0, 0); } virtual int_type overflow(int_type c = traits_type::eof()) { return fputc(c, stdout) == EOF ? traits_type::eof() : c; } }; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // create the console if(AllocConsole()) { freopen("CONOUT$", "w", stdout); SetConsoleTitle("Debug Console"); SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); } // set std::cout to use my custom streambuf outbuf ob; std::streambuf *sb = std::cout.rdbuf(&amp;ob); // do some work here // make sure to restore the original so we don't get a crash on close! std::cout.rdbuf(sb); return 0; } </code></pre> <p>Anyone have a better/cleaner solution than just forcing <code>std::cout</code> to be a glorified <code>fputc</code>?</p>
[ { "answer_id": 312980, "author": "Dmitry Khalatov", "author_id": 18174, "author_profile": "https://Stackoverflow.com/users/18174", "pm_score": 3, "selected": false, "text": "OutputDebugStringA" }, { "answer_id": 424236, "author": "Evan Teran", "author_id": 13430, "aut...
2008/11/23
[ "https://Stackoverflow.com/questions/311955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13430/" ]
311,970
<p>I am trying to create a custom accordion for my page to that display my posts. I have it in list format using HTML and I am trying to create an effect when you click each header to expand to show more information.</p> <p>But I don't want to have say six blocks of code for six of the <code>&lt;li&gt;</code> elements I have on the page.</p> <p>Is there a way to run it through .each(); perhaps? Instead of creating each section? Try a more dynamic approach.</p>
[ { "answer_id": 311977, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "<script type=\"text/javascript\" src=\"jquery.js\"></script>\n<script type=\"text/javascript\">\n$(document).ready(function()\n{...
2008/11/23
[ "https://Stackoverflow.com/questions/311970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,987
<p>Hi I have a JSON object that is a 2-dimentional array and I need to pass it to PHP using Ajax.Request (only way I know how). ...Right now I manually serialized my array using a js function...and get the data in this format: s[]=1&amp;d[]=3&amp;[]=4 etc. ....</p> <p>my question is: Is there a way to pass the JSON object more directly/efficientely?..instead of serializing it myself?</p> <p>Thanks for any suggestions, Andrew</p>
[ { "answer_id": 312063, "author": "Luis Melgratti", "author_id": 17032, "author_profile": "https://Stackoverflow.com/users/17032", "pm_score": 2, "selected": false, "text": "var myJSON= Object.toJSON(youArray);\n" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/311987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
311,990
<p>I have floated images and inset boxes at the top of a container using <code>float:right</code> (or <code>left</code>) many times. Now, I need to float a <code>div</code> to the bottom right corner of another <code>div</code> with the normal text wrap that you get with <code>float</code> (text wrapped above and to the left only).</p> <p>I thought this must be relatively easy even though <code>float</code> has no <code>bottom</code> value but I haven't been able to do it using a number of techniques and searching the web hasn't come up with anything other than using absolute positioning but this doesn't give the correct word wrap behaviour.</p> <p>I had thought this would be a very common design but apparently it isn't. If nobody has a suggestion I'll have to break my text up into separate boxes and align the <code>div</code> manually but that is rather precarious and I'd hate to have to do it on every page that needs it.</p>
[ { "answer_id": 312008, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 8, "selected": false, "text": "position: relative" }, { "answer_id": 312011, "author": "Yona", "author_id": 40007, "author_pro...
2008/11/23
[ "https://Stackoverflow.com/questions/311990", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12845/" ]
312,003
<p>We all know that premature optimization is the root of all evil because it leads to unreadable/unmaintainable code. Even worse is pessimization, when someone implements an "optimization" because they <em>think</em> it will be faster, but it ends up being slower, as well as being buggy, unmaintainable, etc. What is the most ridiculous example of this that you've seen?</p>
[ { "answer_id": 312017, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 6, "selected": false, "text": "String msg = \"Count = \" + count + \" of \" + total + \".\";\n" }, { "answer_id": 312059, "author": "Do...
2008/11/23
[ "https://Stackoverflow.com/questions/312003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23903/" ]
312,006
<p>I have a system that creates an order and that order can be billed to a house account, sent Cash on Delivery (COD), or charged to a credit card. I've created the following tables:</p> <p>ORDERS<br/> order_id<br/> billingoption_id</p> <p>BILLINGOPTIONS<br/> billingoption_id<br/></p> <p>I'm unsure of how the next table should be built for the billing data. Should I build a separate table for each type of billing option (ie. COD, Credit Cards, and House Account)? Then would I have another foreign key column on the Orders table that would refer to a record for the billing data?</p>
[ { "answer_id": 312144, "author": "Nicholas Piasecki", "author_id": 32187, "author_profile": "https://Stackoverflow.com/users/32187", "pm_score": 4, "selected": true, "text": "billingoptions" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37347/" ]
312,009
<p>I have two tables in a DataSet in .NET. I want to join them on an ID column. Then I want a DataGridView to display two columns from the first table and one column from the second table.</p> <p>If it makes it easier, the relation between the two tables is one-to-one.</p> <p>Can it be done?</p>
[ { "answer_id": 312686, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": " DataTable left = new DataTable\n {\n Columns = { {\"PK\", typeof(int)}, {\"Name\", typeof(s...
2008/11/23
[ "https://Stackoverflow.com/questions/312009", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29281/" ]
312,015
<p>I'd like a textbox that allows for certain text within to be "constant" and uneditable while the rest of the text is editable. For instance, I'd like to define a template like this:</p> <pre><code>&lt;Name:&gt;[] &lt;Address:&gt;[] &lt;City&gt;:[] </code></pre> <p>So that the user could later enter:</p> <pre><code>&lt;Name:&gt;[Stefan] &lt;Address:&gt;[Nowhere] &lt;City&gt;:[Alaska] </code></pre> <p>But not:</p> <pre><code>&lt;I'm typing here lol:&gt;[Stefan] &lt;Address:&gt;[Nowhere] &lt;State&gt;:[Alaska] </code></pre> <p>Ideally, they wouldn't even be able to put their cursor in between the &lt;>, similar to Microsoft Word templates.</p> <p>Any ideas? The masked textbox control seems to be along the right path, but isn't multiline and doesn't allow you to enter a variable number of characters in between the braces, for instance.</p> <p>Thanks in advance.</p>
[ { "answer_id": 312023, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 3, "selected": true, "text": "(.*)" }, { "answer_id": 312668, "author": "P Daddy", "author_id": 36388, "author_profile": "https://S...
2008/11/23
[ "https://Stackoverflow.com/questions/312015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13257/" ]
312,022
<p>is there any way to make IE6 understand double classes, say I have a class MenuButton with a color class and possibly a clicked class; like :</p> <pre><code>.LeftContent a.MenuButton {..general rules..} .LeftContent a.MenuButton.Orange {..sets background-image..} .LeftContent a.MenuButton.Clicked {...hum ta dum...} </code></pre> <p>Now, IE6 understands <code>&lt;a class="MenuButton Orange"&gt;</code>, but when adding Clicked, like <code>&lt;a class="MenuButton Orange Clicked"&gt;</code>, IE just ignores the Clicked rule.</p> <p>Of course, I could rewrite my CSS, and have own rules for .MenuButtonOrange<br> and such (and it'd probably taken a lot shorter time than asking this question ;-),<br> but golly, it just so unappealing and Web 0.9...</p> <p>Cheers!</p>
[ { "answer_id": 312038, "author": "Borgar", "author_id": 27388, "author_profile": "https://Stackoverflow.com/users/27388", "pm_score": 6, "selected": true, "text": "Orange" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/447694/" ]
312,024
<p>I have a class Agent with a property Id</p> <p>Given a collection of Agents I need to check if any of them have duplicate Ids.</p> <p>I am currently doing this with a hash table but am trying to get Linq-ified, what's a good way of doing this?</p>
[ { "answer_id": 312033, "author": "Yona", "author_id": 40007, "author_profile": "https://Stackoverflow.com/users/40007", "pm_score": 1, "selected": false, "text": "foreach(var agent in Agents) {\n if(Agents.Count(a => a.ID == agent.ID) > 1)\n Console.WriteLine(\"Found: {0}\", ag...
2008/11/23
[ "https://Stackoverflow.com/questions/312024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
312,040
<p>I'm writing a simple IDictionary abstraction in C# that wraps a Dictionary&lt;K, ICollection&lt;V&gt;&gt;. Basically, it maps multiple values to one key. I can't decide whether to remove a key and its empty list when the last item in a values list is removed, or leave it (to avoid instantiating a new collection if the key is reused) and do checks on a key's values' Count when determining whether a key exists.</p>
[ { "answer_id": 312509, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 2, "selected": false, "text": "ILookup<TKey,TValue>" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18049/" ]
312,044
<p>I want to set the width of a TextBlock based on the width of its container, minus the margins set on the TextBlock.</p> <p>Here is my code:</p> <pre><code>&lt;TextBlock x:Name="txtStatusMessages" Width="{Binding ElementName=LayoutRoot,Path=ActualWidth }" TextWrapping="WrapWithOverflow" Foreground="White" Margin="5,5,5,5"&gt;This is a message &lt;/TextBlock&gt; </code></pre> <p>And that works great except for the fact that the TextBlock is 10 units too big due to the Left and Right Margins bbeing set to 5.</p> <p>OK, so I thought... Let's use a Converter. But I don't know how to pass the ActualWidth of my container control (SEE ABOVE: LayoutRoot).</p> <p>I know how to use converters, and even converters with parameters, just not a parameter like... Binding ElementName=LayoutRoot,Path=ActualWidth</p> <p>For example, I can't make this work:</p> <pre><code>Width="{Binding Converter={StaticResource PositionConverter}, ConverterParameter={Binding ElementName=LayoutRoot,Path=ActualWidth }}" </code></pre> <p>I hope I made this clear enough and hope that you can help because Google is no help for me tonight.</p>
[ { "answer_id": 312171, "author": "Danny Varod", "author_id": 38368, "author_profile": "https://Stackoverflow.com/users/38368", "pm_score": 5, "selected": true, "text": "Width=\"{Binding ElementName=LayoutRoot, Path=ActualWidth,\nConverter={StaticResource PositionConverter}, ConverterPara...
2008/11/23
[ "https://Stackoverflow.com/questions/312044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6514/" ]
312,054
<p>So I just spent 5 hours troubleshooting a problem which turned out to be due not only to the <a href="https://web.archive.org/web/20141209040727/http://classicasp.aspfaq.com/general/what-is-wrong-with-isnumeric.html" rel="nofollow noreferrer">old unreliable</a> <code>ISNUMERIC</code> but it looks like my problem only appears when the UDF in which <code>ISNUMERIC</code> is declared <code>WITH SCHEMABINDING</code> and is called within a stored proc (I've got a lot of work to do to distill it down into a test case, but my first need is to replace it with something reliable).</p> <p>Any recommendations on good, efficient replacements for <code>ISNUMERIC()</code>. Obviously there really need to be variations for <code>int</code>, <code>money</code>, etc., but what are people using (preferably in T-SQL, because on this project, I'm restricted to SQL Server because this is a high-volume SQL Server to SQL Server data processing task)?</p>
[ { "answer_id": 312655, "author": "HTTP 410", "author_id": 13118, "author_profile": "https://Stackoverflow.com/users/13118", "pm_score": 4, "selected": false, "text": "NOT LIKE '%[^0-9]%'\n" }, { "answer_id": 312713, "author": "Dave Markle", "author_id": 24995, "author...
2008/11/23
[ "https://Stackoverflow.com/questions/312054", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18255/" ]
312,055
<p>Some repository clones I have allow me to do this:</p> <pre><code>% git pull % git push </code></pre> <p>But other repositories require me to type:</p> <pre><code>% git pull origin master % git push origin master </code></pre> <p>I think I am missing something in the latter case - does anyone know what is (not) going on here? I am using the latest git version, just obviously not using it well.</p>
[ { "answer_id": 312061, "author": "Brian Gianforcaro", "author_id": 3415, "author_profile": "https://Stackoverflow.com/users/3415", "pm_score": 5, "selected": true, "text": "[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n" }, { "answer_id": 312267, ...
2008/11/23
[ "https://Stackoverflow.com/questions/312055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14356/" ]
312,091
<p>My code opens more than 256 file handles, So When I run it on solaris machines I am ending up in "Exceeding file handlers limit" error. </p> <p>I have two questions regarding this</p> <p>1) Is this limit is only for 32 bit softwares or 64 bit softwares also suffer from it. I googled about it and came to know that 64 bit softwares do not have this limit.(<a href="http://developers.sun.com/solaris/articles/stdio_256.html" rel="nofollow noreferrer">http://developers.sun.com/solaris/articles/stdio_256.html</a>) But I built 64 bit static object and when i use this it is giving the error. What actually 64 bit software means?</p> <p>2) As given in the above link I used ulimit to increase file handlers limit (in run time, I mean just before running the command), exported extendedFile library and I am not got getting any error.What we have to do incase of Linux?</p> <p>Thanks D. L. Kumar</p>
[ { "answer_id": 312106, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 1, "selected": false, "text": "$ file `which ls`\n/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (...
2008/11/23
[ "https://Stackoverflow.com/questions/312091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
312,103
<p>I know how to do this using for loops. Is it possible to do something like this using LINQ or lambdas?</p> <pre><code>int[] a = { 10, 20, 30 }; int[] b = { 2, 4, 10 }; int[] c = a * b; //resulting array should be { 20, 80, 300 } </code></pre>
[ { "answer_id": 312126, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 2, "selected": false, "text": "int[] a = {10, 20, 30};\nint[] b = {2, 4, 10};\n\nif (a.Length == b.Length)\n{\n int[] result = (from i in Enu...
2008/11/23
[ "https://Stackoverflow.com/questions/312103", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2470/" ]
312,115
<p>I'm getting some really wierd linking errors from a class I wrote. I am completely unable to find anything that will describe what is happening. </p> <p>Visual Studio (Windows XP)</p> <blockquote> <p>players.obj : error LNK2019: unresolved external symbol "public: __thiscall TreeNode::TreeNode(void)" (??0?$TreeNode@VPlayer@@@@QAE@XZ) referenced in function "public: __thiscall PlayerList::PlayerList(void)" (??0PlayerList@@QAE@XZ)</p> </blockquote> <p>Xcode (OSX 10.5)</p> <blockquote> <p>Undefined symbols: "TreeNode::~TreeNode()", referenced from: PlayerList::~PlayerList()in players.o</p> </blockquote> <p>Header File: generics.h</p> <pre><code>class TreeNode : public BaseNode{ public: const static int MAX_SIZE = -1; //-1 means any size allowed. const static int MIN_SIZE = 0; //getters int size() const; vector&lt;C*&gt; getChildren() const; //setters void setChildren(vector&lt;C*&gt; &amp;list); //Serialization virtual void display(ostream &amp;out) const; virtual void read(istream &amp;in); virtual void write(ostream &amp;out) const; //Overrides so SC acts like an array of sorts. virtual C* get(int id) const; virtual int get(C *child) const; virtual bool has(C *child) const; virtual C* pop(int id); virtual void push(C *child); virtual TreeNode&amp; operator&lt;&lt; (C *child); //append virtual void remove(int id); //Clears memory virtual void remove(C *child); //Clears memory //Initalizers TreeNode(); TreeNode(istream &amp;in); TreeNode(long id, istream &amp;in); TreeNode(BaseNode* parent, istream &amp;in); TreeNode(long id, BaseNode* parent); TreeNode(long id, BaseNode* parent, istream &amp;in); ~TreeNode(); string __name__() const{ return "TreeNode"; } protected: void clearChildren(); void initalizeChildren(); vector&lt;C*&gt; _children; }; </code></pre> <p>Code from a subclass of TreeNode</p> <pre><code>PlayerList::PlayerList() : TreeNode&lt;Player&gt;(){} PlayerList::PlayerList(istream &amp;in) : TreeNode&lt;Player&gt;(in){} PlayerList::~PlayerList(){} </code></pre>
[ { "answer_id": 312127, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 0, "selected": false, "text": "TreeNode::TreeNode() :\n /* initializers here */\n{\n // ...\n}\n\nTreeNode::~TreeNode()\n{\n // ...\n}\n" }, ...
2008/11/23
[ "https://Stackoverflow.com/questions/312115", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16204/" ]
312,116
<p>I have a simple function in which an array is declared with size depending on the parameter which is int.</p> <pre><code> void f(int n){ char a[n]; }; int main() { return 0; } </code></pre> <p>This piece of code compiles fine on <a href="http://en.wikipedia.org/wiki/G%2B%2B" rel="noreferrer">GNU C++</a>, but not on MSVC 2005.</p> <p>I get the following compilation errors:</p> <pre><code> .\main.cpp(4) : error C2057: expected constant expression .\main.cpp(4) : error C2466: cannot allocate an array of constant size 0 .\main.cpp(4) : error C2133: 'a' : unknown size </code></pre> <p>What can I do to correct this?</p> <p>(I'm interested in making this work with MSVC,without using new/delete)</p>
[ { "answer_id": 312120, "author": "Jim Buck", "author_id": 2666, "author_profile": "https://Stackoverflow.com/users/2666", "pm_score": 3, "selected": false, "text": "char *a = (char *)_alloca(n);\n" }, { "answer_id": 312121, "author": "strager", "author_id": 39992, "au...
2008/11/23
[ "https://Stackoverflow.com/questions/312116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34051/" ]
312,124
<p>How do I apply a <em>repeating</em> texture that always maintains its original scale (1 pixel in the texture = 1 pixel on screen), regardless of the vertex data it is applied with.</p> <p>I realize this is not the most usual task, but is it possible to easily set opengl to do this, or do I need to apply some kind of mask to vertex data that respects its original appearance?</p> <p>edit: in my specific case, I'm trying to draw 2D ellipses of different sizes, with the same pixel pattern. The ellipses are made of a triangle fan, and I'm having a hard time to draw a repeating texture of any kind on it. I was hoping there was some opengl configuration combination to do this easily. Also, now I realize it's important to mention that I'm using opengles, for the iphone, so GLU is not available.</p>
[ { "answer_id": 312377, "author": "Chris", "author_id": 15578, "author_profile": "https://Stackoverflow.com/users/15578", "pm_score": 4, "selected": true, "text": "const XSize = 640, YSize = 480\nglMatrixMode (GL_PROJECTION)\nglLoadIdentity ()\nglOrtho (0, XSize, YSize, 0, 0, 1)\nglMatrix...
2008/11/23
[ "https://Stackoverflow.com/questions/312124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36182/" ]
312,150
<p>Getting started with jquery and having trouble getting hello world type example going for asp.net mvc. I get a runtime error "object expected" when trying to load a page with this script. </p> <p>A. Where should script tags be placed in a master page? B. What might I be doing wrong? There are definitely "a" elements in my page?</p> <pre><code>&lt;script src="../Scripts/jquery-1.2.6.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../Scripts/jquery.corner.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("a").click(function(event) { alert("Thanks for visiting!"); }); }); &lt;/script&gt; </code></pre>
[ { "answer_id": 312162, "author": "Dan Esparza", "author_id": 19020, "author_profile": "https://Stackoverflow.com/users/19020", "pm_score": 3, "selected": false, "text": "<head>" }, { "answer_id": 312319, "author": "æther", "author_id": 39899, "author_profile": "https:...
2008/11/23
[ "https://Stackoverflow.com/questions/312150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
312,163
<p>How would I go about implementation the queries required for pagination?</p> <p>Basically, when page 1 is requested, get the first 5 entries. For page 2, get the next 5 and so on.</p> <p>I plan to use this via the couchdb-python module, but that shouldn't make any difference to the implementation.</p>
[ { "answer_id": 312166, "author": "dbr", "author_id": 745, "author_profile": "https://Stackoverflow.com/users/745", "pm_score": 1, "selected": false, "text": "posthelper.page()" }, { "answer_id": 314532, "author": "Kerr", "author_id": 39392, "author_profile": "https://...
2008/11/23
[ "https://Stackoverflow.com/questions/312163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
312,168
<p>So I was making a class the other day and used Eclipse's method to create the equals method when I realized that it generated the following <strong>working</strong> code:</p> <pre><code>class Test { private int privateInt; [...] public boolean equals(Object obj) { [...] Test t = (Test) obj; if ( t.privateInt == privateInt ) { [...] } } </code></pre> <p>t.privateInt..???? It's suppose to be private! So I guess there is one more field visibility other than private, protected, package protected and public.</p> <p>So what is happening here? How is this called? <strong>Where would somebody use this?</strong> Doesn't this break encapsulation? What if the class didn't have a mutator and I changed this? Does this happen to C++ as well? Is this an OO idiom? If not, then why did Java do it?</p> <p>Generally, where can I find information about this?</p> <p>Thank you.</p>
[ { "answer_id": 312178, "author": "Michael Sharek", "author_id": 1958, "author_profile": "https://Stackoverflow.com/users/1958", "pm_score": 6, "selected": true, "text": "if ( t.privateInt == this.privateInt )\n" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2644/" ]
312,170
<ol> <li>VARCHAR does not store Unicode characters.</li> <li>NVARCHAR does store Unicode characters.</li> <li>Today's applications should always be Unicode compatible.</li> <li>NVARCHAR takes twice the amount of space to store it.</li> <li>Point 4 doesn't matter because storage space is extremely inexpensive.</li> </ol> <p>Ergo: When designing SQL Server databases today, one should always use NVARCHAR.</p> <p>Is this sound reasoning? Does anyone disagree with any of the premises? Are there any reasons to choose VARCHAR over NVARCHAR today?</p>
[ { "answer_id": 312246, "author": "Michael Trausch", "author_id": 26534, "author_profile": "https://Stackoverflow.com/users/26534", "pm_score": 2, "selected": false, "text": "VARCHAR" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4639/" ]
312,184
<p>Extension method is a really helpful feature that you can add a lot of functions you want in any class. But I am wondering if there is any disadvantage that might bring troubles to me. Any comments or suggestions?</p>
[ { "answer_id": 55989940, "author": "Mukesh Adhvaryu", "author_id": 2226467, "author_profile": "https://Stackoverflow.com/users/2226467", "pm_score": 0, "selected": false, "text": "public interface IPointF{\n float X { get; }\n float Y { get; }\n}\n\npublic struct PointF: IPointF{\n...
2008/11/23
[ "https://Stackoverflow.com/questions/312184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40029/" ]
312,185
<p>I am new to C++ on MacOS. I got an error when I used <code>kbhit()</code> in my program.</p> <p>I used <code>#include&lt;conio.h&gt;</code> but got error too, so I searched and test with <code>#include&lt;curses.h&gt;</code> but error is still remained.</p>
[ { "answer_id": 312198, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 2, "selected": false, "text": "int mygetch() {\n char ch;\n int error;\n static struct termios Otty, Ntty;\n\n fflush(stdout);\n tcgeta...
2008/11/23
[ "https://Stackoverflow.com/questions/312185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
312,187
<p>I've seen quite a few developer job postings recently that include a sentence that reads more or less like this: "Must have experience with N-Tier architecture", or "Must be able to develop N-Tier apps".</p> <p>This leads me to ask, what is N-Tier architecture? How does one gain experience with it?</p>
[ { "answer_id": 51452261, "author": "Manjitha Teshara", "author_id": 8077972, "author_profile": "https://Stackoverflow.com/users/8077972", "pm_score": 2, "selected": false, "text": "In a closed layer architecture, a layer can only call the next layer immediately down.\nIn an open layer ar...
2008/11/23
[ "https://Stackoverflow.com/questions/312187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8409/" ]
312,188
<p>I am given an integer (lets call it x) and I need to generate an array of arrays, where each subarray is a list of elements which are one of a given set of integers, and the sum of all of the elements of each subarray is x. The array of arrays needs to contain all possible distinct subarrays of this form.</p> <p>For example, if x is 3 and the list of possible elements is {1, 2}, I'm looking to generate {{1, 2}, {2, 1}}.</p> <p>What would be the best way to go about doing this (in pseudocode or Java)? Is this 2D array the best way to store this type of data? I couldn't think of anything better, but I'm guessing there is something out there.</p>
[ { "answer_id": 312209, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 0, "selected": false, "text": "ArrayList<E>" }, { "answer_id": 312237, "author": "Claudiu", "author_id": 15055, "author_profile":...
2008/11/23
[ "https://Stackoverflow.com/questions/312188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40036/" ]
312,213
<p>I want to use part of the output of a command run from the command line in another xterm, or as part of a different command. For instance: </p> <pre><code>&gt; grep error error.log error: can't find file ~/&lt;some very long path&gt;/thisfile </code></pre> <p>and I want to do this:</p> <pre><code>&gt;ls ~/&lt;some very long path&gt;/ </code></pre> <p>I know two ways to do this:<br> 1. copy <code>~/&lt;some very long path&gt;/</code> with the mouse.<br> 2. use some combination of <code>head</code>/<code>tail</code>/<code>awk</code>/<code>sed</code>/<code>perl</code>/<code>cut</code>/etc... to extract only what I need from the output and then use <em>that</em> inside backticks.</p> <p>Is there any way to copy text without using the mouse? The example that comes to mind is visual mode inside VIM, but I don't know how to do that inside the xterm.</p>
[ { "answer_id": 312215, "author": "strager", "author_id": 39992, "author_profile": "https://Stackoverflow.com/users/39992", "pm_score": 7, "selected": true, "text": "screen" }, { "answer_id": 318874, "author": "salty-horse", "author_id": 16081, "author_profile": "https...
2008/11/23
[ "https://Stackoverflow.com/questions/312213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
312,214
<p>I already have a deploy.rb that can deploy my app on my production server. </p> <p>My app contains a custom rake task (a .rake file in the lib/tasks directory). </p> <p>I'd like to create a cap task that will remotely run that rake task.</p>
[ { "answer_id": 312227, "author": "Richard Poirier", "author_id": 26842, "author_profile": "https://Stackoverflow.com/users/26842", "pm_score": 6, "selected": true, "text": "run(\"cd #{deploy_to}/current && /usr/bin/env rake `<task_name>` RAILS_ENV=production\")\n" }, { "answer_id...
2008/11/23
[ "https://Stackoverflow.com/questions/312214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26842/" ]
312,230
<p>When working with PDFs, I've run across the MIME types <code>application/pdf</code> and <code>application/x-pdf</code> among others. </p> <p>Is there a difference between these two types, and if so what is it? Is one preferred over the other?</p> <p>I'm working on a web app which must deliver huge amounts of PDFs and I want to do it the correct way, if there is one.</p>
[ { "answer_id": 312258, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 12, "selected": true, "text": "application/pdf" }, { "answer_id": 34262538, "author": "Lucky", "author_id": 1793718, "author_profile...
2008/11/23
[ "https://Stackoverflow.com/questions/312230", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20745/" ]
312,245
<p>I want to know what's the difference between string and stream in c++, and what's stringstream?</p>
[ { "answer_id": 312301, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 3, "selected": false, "text": "istream" }, { "answer_id": 312309, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https...
2008/11/23
[ "https://Stackoverflow.com/questions/312245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40040/" ]
312,263
<p>What is a good way to implement keyboard handling? In any language, where I write a keyboard-interactive program (such as a tetris game), I end up having some code that looks like this:</p> <pre><code>for event in pygame.event.get(): if event.type == KEYDOWN: if False: pass #make everything an elif elif rotating: pass elif event.key == K_q: elif event.key == K_e: elif event.key == K_LEFT: curpiece.shift(-1, 0) shadowpiece = curpiece.clone(); setupshadow(shadowpiece) elif event.key == K_RIGHT: curpiece.shift(1, 0) shadowpiece = curpiece.clone(); setupshadow(shadowpiece) </code></pre> <p>(shortened). I don't like this, as this has to go in my main loop, and it messes with all parts of the program. This also makes it impossible to have a user config screen where they can change which key maps to which action. Is there a good pattern to do this using some form of function callbacks?</p>
[ { "answer_id": 312270, "author": "andrewrk", "author_id": 432, "author_profile": "https://Stackoverflow.com/users/432", "pm_score": 5, "selected": true, "text": "def handle_quit():\n quit()\n\ndef handle_left():\n curpiece.shift(-1, 0)\n shadowpiece = curpiece.clone(); setupshadow...
2008/11/23
[ "https://Stackoverflow.com/questions/312263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
312,273
<p>I have a query (which was created by LINQ to SQL) to get me a list of 'site visits' that were made between a certain date range which resulted in an order (orderid is not null).</p> <p>Theres nothing wrong with the query. I just need advice on creating the correct index for it. I was playing around trying different combinations on a production site and managed to screw things up such that a foreign key got disconnected. I fixed that after some panic - but thought I'd ask for advice now before recreating an index. </p> <p>The table is getting close to a million rows and I need the indexes to help me out here. This query is only used for reporting so doesnt have to be extremely fast, just not delay other user's queries (which it is doing).</p> <pre><code>SELECT TOP 1000 t0.SiteVisitId, t0.OrderId, t0.Date, t1.Domain, t0.Referer, t0.CampaignId FROM SiteVisit AS t0 LEFT OUTER JOIN KnownReferer AS t1 ON t1.KnownRefererId = t0.KnownRefererId WHERE t0.Date &lt;= @p0 AND t0.Date &gt;= @p1 AND t0.OrderId IS NOT NULL ORDER BY t0.Date DESC @p0='2008-11-1 23:59:59:000', @p1='2008-10-1 00:00:00:000' </code></pre> <p>I currently have a clustered index on <code>SiteVisitId</code>, which is my identity integer column.</p> <p>I dont know which of the following are most likely to be most efficient:</p> <ul> <li>Create an index on <code>Date</code> </li> <li>Create an index on <code>Date</code> AND a separate index on <code>OrderId</code></li> <li>Create a 'multicolumn' index on <code>Date</code> AND <code>OrderId</code></li> <li>Some other combination?</li> </ul> <p>I am also wondering whether I should create a separate bit column for <code>hasOrder</code> instead of checking if <code>OrderId IS NOT NULL</code> if that might be more efficient.</p> <p>FYI: The KnownReferer is just a table which contains a list of 100 or so known HttpReferers so i can easily see how many hits from google, yahoo etc.</p>
[ { "answer_id": 312298, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 2, "selected": false, "text": "[Date]" }, { "answer_id": 312338, "author": "WW.", "author_id": 14663, "author_profile": "https://Stacko...
2008/11/23
[ "https://Stackoverflow.com/questions/312273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940/" ]
312,284
<p>I have been trying to find information on how to retrieve attachments from a gmail account in either python or PHP, I'm hoping that someone here can be of some help, thanks.</p> <p>Related:</p> <ul> <li><a href="https://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail">How can I download all emails with attachments from Gmail?</a></li> </ul>
[ { "answer_id": 312317, "author": "tzot", "author_id": 6899, "author_profile": "https://Stackoverflow.com/users/6899", "pm_score": 4, "selected": true, "text": "imaplib.IMAP4_SSL" }, { "answer_id": 3242719, "author": "Rogus", "author_id": 310221, "author_profile": "htt...
2008/11/23
[ "https://Stackoverflow.com/questions/312284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/115/" ]
312,286
<p>For my programming class I have to write a linked list class. One of the functions we have to include is next(). This function would return the memory address of the next element in the list.</p> <pre><code>#include &lt;iostream&gt; using namespace std; class Set { private: int num; Set *nextval; bool empty; public: Set(); &lt;some return type&gt; next(); }; &lt;some return type&gt; Set::next() { Set *current; current = this; return current-&gt;next; } int main() { Set a, *b, *c; for (int i=50;i&gt;=0;i=i-2) a.insert(i); // I've ommited since it does not pertain to my question // Test the next_element() iterator b = a.next(); c = b-&gt;next(); cout &lt;&lt; "Third element of b = " &lt;&lt; c-&gt;value() &lt;&lt; endl; return 0; } </code></pre> <p>As you can see, I need to set the pointer <code>*b</code> and <code>*c</code> to the memory address that holds the next element in the list. My question is what kind of return type would I use? I've tried putting Set and Set* in place of but get compiler errors. Any help is greatly appreciated.</p>
[ { "answer_id": 312288, "author": "luqui", "author_id": 33796, "author_profile": "https://Stackoverflow.com/users/33796", "pm_score": 4, "selected": true, "text": "Set*" }, { "answer_id": 312289, "author": "Mel Green", "author_id": 32226, "author_profile": "https://Sta...
2008/11/23
[ "https://Stackoverflow.com/questions/312286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38/" ]
312,300
<p>On Vista, I got a problem with the application crash handler. Basically, if something unexpected occurs which cannot be captured by SEH, I get this pop-up window with "The application stopped working", blablabla, "Close program/Debug program" -- that is, after I disable the error reporting using the system control panel. With error reporting enabled, you would get a task dialog with search for solution online, close, debug.</p> <p>This is not so funny if it happens in automated tools, and I wonder whether there is a way to get rid of it <em>totally</em>, read, if my app crashes, it just crashes to the command line or disappears but does not bring up a dialog.</p>
[ { "answer_id": 312366, "author": "wimh", "author_id": 33499, "author_profile": "https://Stackoverflow.com/users/33499", "pm_score": 4, "selected": true, "text": "SetErrorMode(SetErrorMode(0)|SEM_NOGPFAULTERRORBOX);\n" }, { "answer_id": 326420, "author": "Raymond Martineau", ...
2008/11/23
[ "https://Stackoverflow.com/questions/312300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39912/" ]
312,302
<p>If we implement a stack using arrays in C++, what is the best way to reduce the chance of an overflow condition? Also while keeping in mind the time-space trade off?</p>
[ { "answer_id": 312305, "author": "Anteru", "author_id": 39912, "author_profile": "https://Stackoverflow.com/users/39912", "pm_score": 3, "selected": false, "text": "std::vector" }, { "answer_id": 312410, "author": "Johannes Schaub - litb", "author_id": 34509, "author_...
2008/11/23
[ "https://Stackoverflow.com/questions/312302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
312,312
<p>I have a Visual Studio 2005 C++ program that runs differently in Release mode than it does in Debug mode. In release mode, there's an (apparent) intermittent crash occurring. In debug mode, it doesn't crash. What are some reasons that a Release build would work differently than a Debug build?</p> <p>It's also worth mentioning my program is fairly complex and uses several 3rd party libraries for XML processing, message brokering, etc...</p> <p>Thanks in advance!</p>
[ { "answer_id": 312352, "author": "peterchen", "author_id": 31317, "author_profile": "https://Stackoverflow.com/users/31317", "pm_score": 8, "selected": true, "text": "#ifdef DEBUG\n#define Log(x) cout << #x << x << \"\\n\";\n#else \n#define Log(x)\n#endif\n\nif (foo)\n Log(x)\nif (bar)\...
2008/11/23
[ "https://Stackoverflow.com/questions/312312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/191808/" ]
312,314
<p>I know I can access environment variables in PowerShell using <code>$Env</code>. For example, I can access <code>FOO</code> with <code>$Env:FOO</code>.</p> <p>I can't figure out how to access the environment variable called <code>FOO.BAR</code>.</p> <p><code>$Env:FOO.BAR</code> doesn't work. How can I access this from within PowerShell?</p>
[ { "answer_id": 312327, "author": "Jesse Weigert", "author_id": 7618, "author_profile": "https://Stackoverflow.com/users/7618", "pm_score": 3, "selected": false, "text": "[Environment]::GetEnvironmentVariable(\"FOO.BAR\")\n" }, { "answer_id": 312365, "author": "Shay Levy", ...
2008/11/23
[ "https://Stackoverflow.com/questions/312314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7618/" ]
312,318
<p>I've tried to the letter to search for mistakes in my code, but i can't myself get that autocomplete extender to work. Help wanted. </p> <p>Here's my code: (excerpt from my aspx page) </p> <pre><code> &lt;asp:TextBox ID="TextBox1" Width="120px" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="TextBox1" ServiceMethod="GetCompletionList" ServicePath="SearchAutoComplete.asmx" MinimumPrefixLength="1"&gt; &lt;/cc1:AutoCompleteExtender&gt; </code></pre> <p>My Webservice code: </p> <pre><code> [WebMethod] public static string[] GetCompletionList(string prefixText, int count) { List&lt;string&gt; returnData = new List&lt;string&gt;(); MySqlConnection con = new MySqlConnection(Connection.ConnectionString()); string sql = "select title from blog where title like '%" + prefixText + "%'"; MySqlCommand cmd = new MySqlCommand(sql, con); con.Open(); MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { returnData.Add(reader["title"].ToString()); } return returnData.ToArray(); } </code></pre>
[ { "answer_id": 312931, "author": "David Hall", "author_id": 2660, "author_profile": "https://Stackoverflow.com/users/2660", "pm_score": 1, "selected": false, "text": "GetCompletionList" }, { "answer_id": 314105, "author": "Richard Ev", "author_id": 39709, "author_prof...
2008/11/23
[ "https://Stackoverflow.com/questions/312318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
312,321
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/71419/whats-wrong-with-delphis-with">What&#39;s wrong with Delphi&#39;s &ldquo;with&rdquo;</a> </p> </blockquote> <p>I am have a problem debugging code that uses a ‘WITH’ statement in BDS 2006 The debugger will not show the values of the variables with in a class or record. Am I doing something wrong or does BDS 2006 have a bug ?</p> <pre><code>type TNumber = class Num: Integer; end; implementation {$R *.dfm} var MyNumber: TNumber; procedure TForm2.FormCreate(Sender: TObject); begin MyNumber := TNumber.Create; MyNumber.Num := 10; /// MyNumber.Num Can be seen with debugger with MyNumber do begin Num := Num +1 ; /// Num is not seen by the debugger MyNumber.Num := Num +1 ; /// MyNumber.Num is seen but Num is not seen by the debugger end; end; </code></pre> <p>EDIT:</p> <p>Sure one can use the full name of the variable But things become very messy if you have a complex structure with more than one level</p>
[ { "answer_id": 312407, "author": "Cruachan", "author_id": 7315, "author_profile": "https://Stackoverflow.com/users/7315", "pm_score": 5, "selected": true, "text": "With" }, { "answer_id": 312442, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https:/...
2008/11/23
[ "https://Stackoverflow.com/questions/312321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17560/" ]
312,322
<p>I have a variable of type Hashmap<code>&lt;String,Integer</code>>.</p> <p>In this, the Integer value might have to go some manipulation depending upon the value of a flag variable. I did it like this...</p> <pre><code>Hashmapvariable.put( somestring, if (flag_variable) { //manipulation code goes here new Integer(manipulated value); } else { new Integer(non-manipulated value); } ); </code></pre> <p>But I get an error: </p> <blockquote> <p>Syntax error on token(s), misplaced constructs.</p> </blockquote> <p>at the Hashmapvariable.put call.</p> <p>I also get another error</p> <blockquote> <p>Syntax error on token ")", delete this token.</p> </blockquote> <p>at the final ");" line. But I can't delete the ")" - its the closing parentheses for the put method call.</p> <p>I don't get this. What mistake am I doing?</p>
[ { "answer_id": 312330, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 3, "selected": true, "text": "Integer" }, { "answer_id": 312334, "author": "krosenvold", "author_id": 23691, "author_profile": "https...
2008/11/23
[ "https://Stackoverflow.com/questions/312322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9195/" ]
312,328
<p>Pretty much as the question asks. Answers preferably in pseudo code and referenced. The correct answer should value speed over simplicity.</p>
[ { "answer_id": 312332, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 3, "selected": true, "text": "pie_p" }, { "answer_id": 312453, "author": "e.James", "author_id": 33686, "author_profile": "https:...
2008/11/23
[ "https://Stackoverflow.com/questions/312328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42413/" ]
312,357
<p>What platforms and tools should I use for rapid game development and prototyping?</p> <p>Say that I have an idea for a simple game or a game mechanic that I want to try out, what are the best tools for quickly creating something playable that I can experiment with to try out the idea?</p> <p>The platform does not necessarily have to be easy to learn, that is not the issue, but once learned it has to be quick to use.</p>
[ { "answer_id": 312528, "author": "Jason Miesionczek", "author_id": 18811, "author_profile": "https://Stackoverflow.com/users/18811", "pm_score": 3, "selected": false, "text": "public class HelloWorld extends SimpleGame{\n public static void main(String[] args) {\n HelloWorld app = new H...
2008/11/23
[ "https://Stackoverflow.com/questions/312357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40053/" ]
312,378
<p>I would like to know if you guys have any suggestions about debug levels when writing an application.</p> <p>I thought about 4 levels:</p> <p>0 : No Debug<br> 1 : All inputs and outputs<br> 2 : "I am here" notification from significant functions with main parameters<br> 3 : All variables verbose</p>
[ { "answer_id": 313145, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 4, "selected": false, "text": "syslog" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38963/" ]
312,379
<p>I need to draw gridlines on the background of a canvas that will have other controls placed on it. </p> <p>I tried creating a StreamGeometry, using that to draw lines, and getting that assigned to a DrawingBrush. However I find that if the StreamGeometry has too many lines, the program becomes sluggish after the DrawingBrush is assigned to the Canvas.</p> <p>Is there anyway of 'pre-rendering' grid lines and having that assigned to a Canvas?</p> <p>I tried <code>Freeze()</code>ing the brush and geometry but that didn't seem to work. What other options do I have?</p> <p>Here's my code:</p> <pre><code>public void RenderGrid() { this.UpdateGrid(); Pen grid_pen = new Pen(Brushes.Blue, 0.1); StreamGeometry sg = new StreamGeometry(); DrawingBrush b = new DrawingBrush(); GeometryDrawing gd = new GeometryDrawing(); gd.Geometry = sg; gd.Pen = grid_pen; b.Drawing = gd; StreamGeometryContext ctx = sg.Open(); foreach (double d in this.VerticalGrids) { ctx.BeginFigure(new Point(d, 0), true, false); ctx.LineTo(new Point(d, this.RenderSize.Height), true,false); } foreach (double d in this.HorizontalGrids) { ctx.BeginFigure(new Point(0, d), true, false); ctx.LineTo(new Point(this.RenderSize.Width, d),true, false); } ctx.Close(); sg.Freeze(); gd.Freeze(); b.Freeze(); this.Background = b; } </code></pre>
[ { "answer_id": 423429, "author": "mcdrewski", "author_id": 52768, "author_profile": "https://Stackoverflow.com/users/52768", "pm_score": 2, "selected": false, "text": "<DrawingBrush x:Key=\"MyBrush\" TileMode=\"Tile\" Stretch=\"Fill\" \n Viewport=\"0,0,250,250\" ViewportUnits=\"Absolute...
2008/11/23
[ "https://Stackoverflow.com/questions/312379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/618/" ]
312,400
<p>I have the following (shortened query):</p> <pre><code>SELECT `Statistics`.`StatisticID`, COUNT(DISTINCT `Flags`.`FlagType`) AS `FlagCount` FROM `Statistics` LEFT JOIN `Flags` ON `Statistics`.`StatisticID` = `Flags`.`StatisticID` WHERE `FlagCount` = 0 GROUP BY `Statistics`.`StatisticID` ORDER BY `SubmittedTime` DESC LIMIT 0, 10 </code></pre> <p>Now, neither <code>FlagCount = 0</code> or <code>COUNT(Flags.FlagType)</code> work in the <code>WHERE</code> clause. I thought about using a <code>SET</code> but I'm not sure how I'd add that to the query. Any ideas?</p> <p>Thanks,</p>
[ { "answer_id": 312405, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 3, "selected": false, "text": "HAVING COUNT(DISTINCT Flags.FlagType) = 0" }, { "answer_id": 312408, "author": "Community", "author_id...
2008/11/23
[ "https://Stackoverflow.com/questions/312400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2025/" ]
312,424
<p>I am trying to set the <code>fieldValue</code> of the check box to a value I got from the property tag.</p> <p>I am having trouble with the syntax.</p> <p>This is what I have tried:</p> <pre><code>&lt;s:form id="myForm" method="post" action="removeUser" enctype="multipart/form-data"&gt; &lt;s:iterator value="myList"&gt; &lt;tr&gt; &lt;td&gt;&lt;s:property value="id"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="name"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:property value="email"/&gt;&lt;/td&gt; &lt;td&gt;&lt;s:checkbox label="delete" name="delete" fieldValue="&lt;s:property value='id'/&gt;"/&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/s:iterator&gt; &lt;s:submit id="saveForm" value="Delete users"&gt;&lt;/s:submit&gt; &lt;/s:form&gt; </code></pre> <p>However, it keeps on returning me <code>true</code> as the <code>fieldValue</code></p> <p>Can someone familiar with struts please help me?</p> <p>Thanks</p>
[ { "answer_id": 18515194, "author": "rohan", "author_id": 2551459, "author_profile": "https://Stackoverflow.com/users/2551459", "pm_score": 0, "selected": false, "text": "fieldValue=\"<s:property value= \"${id }\" />\"\n" } ]
2008/11/23
[ "https://Stackoverflow.com/questions/312424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17085/" ]
312,443
<p>How do I split a list of arbitrary length into equal sized chunks?</p> <hr /> <p><sub>See <a href="https://stackoverflow.com/q/434287">How to iterate over a list in chunks</a> if the data result will be used directly for a loop, and does not need to be stored.</sub></p> <p><sub>For the same question with a string input, see <a href="https://stackoverflow.com/questions/9475241">Split string every nth character?</a>. The same techniques generally apply, though there are some variations.</sub></p>
[ { "answer_id": 312464, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 13, "selected": true, "text": "def chunks(lst, n):\n \"\"\"Yield successive n-sized chunks from lst.\"\"\"\n for i in range(0, len(lst), n):...
2008/11/23
[ "https://Stackoverflow.com/questions/312443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/112415/" ]
312,444
<p>Greetings,</p> <p>I'm trying to use pylucene in Python 2.6. Since there's no windows build for 2.6, I try to build the source code.</p> <p>First of all, I build JCC (windows, using cygwin)</p> <pre><code>python setup.py build running build running build_py [...] building 'jcc' extension error: None python setup.py install running install [...] copying jcc\config.py -&gt; build\lib.win32-2.6\jcc copying jcc\classes\org\osafoundation\jcc\PythonException.class -&gt; build\lib.win32-2.6\jcc\classes\org\osafoundation\jcc running build_ext building 'jcc' extension error: None </code></pre> <p>Notice that it won't copy anything on my "F:\Python26\Lib\site-packages" directory. I don't know why. So that, I don't know if it's really installed or not.</p> <p>Now, I'll make pylucene</p> <pre><code>make /cygdrive/f/Python26//python.exe -m jcc --shared --jar lucene-java-2.4.0/build/lucene-core-2.4.0.jar [...] 'doc:(I)Lorg/apache/lucene/document/Document;' --version 2.4.0 --files 2 --build f:\Python26\python.exe: No module named jcc make: *** [compile] Error 1 </code></pre> <p>So, it seems JCC wasn't installed at all.</p> <p>Then, I try to copy the "jcc build" under F:\Python26\Lib\site-packages, and I try to make pylucene again:</p> <pre><code>make [...] f:\Python26\python.exe: jcc is a package and cannot be directly executed make: *** [compile] Error 1 </code></pre> <p>Has anyone else seen this and found a workaround?</p>
[ { "answer_id": 2046369, "author": "YOU", "author_id": 213464, "author_profile": "https://Stackoverflow.com/users/213464", "pm_score": 1, "selected": false, "text": "error: None" }, { "answer_id": 3048703, "author": "image72", "author_id": 362668, "author_profile": "ht...
2008/11/23
[ "https://Stackoverflow.com/questions/312444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40062/" ]
312,471
<p>I would like a Win machine to tunnel into an SSH server whenever the machine starts up. I also want the win machine to reboot the SSH program if it ever crashes. The lighterweight &amp; more stable the SSH program, the more happier I am.</p> <p>What options do I have with this? </p>
[ { "answer_id": 24726894, "author": "Sopalajo de Arrierez", "author_id": 1461017, "author_profile": "https://Stackoverflow.com/users/1461017", "pm_score": 1, "selected": false, "text": "C:\\>tasklist | find \"always\" /i\nAlwaysUp.exe 3112 Console 1 ...
2008/11/23
[ "https://Stackoverflow.com/questions/312471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10352/" ]
312,487
<p>Need help narrowing the scope of this Regex to not return records if there is an alphanumeric character preceding the first "I"</p> <pre><code>"I([ ]{1,2})([a-zA-Z]|\d){2,13}" </code></pre> <p>Want to capture I APF From this string, but not the I ARPT. </p> <pre><code>I APF 'NAPLES MUNI ARPT. ' 42894 JEB 29785584 </code></pre> <p>Thanks! </p>
[ { "answer_id": 312504, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 4, "selected": true, "text": "\\b" }, { "answer_id": 312508, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https:...
2008/11/23
[ "https://Stackoverflow.com/questions/312487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
312,491
<p>I'm adding an existing site to SVN.</p> <p>The files already exist on the webserver, and now identical copies (- configuration files) exist in the repository.</p> <p>I want to convert the webserver directory into an SVN working copy, but when I run:</p> <pre><code>svn checkout http://path.to/svn/repo/httpdocs . </code></pre> <p>I get the error:</p> <blockquote> <p>svn: Failed to add file '': object of the same name already exists</p> </blockquote> <p>How do I tell SVN to just overwrite those files whose contents are the same?</p>
[ { "answer_id": 312493, "author": "Ned Batchelder", "author_id": 14343, "author_profile": "https://Stackoverflow.com/users/14343", "pm_score": 2, "selected": false, "text": "old_crufty" }, { "answer_id": 312519, "author": "Will Dean", "author_id": 987, "author_profile"...
2008/11/23
[ "https://Stackoverflow.com/questions/312491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13238/" ]
312,511
<p>I am looking to use/connect to a different database for one of my controllers and one model. I posted this hear since on the forums of CI I am getting no response.</p> <p>I added this in database.php:</p> <pre><code>$db['tdb']['hostname'] = "localhost";//localhost $db['tdb']['username'] = "username";//root $db['tdb']['password'] = "password";//empty $db['tdb']['database'] = "databasename"; $db['tdb']['dbdriver'] = "mysql"; $db['tdb']['dbprefix'] = ""; $db['tdb']['pconnect'] = FALSE; $db['tdb']['db_debug'] = FALSE; $db['tdb']['cache_on'] = FALSE; $db['tdb']['cachedir'] = ""; $db['tdb']['char_set'] = "utf8"; $db['tdb']['dbcollat'] = "utf8_general_ci"; </code></pre> <p>This as my model:</p> <pre><code>&lt;?php class Tadmin_model extends Model{ function Tadmin_model(){ parent::Model(); $tdb = $this-&gt;load-&gt;database('tdb', TRUE); } function FInsert($usernames){ $query = $tdb-&gt;query("SELECT * FROM following"); return $query-&gt;row(); } } ?&gt; </code></pre> <p>And this is the start of my controller:</p> <pre><code>&lt;?php class Tadmin extends Controller{ function Tradmin(){ parent::Controller(); $this-&gt;load-&gt;model('tadmin_model'); </code></pre> <p>And I get this error:</p> <blockquote> <p>A PHP Error was encountered</p> <p>Severity: Notice</p> <p>Message: Undefined variable: tdb</p> <p>Filename: models/tadmin_model.php</p> <p>Line Number: ...</p> <p>Fatal error: Call to a member function query() on a non-object in /blablabla/tadmin_model.php on line ...</p> </blockquote> <p>What am I doing wrong here?</p>
[ { "answer_id": 342812, "author": "Jim OHalloran", "author_id": 38458, "author_profile": "https://Stackoverflow.com/users/38458", "pm_score": 3, "selected": false, "text": "<?php\n\nclass Tadmin_model extends Model{\n var $tdb;\n\n function Tadmin_model(){\n\n parent::Model()...
2008/11/23
[ "https://Stackoverflow.com/questions/312511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]