qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
256,255
<p>I read all over the place about how Spring encourages you to use interfaces in your code. I don't see it. There is no notion of interface in your spring xml configuration. What part of Spring actually encourages you to use interfaces (other than the docs)?</p>
[ { "answer_id": 256274, "author": "Jack Leow", "author_id": 31506, "author_profile": "https://Stackoverflow.com/users/31506", "pm_score": 2, "selected": false, "text": "org.springframework.core.io.Resource" }, { "answer_id": 256329, "author": "toolkit", "author_id": 3295, ...
2008/11/01
[ "https://Stackoverflow.com/questions/256255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22063/" ]
256,264
<p>The symptom of the problem looks like "[0m[27m[24m[J[34;1" which on a terminal translates into the color blue.</p> <p>-A </p>
[ { "answer_id": 256393, "author": "cefstat", "author_id": 19155, "author_profile": "https://Stackoverflow.com/users/19155", "pm_score": 0, "selected": false, "text": "case $TERM in\nxterm-color)\nexport PS1='\\[\\e]0;\\W\\007\\]\\[\\e[34;1m\\]\\W\\[\\e[0m\\]\\$ '\n;;\n*)\nexport PS1='\\W\...
2008/11/01
[ "https://Stackoverflow.com/questions/256264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
256,267
<p>I have a windows service connecting to a SqlServer database on the local box. This works fine most all the time. At a large customer, however, the database connectivity gets corrupted for some rare and unknown reason. When this happens, calls to DbDataAdapter.Fill return a DataSet with a different number of columns than in the select command passed in (validated by trace logs showing the sql expected, and the number of columns returned). For the first few errored DataSets it appears the adapter instance is returning results from the previous query. This is happening even though the adapter objects are unique instances, and the connection/adapter creation calls are thread protected (as DbProviderFactory is not thread safe).</p> <p>Has anyone experience this or something similar? Does anyone know what could cause this? At this moment in time, I'm having a hard time thinking up new ideas for a cause of this.</p>
[ { "answer_id": 256393, "author": "cefstat", "author_id": 19155, "author_profile": "https://Stackoverflow.com/users/19155", "pm_score": 0, "selected": false, "text": "case $TERM in\nxterm-color)\nexport PS1='\\[\\e]0;\\W\\007\\]\\[\\e[34;1m\\]\\W\\[\\e[0m\\]\\$ '\n;;\n*)\nexport PS1='\\W\...
2008/11/01
[ "https://Stackoverflow.com/questions/256267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18313/" ]
256,277
<p>"C Interfaces and Implementations" shows some interesting usage patterns for data structures, but I am sure there are others out there.</p> <p><a href="https://rads.stackoverflow.com/amzn/click/com/0201498413" rel="nofollow noreferrer" rel="nofollow noreferrer">http://www.amazon.com/Interfaces-Implementations-Techniques-Addison-Wesley-Professional/dp/0201498413</a></p>
[ { "answer_id": 256440, "author": "Jonathan Leffler", "author_id": 15168, "author_profile": "https://Stackoverflow.com/users/15168", "pm_score": 4, "selected": true, "text": "#include \"header.h\"\n" } ]
2008/11/01
[ "https://Stackoverflow.com/questions/256277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30636/" ]
256,282
<p>On <a href="http://andrew.hedges.name/blog/" rel="nofollow noreferrer">my blog</a>, I display in the right nav the 10 most popular articles in terms of page hits. Here's how I get that:</p> <pre><code>SELECT * FROM entries WHERE is_published = 1 ORDER BY hits DESC, created DESC LIMIT 10 </code></pre> <p>What I would like to do is show the top 10 in terms of page hits <em>per day.</em> I'm using MySQL. Is there a way I can do this in the database?</p> <p>BTW, The <code>created</code> field is a datetime.</p> <p>UPDATE: I think I haven't made myself clear. What I want is for the blog post with 10,000 hits that was posted 1,000 days ago to have the same popularity as the blog post with 10 hits that was posted 1 day ago. In pseudo-code:</p> <pre><code>ORDER BY hits / days since posting </code></pre> <p>...where <code>hits</code> is just an int that is incremented each time the blog post is viewed.</p> <p>OK, here's what I'm going to use:</p> <pre><code>SELECT *, AVG( hits / DATEDIFF(NOW(), created) ) AS avg_hits FROM entries WHERE is_published = 1 GROUP BY id ORDER BY avg_hits DESC, hits DESC, created DESC LIMIT 10 </code></pre> <p>Thanks, Stephen! (I love this site...)</p>
[ { "answer_id": 256302, "author": "Stephen Walcher", "author_id": 25375, "author_profile": "https://Stackoverflow.com/users/25375", "pm_score": 4, "selected": true, "text": "SELECT *, AVG(hits / DATEDIFF(NOW(), created)) as avg_hits\nFROM entries\nWHERE is_published = 1\nGROUP BY id\nORDE...
2008/11/01
[ "https://Stackoverflow.com/questions/256282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11577/" ]
256,291
<p>What tools do you know, other than those in Visual Studio, to analyze performance bottlenecks in a Windows CE/Mobile application? I'm looking for something like AQTime for CE/Mobile, to profile C/C++ applications compiled to native code.</p>
[ { "answer_id": 256502, "author": "Shane Powell", "author_id": 23235, "author_profile": "https://Stackoverflow.com/users/23235", "pm_score": 4, "selected": true, "text": "// File: callcaphooks.c\n\n#include <stdio.h>\nint main();\n\nvoid _CAP_Enter_Function(void *p) \n{\n if (p != main...
2008/11/02
[ "https://Stackoverflow.com/questions/256291", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8999/" ]
256,297
<p>In C++ I'd like to do something like:</p> <pre><code>int n = get_int_from_user(); char* matrix = new char[n][n]; matrix[0][0] = 'c'; //... matrix[n][n] = 'a'; delete [][] matrix; </code></pre> <p>but of course this doesn't work. What is the best way to do something similar? I've seen some solutions to this but they seem pretty messy.</p>
[ { "answer_id": 256303, "author": "Bernard", "author_id": 61, "author_profile": "https://Stackoverflow.com/users/61", "pm_score": 2, "selected": false, "text": "int n = get_int_from_user();\n\nchar** matrix = new char*[n];\nfor (int i = 0; i < n; i++) {\n matrix[i] = new char[n];\n}\n\...
2008/11/02
[ "https://Stackoverflow.com/questions/256297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30529/" ]
256,306
<p>I have a class that defines a CallRate type. I need to add the ability to create multiple instances of my class by reading the data from a file.</p> <p>I added a static method to my class CallRate that returns a <code>List&lt;CallRate&gt;</code>. Is it ok for a class to generate new instances of itself by calling one of its own constructors? It works, I just wonder if it's the proper thing to do.</p> <pre><code>List&lt;CallRates&gt; cr = CallRates.ProcessCallsFile(file); </code></pre>
[ { "answer_id": 256308, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 5, "selected": true, "text": "XmlReadrer reader = XmlReader.Create(filepathString);\n" }, { "answer_id": 256323, "author": "Jay Bazuzi", "...
2008/11/02
[ "https://Stackoverflow.com/questions/256306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10178/" ]
256,325
<p>For my Django app I have Events, Ratings, and Users. Ratings are related to Events and Users through a foreign keys. When displaying a list of Events I want to filter the ratings of the Event by a user_id so I know if an event has been rated by the user. </p> <p>If I do:</p> <pre><code>event_list = Event.objects.filter(rating__user=request.user.id) </code></pre> <p>(request.user.id gives the user_id of the current logged in user) ...then I only get the events that are rated by the user and not the entire list of events.</p> <p>What I need can be generated through the custom SQL:</p> <pre><code>SELECT * FROM `events_event` LEFT OUTER JOIN ( SELECT * FROM `events_rating` WHERE user_id = ## ) AS temp ON events_event.id = temp.user_id </code></pre> <p>Is there an easier way so I don't have to use custom SQL?</p>
[ { "answer_id": 256342, "author": "S.Lott", "author_id": 10661, "author_profile": "https://Stackoverflow.com/users/10661", "pm_score": 1, "selected": false, "text": "Event.objects.all()" }, { "answer_id": 256400, "author": "Daniel Naab", "author_id": 32638, "author_pro...
2008/11/02
[ "https://Stackoverflow.com/questions/256325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5112/" ]
256,345
<p>Could you write a function that takes one argument (a positive integer) and</p> <ul> <li>divides it by two if it's even, or</li> <li>multiplies it by three and adds one if it's odd</li> </ul> <p>and then returns the resulting number.</p> <p>And then a separate function that takes one argument (a positive integer) and repeatedly passes it to the previous function until it reaches 1 (at which point it stops). The function would return the number of steps it took to reduce it to 1.</p> <p>And then another function which takes two arguments a and b (both positive integers with a &lt;= b) and returns the largest number of repeated Collatz steps it takes to reduce any single number in the range to 1 (including the endpoints). (Collatz steps refers to the previous function).</p> <p>And finally, another function that takes two arguments a and b (both positive integers with a &lt;= b) and returns the number between a and b (including the endpoints) that takes the largest number of Collatz steps to be reduced to 1.</p> <p>These functions are related to the Collatz problem, and I find it very interesting. The subsequent functions will obviously borrow other function that were defined previously.</p> <p>Any idea how we could show this in Scheme code?</p>
[ { "answer_id": 256352, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 0, "selected": false, "text": "(define (collatz x)\n (if (even? x)\n (/ x 2)\n (+ (* x 3) 1)))\n" }, { "answer_id": 256369, "autho...
2008/11/02
[ "https://Stackoverflow.com/questions/256345", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30622/" ]
256,349
<p>I'm trying to find some info on the best and most common RESTful url actions.</p> <p>for example, what url do you use for displaying the details of an item, for editing the item, updating, etc.</p> <pre><code>/question/show/&lt;whatever&gt; /question/edit/&lt;whatever&gt; /question/update/&lt;whatever&gt; (this is the post back url) /question/list (lists the questions) </code></pre> <p>hmm. thanks to anyone helping out :)</p>
[ { "answer_id": 256355, "author": "Allain Lalonde", "author_id": 2443, "author_profile": "https://Stackoverflow.com/users/2443", "pm_score": 4, "selected": false, "text": "/questions/10" }, { "answer_id": 256359, "author": "Brian R. Bondy", "author_id": 3153, "author_p...
2008/11/02
[ "https://Stackoverflow.com/questions/256349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30674/" ]
256,354
<p>In some my project I notice that during executing unit tests under VSTS2008 its VSTestHost's memory consuming grows. As I have very many tests in my solution it leads to OutOfMemroyException eventually. That looks very strange for me as I was sure that MSTest creates a new AppDomain for each unit test. Otherwise how would it reset static fields? But if AppDomain is being created for each test than memory shouldn't leak. But it does.</p> <p>So the question is: Should VS create AppDomain for each test class or not? If yes than how can I check that it does it. I tried tracing through ProcessExpolorer and Performance snap-in. A value of "Total appdomain unloaded" is always 0 during test run.</p>
[ { "answer_id": 256865, "author": "Shrike", "author_id": 27703, "author_profile": "https://Stackoverflow.com/users/27703", "pm_score": 3, "selected": false, "text": "public class Singleton\n{\n public static Singleton Instance = new Singleton();\n\n private Guid _token;\n private...
2008/11/02
[ "https://Stackoverflow.com/questions/256354", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27703/" ]
256,387
<p>When using copy-on-write semantics to share memory among processes, how can you test if a memory page is writable or if it is marked as read-only? Can this be done by calling a specific assembler code, or reading a certain spot in memory, or through the OS's API?</p>
[ { "answer_id": 256409, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 3, "selected": true, "text": "$ cat /proc/self/maps\n\n002b3000-002cc000 r-xp 00000000 68:01 143009 /lib/ld-2.5.so\n002cc000-002cd000 r-xp 000180...
2008/11/02
[ "https://Stackoverflow.com/questions/256387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33364/" ]
256,405
<p>I have a C/C++ application and I need to create a X509 pem certificate containing both a public and private key. The certificate can be self signed, or unsigned, doesn't matter.</p> <p>I want to do this inside an app, not from command line.</p> <p>What OpenSSL functions will do this for me? Any sample code is a bonus!</p>
[ { "answer_id": 256436, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 2, "selected": false, "text": "system" }, { "answer_id": 15082282, "author": "Nathan Osman", "author_id": 193619, "author_profile":...
2008/11/02
[ "https://Stackoverflow.com/questions/256405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
256,451
<p>I've written a VB.NET application that uses SQL CE 3.5. I'm curious if anyone has any best practice or code to help check if A) SQL CE is installed and B) If so, what version. </p> <p>I searched msdn and google for anything but I didn't find anything helpful. I was poking around the registry and found this key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5 with a string value "Version" and the data was 3.5.5692.0. </p> <p>So off the bat my assumption is to check for the presence of this key but it bothers me because the "3.5" key sure sounds like it's tied to the 3.5 DLL. What I'm trying to say is I'd hate to force someone to install SQL 3.5 if they have SQL CE (insert some future version of CE here).</p> <p>Misc info: Target Framework: .NET 2.0 Minimum Target OS: Windows XP SP2</p>
[ { "answer_id": 17834938, "author": "noelicus", "author_id": 865643, "author_profile": "https://Stackoverflow.com/users/865643", "pm_score": 0, "selected": false, "text": "<Fragment>\n <util:RegistrySearch\n Id='SearchForSQLCE'\n Variable=\"SQLCEInstalled\"\n ...
2008/11/02
[ "https://Stackoverflow.com/questions/256451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33371/" ]
256,456
<p>My application has a WCF service tier between the front-end and the database. Since we currently host in IIS6 we are using SOAP over HTTP. How can I find out how much real world time I am spending doing serialization activities in my application?</p>
[ { "answer_id": 256602, "author": "Ray Lu", "author_id": 11413, "author_profile": "https://Stackoverflow.com/users/11413", "pm_score": 1, "selected": false, "text": "AfterReceiveRequest\n{\n DateTime start = datetime.now;\n return start;\n}\nBeforeSendReply\n{\n // start will be passed ...
2008/11/02
[ "https://Stackoverflow.com/questions/256456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32992/" ]
256,460
<p>Is there anything similar to an <code>indexOf</code> function in the NSString objects?</p>
[ { "answer_id": 256464, "author": "Airsource Ltd", "author_id": 18017, "author_profile": "https://Stackoverflow.com/users/18017", "pm_score": 8, "selected": true, "text": "-[NSString rangeOfString:]" }, { "answer_id": 7329792, "author": "firestoke", "author_id": 555796, ...
2008/11/02
[ "https://Stackoverflow.com/questions/256460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12388/" ]
256,490
<p>I'm trying to go deep into Dictionary ADT and Skip List for Java. My textbook doesn't cover a lot about this and whatever it has covered is very complicated. Which is the best online site to get more information on Dictionary ADT and Skip List for Java. I'm looking for the one which talks visually and gives a lot of examples.</p>
[ { "answer_id": 256498, "author": "Alan", "author_id": 17205, "author_profile": "https://Stackoverflow.com/users/17205", "pm_score": 3, "selected": true, "text": "ConcurrentSkipListSet" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
256,495
<p>Are there compilers for high-level languages (such as C) which can be targeted to various architectures by specifying the hardware resources of the target?</p> <p>I'm wondering if there are compilers which can target an architecture by specifying features such as the available registers and instruction set of the processor (i.e. how each instruction changes the state of the processor), and memory layout of the architecture.</p> <p>I am aware that compilers such as <a href="http://gcc.gnu.org/" rel="nofollow noreferrer">gcc</a> can target for multiple archtectures, but I'd like to know if there are compilers that can compile for new architectures by swapping out, say, configuration files, in order to target a new architecture.</p>
[ { "answer_id": 256555, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 2, "selected": true, "text": ".md" }, { "answer_id": 256639, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https:/...
2008/11/02
[ "https://Stackoverflow.com/questions/256495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17172/" ]
256,507
<p>I'm a Lisp beginner. I'm trying to memoize a recursive function for calculating the number of terms in a <a href="http://en.wikipedia.org/wiki/Collatz_conjecture" rel="noreferrer">Collatz sequence</a> (for problem 14 in <a href="http://projecteuler.net/index.php?section=problems&amp;id=14" rel="noreferrer">Project Euler</a>). My code as of yet is:</p> <pre><code>(defun collatz-steps (n) (if (= 1 n) 0 (if (evenp n) (1+ (collatz-steps (/ n 2))) (1+ (collatz-steps (1+ (* 3 n))))))) (defun p14 () (defvar m-collatz-steps (memoize #'collatz-steps)) (let ((maxsteps (funcall m-collatz-steps 2)) (n 2) (steps)) (loop for i from 1 to 1000000 do (setq steps (funcall m-collatz-steps i)) (cond ((&gt; steps maxsteps) (setq maxsteps steps) (setq n i)) (t ()))) n)) (defun memoize (fn) (let ((cache (make-hash-table :test #'equal))) #'(lambda (&amp;rest args) (multiple-value-bind (result exists) (gethash args cache) (if exists result (setf (gethash args cache) (apply fn args))))))) </code></pre> <p>The memoize function is the same as the one given in the <a href="http://lib.store.yahoo.net/lib/paulgraham/onlisp.pdf" rel="noreferrer">On Lisp</a> book. </p> <p>This code doesn't actually give any speedup compared to the non-memoized version. I believe it's due to the recursive calls calling the non-memoized version of the function, which sort of defeats the purpose. In that case, what is the correct way to do the memoization here? Is there any way to have all calls to the original function call the memoized version itself, removing the need for the special m-collatz-steps symbol?</p> <p>EDIT: Corrected the code to have </p> <pre><code>(defvar m-collatz-steps (memoize #'collatz-steps)) </code></pre> <p>which is what I had in my code. Before the edit I had erroneously put:</p> <pre><code>(defvar collatz-steps (memoize #'collatz-steps)) </code></pre> <p>Seeing that error gave me another idea, and I tried using this last defvar itself and changing the recursive calls to </p> <pre><code> (1+ (funcall collatz-steps (/ n 2))) (1+ (funcall collatz-steps (1+ (* 3 n)))) </code></pre> <p>This does seem to perform the memoization (speedup from about 60 seconds to 1.5 seconds), but requires changing the original function. Is there a cleaner solution which doesn't involve changing the original function? </p>
[ { "answer_id": 256552, "author": "Javier", "author_id": 11649, "author_profile": "https://Stackoverflow.com/users/11649", "pm_score": 2, "selected": false, "text": "(setf collatz-steps (memoize lambda (n)\n (if (= 1 n) 0\n (if (evenp n) \n (1+ (collatz-steps (/ n 2)))\n ...
2008/11/02
[ "https://Stackoverflow.com/questions/256507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8127/" ]
256,517
<p>When I was learning Java coming from a background of some 20 years of procedural programming with basic, Pascal, COBOL and C, I thought at the time that the hardest thing about it was wrapping my head around the OOP jargon and concepts. Now with about 8 years of solid Java under my belt, I have come to the conclusion that the single hardest thing about programming in Java and similar languages like C# is the multithreaded/concurrent aspects.</p> <p>Coding reliable and scalable multi-threaded applications is just plain hard! And with the trend for processors to grow "wider" rather than faster, it is rapidly becoming just plain critical.</p> <p>The hardest area is, of course, controlling interactions between threads and the resulting bugs: deadlocks, race conditions, stale data and latency.</p> <p>So my question to you is this: what approach or methodology do <em>you</em> employ for producing safe concurrent code while mitigating the potential for deadlocks, latency, and other problems? I have come up with an approach which is a little unconventional but has worked very well in several large applications, which I will share in a detailed answer to this question.</p>
[ { "answer_id": 256591, "author": "Lawrence Dol", "author_id": 8946, "author_profile": "https://Stackoverflow.com/users/8946", "pm_score": 0, "selected": false, "text": "Object processIocMessage(Object msgsdr, int msgidn, Object msgdta)\n" }, { "answer_id": 256675, "author": "...
2008/11/02
[ "https://Stackoverflow.com/questions/256517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8946/" ]
256,546
<p>Anyone know if there is already a validator for "type" strings?</p> <p>I want to make sure that the type attributes in my custom config are one of the following:</p> <pre> type="TopNamespace.SubNameSpace.ContainingClass, MyAssembly" type="TopNamespace.SubNameSpace.ContainingClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089" </pre> <p>Writing one is easy enough, I just don't want to reinvent the wheel.</p>
[ { "answer_id": 258944, "author": "jon without an h", "author_id": 27578, "author_profile": "https://Stackoverflow.com/users/27578", "pm_score": 0, "selected": false, "text": "List<>\n\"System.Collections.Generic.List`1\"\n\nList<string>\n\"System.Collections.Generic.List`1[[System.String...
2008/11/02
[ "https://Stackoverflow.com/questions/256546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91911/" ]
256,554
<p>In particular, I'm editing the AutoCompletion.plist file for CSSEdit (if that even matters).</p> <p>My question is, are there any characters withing the STRING elements that need to be escaped? spaces? quotes?</p> <p>EDIT: Just to be clear, I'm not using CSSEdit to edit the file - rather the file is part of the CSSEdit package. I'm using TextMate to edit the file (although "Property List Editor.app" is another option) and it is in XML format. Here's a snippet from the AutoCompletion.plist file:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;font-family&lt;/key&gt; &lt;array&gt; &lt;string&gt;Arial&lt;/string&gt; &lt;string&gt;Helvetica&lt;/string&gt; &lt;string&gt;Georgia&lt;/string&gt; &lt;string&gt;serif&lt;/string&gt; &lt;string&gt;sans-serif&lt;/string&gt; &lt;string&gt;cursive&lt;/string&gt; etc... </code></pre> <p>I'd like to add STRINGs with spaces and single quotes such as:</p> <pre><code>&lt;string&gt;Georgia, Times, 'Times New Roman', serif&lt;/string&gt; </code></pre> <p>But CSSEdit goes haywire when I edit the file as such</p>
[ { "answer_id": 257149, "author": "Brian Webster", "author_id": 23324, "author_profile": "https://Stackoverflow.com/users/23324", "pm_score": 5, "selected": true, "text": "<string>Georgia, Times, &apos;Times New Roman&apos;, serif</string>" }, { "answer_id": 257185, "author": ...
2008/11/02
[ "https://Stackoverflow.com/questions/256554", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17252/" ]
256,557
<p>One of the things that seems to be necessary with use of STL is a way to specify local functions. Many of the functions that I would normally provide cannot be created using STL function object creation tools ( eg bind ), I have to hand roll my function object.</p> <p>Since the C++ standard forbids local types to be used as arguments in template instantiations the best I was able to use was to create a small library, ( just showing relevant parts )</p> <pre><code>// library header class MyFunctionBase&lt;R,T&gt; { public: virtual ~MyFunctionBase(); virtual R operator()(const T &amp;) const=0; }; class MyFunction&lt;R,T&gt; { MyFunctionBase&lt;R,T&gt; *b; public: ~MyFunction() { delete b; } virtual R operator()(const T &amp;) const { return (*b)(T); } }; // source file .... class func: public MyFunctionBase ... std::stl_alg(.... MyFunction(new funct)); </code></pre> <p>This has always seemed unwieldly to me. I guess to the people on the ISO committee believe so too and added a lambda to C++.</p> <p>In the meantime how have compilers addressed this problem? ( Especially Windows compilers. )</p> <p>A correction which might clarify a bit. Changelog: Nov 2 replaced to clarify Since the C++ standard forbids local classes as function objects</p>
[ { "answer_id": 256567, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 2, "selected": false, "text": "struct" }, { "answer_id": 257299, "author": "Dean Michael", "author_id": 11274, "author_profile": "https:...
2008/11/02
[ "https://Stackoverflow.com/questions/256557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29178/" ]
256,564
<p>I'm a Python novice, trying to use pyCurl. The project I am working on is creating a Python wrapper for the twitpic.com API (<a href="http://twitpic.com/api.do" rel="nofollow noreferrer">http://twitpic.com/api.do</a>). For reference purposes, check out the code (<a href="http://pastebin.com/f4c498b6e" rel="nofollow noreferrer">http://pastebin.com/f4c498b6e</a>) and the error I'm getting (<a href="http://pastebin.com/mff11d31" rel="nofollow noreferrer">http://pastebin.com/mff11d31</a>).</p> <p>Pay special attention to line 27 of the code, which contains "xml = server.perform()". After researching my problem, I discovered that unlike I had previously thought, .perform() does not return the xml response from twitpic.com, but None, when the upload succeeds (duh!).</p> <p>After looking at the error output further, it seems to me like the xml input that I want stuffed into the "xml" variable is instead being printed to ether standard output or standard error (not sure which). I'm sure there is an easy way to do this, but I cannot seem to think of it at the moment. If you have any tips that could point me in the right direction, I'd be very appreciative. Thanks in advance.</p>
[ { "answer_id": 256610, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 3, "selected": true, "text": "import sys\nimport pycurl\n\nclass Test:\n def __init__(self):\n self.contents = ''\n\n def body_callback(self, buf):...
2008/11/02
[ "https://Stackoverflow.com/questions/256564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33383/" ]
256,566
<p>I'm trying to create a function in C# which will allow me to, when called, return a reference to a given class type. The only types of functions like this that I have seen are in UnrealScript and even then the functionality is hard coded into its compiler. I'm wondering if I can do this in C#. Here's what I mean (code snippet from UnrealScript source):</p> <pre><code>native(278) final function actor Spawn ( class&lt;actor&gt; SpawnClass, optional actor SpawnOwner, optional name SpawnTag, optional vector SpawnLocation, optional rotator SpawnRotation ); </code></pre> <p>Now in UScript you would call it like this...</p> <pre><code>local ActorChild myChildRef; //Ref to ActorChild which Extends 'actor' myChildRef = Spawn(class'ActorChild' ...); //rest of parameters taken out myChildRef.ChildMethod(); //method call to method existing inside class 'ActorChild' </code></pre> <p>Which will return a reference to an object of class 'ActorChild' and set it to variable 'myChildRef.' I need to do something similar within C#.</p> <p>I've looked into Generics but it seems that to use them, I need create an instace of the class where my function lies and pass the 'generic' parameter to it. This isn't very desirable however as I won't need to use the 'Spawn' function for certain classes but I would still need to add the generic parameter to the class whenever I use it.</p> <p>I guess a simplified question would be, how can I return a type that I do not know at compile time and when the different classes could be far too many to trap.</p> <p>Pseudo-Code (sticking to UScript class names, i.e. Actor):</p> <pre><code>//Function Sig public class&lt;Actor&gt; Create(class&lt;Actor&gt; CreatedClass) { return new CreatedClass; } //Function call ActorChild myChild = Create(class'ActorChild'); </code></pre> <p>Any ideas?</p> <p>EDIT: I would like to avoid explicit typecasts that would occur from the class calling Created. If I can typecast to the desired object within the Created method and return the 'unknown type' whatever that may be, I would be extremely happy.</p> <p>EDIT 2: Thanks for your answers.</p>
[ { "answer_id": 256586, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 0, "selected": false, "text": "System.Type t = typeof(ActorChild);\n" }, { "answer_id": 256633, "author": "Alon L", "author_id": ...
2008/11/02
[ "https://Stackoverflow.com/questions/256566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
256,579
<p>I'm working on an application developed by another mob and am confounded by the use of a char field instead of bit for all the boolean columns in the database. It uses "Y" for true and "N" for false (these have to be uppercase). The type name itself is then aliased with some obscure name like <em>ybln</em>.</p> <p>This is very annoying to work with for a lot of reasons, not the least of which is that it just looks downright aesthetically unpleasing.</p> <p>But maybe its me that's stupid - why would anyone do this? Is it a database compatibility issue or some design pattern that I am not aware of?</p> <p>Can anyone enlighten me?</p>
[ { "answer_id": 259176, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "WHERE BooleanColumn" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21966/" ]
256,625
<p>I have seen samples of closure from - <a href="https://stackoverflow.com/questions/36636/what-is-a-closure">What is a &#39;Closure&#39;?</a></p> <p>Can anyone provide simple example of when to use closure?<br></p> <p><b>Specifically, scenarios in which closure makes sense?</b><Br></p> <p>Lets assume that the language doesn't have closure support, how would one still achieve similar thing?</p> <p>Not to offend anyone, please post code samples in a language like c#, python, javascript, ruby etc. <br>I am sorry, I do not understand functional languages yet.</p>
[ { "answer_id": 256630, "author": "Rich", "author_id": 22003, "author_profile": "https://Stackoverflow.com/users/22003", "pm_score": 4, "selected": false, "text": "(defun make-adder (how-much)\n (lambda (x)\n (+ x how-much)))\n" }, { "answer_id": 256663, "author": "zvoase"...
2008/11/02
[ "https://Stackoverflow.com/questions/256625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23574/" ]
256,628
<p>I'm trying to set up a loop where an animation runs a certain number of times, and a function is run before each iteration of the animation. The timing ends up being off, though -- it runs the callback n times, then runs the animation n times. For example:</p> <pre><code>for (var i=0;i&lt;3;i++) { console.log(i); $('#blerg').animate({top:'+=50px'},75,'linear', function(){log('animated')}); } </code></pre> <p>outputs</p> <pre><code>0 1 2 animated animated animated </code></pre> <p>I ran into this problem with scriptaculous before I switched to jquery, and discovered a "beforeSetup" animation callback. Is there a jquery equivalent?</p>
[ { "answer_id": 256645, "author": "MDCore", "author_id": 1896, "author_profile": "https://Stackoverflow.com/users/1896", "pm_score": 2, "selected": false, "text": "do_animation(max_runs, total_runs) {\n log();\n if (total_runs < max_runs) {\n $(foo).animate(..., do_animation(max...
2008/11/02
[ "https://Stackoverflow.com/questions/256628", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33391/" ]
256,647
<p>I want to see how long a function takes to run. What's the easiest way to do this in PLT-Scheme? Ideally I'd want to be able to do something like this:</p> <pre><code>&gt; (define (loopy times) (if (zero? times) 0 (loopy (sub1 times)))) &gt; (loopy 5000000) 0 ;(after about a second) &gt; (timed (loopy 5000000)) Took: 0.93 seconds 0 &gt; </code></pre> <p>It doesn't matter if I'd have to use some other syntax like <code>(timed loopy 5000000)</code> or <code>(timed '(loopy 5000000))</code>, or if it returns the time taken in a cons or something.</p>
[ { "answer_id": 256652, "author": "Claudiu", "author_id": 15055, "author_profile": "https://Stackoverflow.com/users/15055", "pm_score": 2, "selected": false, "text": "(time-apply proc arg-list)" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15055/" ]
256,700
<p>What is a view in Oracle?</p>
[ { "answer_id": 256703, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 7, "selected": false, "text": "SELECT customerid, customername FROM customers WHERE countryid='US';\n" }, { "answer_id": 5867837, "author": "s...
2008/11/02
[ "https://Stackoverflow.com/questions/256700", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
256,702
<p>I have used something like the following to compose policies for my application:</p> <p>The policy classes look like this:</p> <pre><code>struct Policy { static void init(); static void cleanup(); //... }; template &lt;class CarT, class CdrT&gt; struct Cons { static void init() { CarT::init(); CdrT::init(); } static void cleanup() { CdrT::cleanup(); CarT::cleanup(); } //... }; </code></pre> <p>To compose policies:</p> <pre><code>typedef Cons&lt;Policy1, Cons&lt;Policy2, Cons&lt;Policy3, Policy4&gt; &gt; &gt; MyPolicy; </code></pre> <p>To use MyPolicy:</p> <pre><code>init_with&lt;MyPolicy&gt;(...); //... cleanup_with&lt;MyPolicy&gt;(...); </code></pre> <p>where they'd call:</p> <pre><code>MyPolicy::init_options(); // calls Policy1 to 4's init in order </code></pre> <p>and</p> <pre><code>MyPolicy::cleanup(); // calls Policy1 to 4's cleanup in reverse order </code></pre> <p>Essentially, Cons constructs a type list here. It's pretty straight forward. However the typedef cons line is kinda ugly. It'll be ideal to have policy combiner that can do this:</p> <pre><code>typedef CombinePolicy&lt;Policy1, Policy2, Policy3, Policy4&gt; MyPolicy; </code></pre> <p>Since we can have arbitrary number of policies, the CombinePolicy would need variadic template support in C++0x, which is only available experimentally in cutting edge compilers. However, it seems that boost:mpl library solved/worked around the problem by using a bunch preprocessing tricks. I <em>guess</em> I could use something like:</p> <pre><code>typedef mpl::list&lt;Policy, Policy2, Policy3, Policy4&gt; Policies; </code></pre> <p>and then calls:</p> <pre><code>init_with&lt;Policies&gt;(...); </code></pre> <p>which would then use:</p> <pre><code>typedef iter_fold&lt;Policies, begin&lt;Policies&gt;::type, some_magic_lambda_expression&gt;::type MyPolicy; </code></pre> <p>Obviously, I have a little trouble figuring out <em>some_magic_lambda_expression</em> here. I'm sure it's quite trivial for mpl experts here.</p> <p>Thanks in advance.</p>
[ { "answer_id": 256860, "author": "tabdamage", "author_id": 28022, "author_profile": "https://Stackoverflow.com/users/28022", "pm_score": 1, "selected": false, "text": "for_each<Policies>(InitPolicy());\n" }, { "answer_id": 257270, "author": "Dean Michael", "author_id": 11...
2008/11/02
[ "https://Stackoverflow.com/questions/256702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28888/" ]
256,719
<p>In most versions of windows, you can get to the menu by pressing the F10 key, thus avoiding having to use the mouse. This behaviour does not appear to be present in Windows Mobile 5.0, but is desirable as the device I am using will be more keyboard than touch screen driven. </p> <p>Is there a way of programmatically activating and using the menu on Windows Mobile 5.0, under C++ using either MFC or Windows API calls. I have tried setting the focus of the CFrameWnd and CCeCommandBar classes to no avail.</p>
[ { "answer_id": 256777, "author": "SmacL", "author_id": 22564, "author_profile": "https://Stackoverflow.com/users/22564", "pm_score": 2, "selected": true, "text": "void CMyFrame::OnFocusMenu()\n{\n PostMessage(WM_SYSCOMMAND,SC_KEYMENU,0);\n}\n" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22564/" ]
256,723
<p>We are using Subversion. We would like to </p> <pre><code>1. search across all commit messages ? 2. monitor the commits on certain important files ? 3. identify files that are never/rarely used ? 4. identify files that are most frequently changed ? 5. identify files that most developers have accessed ? 6. identify files that have been committed together many number of times ? </code></pre> <p>The usage of these data could be to weed out messages like <a href="https://stackoverflow.com/questions/216876/what-is-the-best-commit-message-you-have-ever-encountered#255762">these</a>, to refactor code and clean up the project of unused files. </p> <p>Please suggest tools to achieve the same.. </p> <p><b>EDIT:</b> We run SVN on Windows 2003.</p>
[ { "answer_id": 256727, "author": "Adam Liss", "author_id": 29157, "author_profile": "https://Stackoverflow.com/users/29157", "pm_score": 1, "selected": false, "text": "sed" }, { "answer_id": 257141, "author": "JesperE", "author_id": 13051, "author_profile": "https://S...
2008/11/02
[ "https://Stackoverflow.com/questions/256723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27474/" ]
256,724
<p>In C++, is it safe to extend scope via a reference?</p> <p>In code, what I mean is: </p> <pre><code>MyCLass&amp; function badIdea() { MyClass obj1; ... return obj1; } </code></pre>
[ { "answer_id": 256741, "author": "peterchen", "author_id": 31317, "author_profile": "https://Stackoverflow.com/users/31317", "pm_score": 1, "selected": false, "text": "int * p = NULL;\n{\n int y = 22;\n p = &y;\n}\n*p = 77; // BOOM!\n" }, { "answer_id": 256748, "author": "M...
2008/11/02
[ "https://Stackoverflow.com/questions/256724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
256,728
<pre><code>function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError, OnTimeOut); //working } function OnSuccessTicketPrices(result2) { alert(result2); //not working } </code></pre> <p>Why is the alert not working? On Debugging the function calling <code>AddTicketPricesSVC</code> is returning correct value.</p>
[ { "answer_id": 256747, "author": "naveen", "author_id": 17447, "author_profile": "https://Stackoverflow.com/users/17447", "pm_score": 0, "selected": false, "text": "function OnError(error)\n{\n alert(error.get_message());\n}\nfunction OnTimeOut()\n{\n alert('System Time Out');\n}\n...
2008/11/02
[ "https://Stackoverflow.com/questions/256728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17447/" ]
256,729
<p>I have a regular expression to match a persons name.</p> <p>So far I have ^([a-zA-Z\'\s]+)$ but id like to add a check to allow for a maximum of 4 spaces. How do I amend it to do this?</p> <p><strong>Edit:</strong> what i meant was 4 spaces anywhere in the string</p>
[ { "answer_id": 256735, "author": "Kent Fredric", "author_id": 15614, "author_profile": "https://Stackoverflow.com/users/15614", "pm_score": 4, "selected": true, "text": "1: Get Input \n2: Trim White Space\n3: If this makes sence, trim out any 'bad' characters. \n4: Use the \"split\" u...
2008/11/02
[ "https://Stackoverflow.com/questions/256729", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
256,754
<p>The situation is somewhat like-</p> <pre><code>var someVar = some_other_function(); someObj.addEventListener("click", function(){ some_function(someVar); }, false); </code></pre> <p>The problem is that the value of <code>someVar</code> is not visible inside the listener function of the <code>addEventListener</code>, where it is probably being treated as a new variable.</p>
[ { "answer_id": 256763, "author": "Sergey Ilinsky", "author_id": 23815, "author_profile": "https://Stackoverflow.com/users/23815", "pm_score": 9, "selected": true, "text": "some_function" }, { "answer_id": 256945, "author": "Thevs", "author_id": 8559, "author_profile":...
2008/11/02
[ "https://Stackoverflow.com/questions/256754", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30252/" ]
256,803
<p>A few days ago, I asked <a href="https://stackoverflow.com/questions/242577/c-what-is-string-really-good-for">why its not possible to store binary data, such as a jpg file into a string variable</a>.</p> <p>Most of the answers I got said that string is used for textual information such as what I'm writing now.</p> <p>What is considered textual data though? Bytes of a certain nature represent a jpg file and those bytes could be represented by character byte values...I think. So when we say strings are for textual information, is there some sort of range or list of characters that aren't stored?</p> <p>Sorry if the question sounds silly. Just trying to 'get it'</p>
[ { "answer_id": 256824, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 1, "selected": false, "text": "byte[] myJpegByteArray = GetBytesFromSomeImage();\n\nstring myString = Encoding.ASCII.GetString(myJpegByteArray);\n...
2008/11/02
[ "https://Stackoverflow.com/questions/256803", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17211/" ]
256,804
<p>Is there a way to execute SQL custom functions with Enterpise Library? I've tried Database.ExecuteScalar() but for some reason it returns null.</p> <p>This is my function:</p> <pre><code>Database db = DatabaseFactory.CreateDatabase("ConnectionString"); DbCommand cmd = db.GetStoredProcCommand("FunctionName"); db.AddInParameter(cmd, "Value1", DbType.String, Param1Value); db.AddInParameter(cmd, "Value2", DbType.String, Param2Value); return Convert.ToBoolean(db.ExecuteScalar(cmd)); </code></pre> <p>Here the db.ExecuteScalar(cmd) method returns null. This does not happen with Stored Procedures.</p> <p>By the way, im using version 4.0</p> <p>Thanks.</p>
[ { "answer_id": 256898, "author": "oglester", "author_id": 2017, "author_profile": "https://Stackoverflow.com/users/2017", "pm_score": 2, "selected": false, "text": "SELECT FuncName(@Param1)\n" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14533/" ]
256,806
<p>A common pattern in C++ is to create a class that wraps a lock - the lock is either implicitly taken when object is created, or taken explicitly afterwards. When object goes out of scope, dtor automatically releases the lock. Is it possible to do this in C#? As far as I understand there are no guarantees on when dtor in C# will run after object goes out of scope.</p> <p>Clarification: Any lock in general, spinlock, ReaderWriterLock, whatever. Calling Dispose myself defeats the purpose of the pattern - to have the lock released as soon as we exit scope - no matter if we called return in the middle, threw exception or whatnot. Also, as far as I understand using will still only queue object for GC, not destroy it immediately...</p>
[ { "answer_id": 256818, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": 2, "selected": false, "text": "lock (_myLockKey) { ... }\n" }, { "answer_id": 256842, "author": "denis phillips", "author_id": 748...
2008/11/02
[ "https://Stackoverflow.com/questions/256806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33426/" ]
256,807
<p>Is there any way to check if a given index of an array exists? I am trying to set numerical index but something like 1, 5, 6,10. And so I want to see if these indexes already exist and if they do just increase another counter.</p> <p>I normally work with php but I am trying to do this in c++, so basically I am trying to ask if there is an isset() way to use with c++</p> <p>PS: Would this be easier with vectors? If so, can anyone point me to a good vector tutorial? Thanks</p>
[ { "answer_id": 256825, "author": "user23167", "author_id": 23167, "author_profile": "https://Stackoverflow.com/users/23167", "pm_score": 4, "selected": true, "text": "int i[10];\ni[10] = 2; // Legal but very dangerous! Writing on memory you don't know about\n" }, { "answer_id": 3...
2008/11/02
[ "https://Stackoverflow.com/questions/256807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8715/" ]
256,811
<p>How do you create non scrolling div that looks like the MS Office 2007 ribbon on a web page without two sets of scroll bars. One for the window and one for the div.</p>
[ { "answer_id": 256830, "author": "belugabob", "author_id": 13397, "author_profile": "https://Stackoverflow.com/users/13397", "pm_score": 3, "selected": false, "text": "<div>" }, { "answer_id": 256870, "author": "Nikola Stjelja", "author_id": 32582, "author_profile": "...
2008/11/02
[ "https://Stackoverflow.com/questions/256811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
256,822
<p>In RoR,how to validate a Chinese or a Japanese word for a posting form with utf8 code.</p> <p>In GBK code, it uses [\u4e00-\u9fa5]+ to validate Chinese words. In Php, it uses /^[\x{4e00}-\x{9fa5}]+$/u for utf-8 pages.</p>
[ { "answer_id": 256855, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 3, "selected": false, "text": ">> \"acentuação\".scan(/\\xC3\\xA7/)\n=> [\"ç\"] \n" }, { "answer_id": 1971006, "author": "Jose Barre...
2008/11/02
[ "https://Stackoverflow.com/questions/256822", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20191/" ]
256,823
<p>The scenario is trying to adjust font size to get a nice graphic arrangement, or trying to decide where to break a caption/subtitle. a) In XL VBA is there a way to find out whether a text on a textbox, or caption on a label, still fits the control? b) Is there a way to know where was the text/caption broken on multiline control?</p>
[ { "answer_id": 257458, "author": "jpinto3912", "author_id": 11567, "author_profile": "https://Stackoverflow.com/users/11567", "pm_score": 3, "selected": true, "text": "Function TextWidth(aText As String, Optional aFont As NewFont) As Single\n Dim theFont As New NewFont\n Dim notSee...
2008/11/02
[ "https://Stackoverflow.com/questions/256823", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11567/" ]
256,832
<p>I'm used to work with Java where large amounts of examples are available. For various reasons I had to switch to C# and trying to do the following in SharpDevelop:</p> <pre><code>// Form has a menu containing a combobox added via SharpDevelop's GUI // --- Variables languages = new string[2]; languages[0] = "English"; languages[1] = "German"; DataSet myDataSet = new DataSet(); // --- Preparation DataTable lTable = new DataTable("Lang"); DataColumn lName = new DataColumn("Language", typeof(string)); lTable.Columns.Add( lName ); for( int i=0; i&lt;languages.Length; i++ ) { DataRow lLang = lTable.NewRow(); lLang["Language"] = languages[i]; lTable.Rows.Add(lLang); } myDataSet.Tables.Add(lTable); // --- Handling the combobox mnuActionLanguage.ComboBox.DataSource = myDataSet.Tables["Lang"].DefaultView; mnuActionLanguage.ComboBox.DisplayMember = "Language"; </code></pre> <p>One would assume to see some values in the dropdown, but it's empty. Please tell me what I'm doing wrong ;(</p> <p><em>EDIT: mnuActionLanguage.ComboBox.DataBind() is what I also found on the net, but it doesn't work in my case.</em></p> <p><strong>SOLUTION</strong></p> <pre><code>mnuActionLanguage.ComboBox.BindingContext = this.BindingContext; </code></pre> <p>at the end solved the problem!</p>
[ { "answer_id": 256840, "author": "Alan", "author_id": 31223, "author_profile": "https://Stackoverflow.com/users/31223", "pm_score": 0, "selected": false, "text": "mnuActionLanguage.ComboBox.DisplayMember = \"Lang.Language\";\n" }, { "answer_id": 256854, "author": "Timothy Kho...
2008/11/02
[ "https://Stackoverflow.com/questions/256832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33429/" ]
256,859
<p>What, if any, is the performance difference between the following two loops?</p> <pre><code>for (Object o: objectArrayList) { o.DoSomething(); } </code></pre> <p>and </p> <pre><code>for (int i=0; i&lt;objectArrayList.size(); i++) { objectArrayList.get(i).DoSomething(); } </code></pre>
[ { "answer_id": 256861, "author": "Vijay Dev", "author_id": 27474, "author_profile": "https://Stackoverflow.com/users/27474", "pm_score": 9, "selected": true, "text": "// The preferred idiom for iterating over collections and arrays\nfor (Element e : elements) {\n doSomething(e);\n}\n"...
2008/11/02
[ "https://Stackoverflow.com/questions/256859", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26567/" ]
256,892
<p>How do i backup a SQL database using PHP.</p> <p>Is there a vendor agnostic way to do this that conforms to ANSI SQL?</p> <p>If not maybe you can list how to do it for each of the database vendors?</p>
[ { "answer_id": 256907, "author": "vog", "author_id": 19163, "author_profile": "https://Stackoverflow.com/users/19163", "pm_score": 4, "selected": true, "text": "pg_dump" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13227/" ]
256,897
<p>I'm using <a href="http://www.codeplex.com/bizunit" rel="noreferrer" title="BizUnit">BizUnit</a> to unit-tests my Biztalk orchestrations, but some orchestrations consume a WebService,and testing these seems more like integration testing than unit testing.</p> <p>I'm familiar with using a mocking framework to mock the generated proxy objects, in order to test a web service from a Windows Forms application, but I would like to be able to do it in a more integrated way in a request-response port?</p> <p>How would you approach this problem?</p>
[ { "answer_id": 271044, "author": "David Hall", "author_id": 2660, "author_profile": "https://Stackoverflow.com/users/2660", "pm_score": 4, "selected": true, "text": "new Guid(\"\")," } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18865/" ]
256,915
<p>I'm building small web shop with asp.net mvc and Structuremap ioc/di. My Basket class uses session object for persistence, and I want use SM to create my basket object through IBasket interface. My basket implementation need HttpSessionStateBase (session state wrapper from mvc) in constructor, which is available inside Controller/Action. How do I register my IBasket implementation for SM?<br> This is my basket interface:</p> <pre><code>public interface IBasketService { BasketContent GetBasket(); void AddItem(Product productItem); void RemoveItem(Guid guid); } </code></pre> <p>And SM registration: </p> <pre><code>ForRequestedType(typeof (IBasketService)).TheDefaultIsConcreteType(typeof (StoreBasketService)); </code></pre> <p>But my StoreBasketService implementation has constructor: </p> <pre><code>public StoreBasketService(HttpSessionStateBase sessionState) </code></pre> <p>How do I provide HttpSessionStateBase object to SM, which is available only in controller?<br> This is my first use of SM IOC/DI, and cann't find solution/example in official documentation and web site ;)</p>
[ { "answer_id": 257496, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "public interface IHttpSessionStateWrapper\n{\n HttpSessionState GetSessionState();\n}\n\npublic class HttpSessionStat...
2008/11/02
[ "https://Stackoverflow.com/questions/256915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1407/" ]
256,919
<p>I am looking for suggestions on how to find the sizes (in bits) and range of floating point numbers in an architecture independent manner. The code could be built on various platforms (AIX, Linux, HPUX, VMS, maybe Windoze) using different flags - so results should vary. The sign, I've only seen as one bit, but how to measure the size of the exponent and mantissa?</p>
[ { "answer_id": 256926, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 2, "selected": false, "text": "float.h" }, { "answer_id": 256928, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "h...
2008/11/02
[ "https://Stackoverflow.com/questions/256919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
256,932
<p>Is there a way of getting the websites absolute URL (<a href="http://www.domain.com/" rel="nofollow noreferrer">http://www.domain.com/</a>) using Java? because I've googled a bit but I only come across with having to make 2 or 3 classes to create that function =/</p> <h3>Update:</h3> <p>The thing is I am trying to create a crawler that will give me some information and among that I'd like to get the URL of the webpage it's getting the information from. I'm developing this in JAVA and what I meant to say was that I was wondering if there was some getUrl(); or any method like that to get me the Url, because I know it can be done but I've only done it writing a whole other class to retrieve the url and then inherit it and use it further...hope it made it clearer</p>
[ { "answer_id": 256995, "author": "Paul Croarkin", "author_id": 18995, "author_profile": "https://Stackoverflow.com/users/18995", "pm_score": 1, "selected": false, "text": "String realPath = getServletConfig().getServletContext().getRealPath(relativePath);\n" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/256932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28586/" ]
256,938
<p>I am writing a footer div that displays info from the database. The footer has a different background color than the rest of the page, and will have a height that depends on how much content the database throws to it. When I generate the content with php and call for a border around the footer div, the content appears and is, let's say, 400px high, but the div border appears as a 1px high rectangle at the top of the div.</p> <p>How do I get the height to auto-fit the content?</p> <pre><code>&lt;div id="footer"&gt; &lt;?php $an_array=array(); $tasks=mysql_query("select stuff from the db"); while($row=mysql_fetch_assoc($tasks)){ extract($taskrow); $an_array[]=$task; } $an_array=array_chunk($an_array,4); foreach($an_array as $dtkey=&gt;$dtval){ echo "&lt;dl&gt;"; foreach($dtval as $dtvkey=&gt;$dtvval){ echo "&lt;dt&gt;".$dtvval."&lt;/dt&gt;"; } echo "&lt;/dl&gt;"; } ?&gt; &lt;/div&gt; </code></pre> <p>This is what I get. The area below the red border should be filled with a color. <a href="http://www.kevtrout.com/tortus/div.png" rel="nofollow noreferrer">border image http://www.kevtrout.com/tortus/div.png</a></p> <p>By popular demand, here is the css:</p> <pre><code>#footer{ border-top: 10px solid #d8d8d8; background:#5b5b5b; /*overflow:auto;*///Added this after seeing your answers, it worked } dl.tr{ width: 255px; height:160px; background: #5b5b5b; margin:0px; float:left; padding: 10px; } dt.tr{ font-weight: normal; font-size: 14px; color: #d8d8d8; line-height: 28px; } </code></pre> <p>edit: I am using firefox on a mac</p>
[ { "answer_id": 256948, "author": "stevemegson", "author_id": 25028, "author_profile": "https://Stackoverflow.com/users/25028", "pm_score": 2, "selected": false, "text": "<dl>" }, { "answer_id": 256965, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "...
2008/11/02
[ "https://Stackoverflow.com/questions/256938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1149/" ]
256,953
<p>It seems that HTML 5 is going to be supported (partially) by Firefox 3.1 and other browsers. It is adding support for video and audio as tags, but these are new tags that XHTML 1.0 Transitional does not recognize. What is the behavior supposed to be if I use a new HTML 5 tag in a future version of Firefox but use the DTD for XHTML? And what if I mix HTML 5 markup with XHTML 1.0 Trans?</p> <p>This is getting confusing. Why didn't they just add these tags to XHTML? How do we support both XHTML and HTML 5?</p> <p>Video on HTML 5: <a href="http://www.youtube.com/watch?v=xIxDJof7xxQ" rel="noreferrer">http://www.youtube.com/watch?v=xIxDJof7xxQ</a></p>
[ { "answer_id": 256998, "author": "hangy", "author_id": 11963, "author_profile": "https://Stackoverflow.com/users/11963", "pm_score": 4, "selected": true, "text": "<video>" }, { "answer_id": 257053, "author": "Ms2ger", "author_id": 33466, "author_profile": "https://Sta...
2008/11/02
[ "https://Stackoverflow.com/questions/256953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10366/" ]
256,978
<p>Is there a way to persist an enum to the DB using NHibernate? That is have a table of both the code and the name of each value in the enum.</p> <p>I want to keep the enum without an entity, but still have a foreign key (the int representation of the enum) from all other referencing entities to the enum's table.</p>
[ { "answer_id": 257073, "author": "Paco", "author_id": 13376, "author_profile": "https://Stackoverflow.com/users/13376", "pm_score": 3, "selected": false, "text": "private int myField;\npublic virtual MyEnum MyProperty\n{\n get { return (MyEnum)myField; }\n set { myField = value; }\n}...
2008/11/02
[ "https://Stackoverflow.com/questions/256978", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19956/" ]
256,997
<p>I have a PHP web application which uses a MySQL database for object tagging, in which I've used the tag structure accepted as the answer to <a href="https://stackoverflow.com/questions/20856/how-do-you-recommend-implementing-tags-or-tagging">this SO question</a>.</p> <p>I'd like to implement a tag hierarchy, where each tag can have a unique parent tag. Searches for a parent tag T would then match all descendants of T (i.e. T, tags whos parent is T (children of T), grandchildren of T, etc.).</p> <p>The easiest way of doing this seems to be to add a ParentID field to the tag table, which contains the ID of a tag's parent tag, or some magic number if the tag has no parent. Searching for descendants, however, then requires repeated full searches of the database to find the tags in each 'generation', which I'd like to avoid.</p> <p>A (presumably) faster, but less normalised way of doing this would be to have a table containing all the children of each tag, or even all the descendants of each tag. This however runs the risk of inconsistent data in the database (e.g. a tag being the child of more than one parent).</p> <p>Is there a good way to make queries to find descendants fast, while keeping the data as normalised as possible?</p>
[ { "answer_id": 257020, "author": "splattne", "author_id": 6461, "author_profile": "https://Stackoverflow.com/users/6461", "pm_score": 3, "selected": false, "text": "tag path\n--- ----\ndatabase database/\nmysql database/mysql/\nmysql4 database...
2008/11/02
[ "https://Stackoverflow.com/questions/256997", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23732/" ]
257,005
<p>I want to do this using the <code>Math.Round</code> function</p>
[ { "answer_id": 257011, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 7, "selected": false, "text": "twoDec = Math.Round(val, 2)\n" }, { "answer_id": 257017, "author": "Eoin Campbell", "author_id": 30155, ...
2008/11/02
[ "https://Stackoverflow.com/questions/257005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
257,030
<p>Writing something like this using the <a href="http://loki-lib.sourceforge.net/" rel="nofollow noreferrer">loki library</a>,</p> <pre><code>typedef Functor&lt;void&gt; BitButtonPushHandler; </code></pre> <p>throws a compiler error, but this works</p> <pre><code>typedef Functor&lt;void,TYPELIST_1(Matrix3D*)&gt; Perspective; </code></pre> <blockquote> <p>Functor.h:530: error: '((Loki::FunctorHandler, int>*)this)->Loki::FunctorHandler, int>::f_' cannot be used as a function Functor.h:530: error: return-statement with a value, in function returning 'void'</p> </blockquote> <p>Anyone familiar with this library know how to get the first line working?</p>
[ { "answer_id": 257064, "author": "user23167", "author_id": 23167, "author_profile": "https://Stackoverflow.com/users/23167", "pm_score": 3, "selected": true, "text": "template <typename R = void, class TList = NullType,\n template<class, class> class ThreadingModel = LOKI_DEFAULT_...
2008/11/02
[ "https://Stackoverflow.com/questions/257030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/209/" ]
257,047
<p>Where would i go to look for algorithms that take a 2d grid of values that are either 0 or 1 as input and then identifies all possible non-overlapping rectangles in it?</p> <p>In a more practical explanation: I am drawing a grid that is represented by a number of squares, and i wish to find a way to combine as many adjacent squares into rectangles as possible, in order to cut down on the time spent on cycling through each square and drawing it.</p> <p>Maximum efficiency is not needed, speed is more important.</p> <p>Addendum: Apparently what i am looking for seems to be a technique called Tesselation. Now i only need to find a good description for this specific case.</p> <p>Addendum 2: The boundary of the "1" squares will be irregular and in some cases not even connected, as the distribution of "1" squares will be completely random. I need these irregular shapes to be identified and split up into regular rectangles.</p> <p><strong>Correct answer:</strong> To get the best balance between speed and efficiency it is optimal to use the grid data to fill a quad-tree with each node having a status value of either empty/partly filled/filled.</p>
[ { "answer_id": 257075, "author": "Peter Olsson", "author_id": 2703, "author_profile": "https://Stackoverflow.com/users/2703", "pm_score": 1, "selected": false, "text": "0 0 1 1 1 0 0 0 1 1 1 1 0\n" }, { "answer_id": 257103, "author": "Daniel Rikowski", "author_id": 23368,...
2008/11/02
[ "https://Stackoverflow.com/questions/257047", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145119/" ]
257,050
<p>Say you have a string, but you don't know what it contains. And you want to replace all occurences of a particular word or part of a word with a formatted version of the same word. For example, I have a string that contains "lorem ipsum" and i want to replace the entire word that contains "lo" with "lorem can" so that the end result would be "lorem can ipsum" but if I put the string "loreal ipsum" through the same function, the result would now be "loreal can ipsum". Thanks</p>
[ { "answer_id": 257054, "author": "Greg", "author_id": 24181, "author_profile": "https://Stackoverflow.com/users/24181", "pm_score": 1, "selected": true, "text": "$str = preg_replace('/lo(\\w*)/', 'lo$1 can', $str);" }, { "answer_id": 257063, "author": "eyelidlessness", "a...
2008/11/02
[ "https://Stackoverflow.com/questions/257050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24391/" ]
257,065
<p>The reason I am asking this is that I had accidentally done a <code>git commit -a</code> that included a file I did not yet want to commit. My solution was to do the following:</p> <pre><code>git reset --soft HEAD^ git reset -- file/with/changes_not_to_committed git commit -C HEAD@{1} </code></pre> <p>Here, I’ve rewound the branch by one commit while keeping the index and working tree, then pulled <code>file/with/changes_not_to_committed</code> from a yet older revision into the index, and then I committed the index using the commit message from the previous branch head commit. Neither <code>git-reset</code> invocation touches the working copy, so my modifications to <code>file/with/changes_not_to_committed</code> persist, but are no longer recorded in the <code>HEAD</code> revision.</p> <p>However, it would have been easier if I could pull <code>file/with/changes_not_to_committed</code> from the <code>HEAD^</code> revision right into the index <em>without touching the working copy</em>. Since the index otherwise already represents the state I want, I could then just amend the <code>HEAD</code> commit, producing a sequence like this:</p> <pre><code>git magic-pony HEAD^ file/with/changes_not_to_committed git commit --amend -C HEAD </code></pre> <p>This is <em>almost</em> what I would get by replacing <code>git-magic-pony</code> with <code>git-checkout</code>, except for the requirement that the working copy be left untouched and only the index updated. It seems there is no way to make <code>git-checkout</code> not touch both.</p> <p>My question is: does <code>git-magic-pony</code> exist, and if so, under what name?</p>
[ { "answer_id": 257105, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "git update-index" }, { "answer_id": 257196, "author": "Aristotle Pagaltzis", "author_id": 9410, "auth...
2008/11/02
[ "https://Stackoverflow.com/questions/257065", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9410/" ]
257,078
<p>I understand that using the "===" compares type, so running the following code results in "not equal" because it's comparing a number type to a string type.</p> <pre><code>var a = 20; var b = "20"; if (a === b) { alert("They are equal"); } else { alert("They are not equal"); } </code></pre> <p>But I dont understand how using the "==" to compare only the value results in the "They are equal" message.</p> <pre><code>var a = 20; var b = "20"; if (a == b) { alert("They are equal"); } else { alert("They are not equal"); } </code></pre> <p>How are the values equal? Isn't the string "20" stored as the ASCII characters 50 and 48 (0110010 and 0110000 in binary) and 20 stored as the actual binary number 0010100?</p> <p>EDIT: Thanks everyone! I think all the responses are great and have helped me understand this much better.</p>
[ { "answer_id": 257083, "author": "andy.gurin", "author_id": 22388, "author_profile": "https://Stackoverflow.com/users/22388", "pm_score": 5, "selected": true, "text": "==" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
257,085
<p>I have a JavaScript snippet that runs very well on Firefox and Safari, but refuses to run on IE:</p> <pre><code>var drop= function(id) { if(document.getElementById("select1").value == "Ficha de pediatria"){ top.location.href = "print.jsp?id="+id+"&amp;type=2"; } else if(document.getElementById("select1").value == "Ficha normal"){ top.location.href = "print.jsp?id="+id+"&amp;type=1"; } } &lt;select id="select1" name="select1" onChange="drop(id);return false;"&gt; &lt;option&gt;Imprimir:&lt;/option&gt; &lt;option&gt;Ficha de pediatria&lt;/option&gt; &lt;option&gt;Ficha normal&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I trimed this as it had more JSP code but it' remained the same. Anyone got any idea why it's not running on IE?</p>
[ { "answer_id": 257095, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 4, "selected": true, "text": "id" }, { "answer_id": 257097, "author": "mbillard", "author_id": 810, "author_profile": "https://Sta...
2008/11/02
[ "https://Stackoverflow.com/questions/257085", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26004/" ]
257,091
<p>How do I clear the cin buffer in C++?</p>
[ { "answer_id": 257092, "author": "Gunnar Steinn", "author_id": 33468, "author_profile": "https://Stackoverflow.com/users/33468", "pm_score": 1, "selected": false, "text": "cin.flush();\n" }, { "answer_id": 257098, "author": "Evan Teran", "author_id": 13430, "author_pr...
2008/11/02
[ "https://Stackoverflow.com/questions/257091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
257,093
<p>Given the following table, how does one calculate the hourly mode, or value with the highest frequency by hour?</p> <pre><code>CREATE TABLE Values ( ValueID int NOT NULL, Value int NOT NULL, LogTime datetime NOT NULL ) </code></pre> <p>So far, I've come up with the following query.</p> <pre><code>SELECT count(*) AS Frequency, DatePart(yy, LogTime) as [Year], DatePart(mm, LogTime) as [Month], DatePart(dd, LogTime) as [Day], DatePart(hh, LogTime) as [Hour] FROM Values GROUP BY Value, DatePart(yy, LogTime), DatePart(mm, LogTime), DatePart(dd, LogTime), DatePart(hh, LogTime) </code></pre> <p>However, this yields the frequency of each distinct value by hour. How do I add a constraint to only return the value with the maximum frequency by hour?</p> <p>Thanks</p>
[ { "answer_id": 257181, "author": "gbn", "author_id": 27535, "author_profile": "https://Stackoverflow.com/users/27535", "pm_score": 1, "selected": false, "text": "SELECT\n MAX(Frequency) AS [Mode],\n [Year],[Month],[Day],[Hour]\nFROM\n (SELECT\n COUNT(*) AS Frequency, \n ...
2008/11/02
[ "https://Stackoverflow.com/questions/257093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
257,102
<p>In other words, can <code>fn()</code> know that it is being used as <code>$var = fn();</code> rather than as <code>fn();</code>?</p> <p>A use case would be to <code>echo</code> the return value in the latter case but to <code>return</code> it in the former.</p> <p>Can this be done without passing a parameter to the function to declare which way it is being used?</p>
[ { "answer_id": 257122, "author": "Stephen Walcher", "author_id": 25375, "author_profile": "https://Stackoverflow.com/users/25375", "pm_score": 0, "selected": false, "text": "if (namespace) {\n return $output;\n} else {\n echo $output;\n}\n" }, { "answer_id": 257184, "au...
2008/11/02
[ "https://Stackoverflow.com/questions/257102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17964/" ]
257,152
<p>If I have two things which are hex, can I someone how append their binary together to get a value?</p> <p>In C++, say I have</p> <pre><code>unsigned char t = 0xc2; // 11000010 unsigned char q = 0xa3; // 10100011 </code></pre> <p>What I want is somehow, <code>1100001010100011</code>, is this possible using bit-wise operators?</p> <p>I want to extract the binary form of t and q and append them...</p>
[ { "answer_id": 257199, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 4, "selected": false, "text": "unsigned char t = 0xc2; // 11000010 \nunsigned char q = 0xa3; // 10100011\nunsigned short s = (((unsigned short)t)<<8...
2008/11/02
[ "https://Stackoverflow.com/questions/257152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
257,157
<p>I am attempting to build a simple method that creates an XML file from a database in ruby on rails. I feel like my code is right but I am not seeing all of the users in the XML.<br> I am a complete newbie to RoR.</p> <p>Here's my code:</p> <pre><code>def create_file @users = User.find(:all) file = File.new('dir.xml','w') doc = Document.new make = Element.new "make" @users.each do |y| make.add_element "name" make.elements["name"].text = y.name make.add_element "description" make.elements["description"].text = y.description end doc.add_element make file.puts doc file.close end </code></pre> <p>And my XML output:</p> <pre><code>&lt;make&gt; &lt;name&gt;sammy&lt;/name&gt;&lt;description&gt;samsdescription&lt;/description&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;name/&gt;&lt;description/&gt; &lt;/make&gt; </code></pre> <p>I don't get why all the fields aren't populated. Why is just one of the database entires showing up? I really appreciate the help.</p>
[ { "answer_id": 257180, "author": "Rômulo Ceccon", "author_id": 23193, "author_profile": "https://Stackoverflow.com/users/23193", "pm_score": 3, "selected": true, "text": "add_element" }, { "answer_id": 257781, "author": "Grant Hutchins", "author_id": 6304, "author_pro...
2008/11/02
[ "https://Stackoverflow.com/questions/257157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33344/" ]
257,188
<p>I'm looking for a free (GPL or BSD-type license) outliner library that works in a browser. </p> <p>It doesn't have to be too complicated, just allow keyboard control of collapsing and expanding items, and changing their order.</p> <p>Anyone know a good library for this? Do any of the big UI component libraries have an outliner? If not, how would I go about writing it from scratch? (Eg. would it be better to start with jQuery? Or something else?)</p>
[ { "answer_id": 6179661, "author": "Marcel", "author_id": 154877, "author_profile": "https://Stackoverflow.com/users/154877", "pm_score": 3, "selected": false, "text": "<li>" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8482/" ]
257,189
<p>I've heard a lot of people touting success using Linux based proxies to handle routing for high availability of web applications, but what are others doing with web services? I have a bank of WCF services that need to be moved to a high availability (failover) model, meaning that if a particular server hosting the WCF services goes down, the request is routed to another of the servers in the bank. I would rather stay away from implementing a Linux based solution, since there are no Linux knowledgeable people in the environment. </p>
[ { "answer_id": 6179661, "author": "Marcel", "author_id": 154877, "author_profile": "https://Stackoverflow.com/users/154877", "pm_score": 3, "selected": false, "text": "<li>" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257189", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5469/" ]
257,190
<p>Here is a simple scenario with table characters:</p> <pre><code>CharacterName GameTime Gold Live Foo 10 100 3 Foo 20 100 2 Foo 30 95 2 </code></pre> <p>How do I get this output for the query <code>SELECT Gold, Live FROM characters WHERE name = 'Foo' ORDER BY GameTime</code>:</p> <pre><code>Gold Live 100 3 0 -1 -5 0 </code></pre> <p>using MySQL stored procedure (or query) if it's even possible? I thought of using 2 arrays like how one would normally do in a server-side language, but MySQL doesn't have array types.</p> <p>While I'm aware it's probably easier to do in PHP (my server-side langauge), I want to know if it's possible to do in MySQL, just as a learning material.</p>
[ { "answer_id": 257213, "author": "Eoin Campbell", "author_id": 30155, "author_profile": "https://Stackoverflow.com/users/30155", "pm_score": 2, "selected": false, "text": "GameID CharacterName GameTime Gold Live\n----------- ------------- ----------- ----------- ----------...
2008/11/02
[ "https://Stackoverflow.com/questions/257190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15345/" ]
257,220
<h2>solution structure [Plain Winforms + VS 2008 Express Edition]</h2> <ul> <li>CoffeeMakerInterface (NS CoffeeMaker)</li> <li>CoffeeMakerSoftware (NS CoffeeMakerSoftware)</li> <li>TestCoffeeMaker (NS TestCoffeeMaker)</li> </ul> <p>CoffeeMakerSoftware proj references CoffeeMakerInterface. TestCoffeeMaker proj references CoffeeMakerInterface and CoffeeMakerSoftware.</p> <p>Now the thing that is driving me nuts. I can't get this to build. <strong>If I remove CoffeeMakerSoftware project reference from TestCoffeeMaker it builds (??!!).. as soon as I add the second project reference, it throws build errors</strong> claiming that types declared in first reference 'can't be found.. are you missing an assembly ref'</p> <p>At first I had the first 2 assemblies having the same namespace CoffeeMaker.. I then made them distinct (although I think having classes belonging to the same NS across assemblies should be possible) but even that doesn't seem to be it.</p> <p>Calling more eyeballs. Any pointers.. </p>
[ { "answer_id": 258076, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 1, "selected": false, "text": "1. CoffeeMaker > CoffeeMakerInterfaces\n2. [X] > CoffeeMaker > CoffeeMakerSoftware\n3. [X] > TestCo...
2008/11/02
[ "https://Stackoverflow.com/questions/257220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1695/" ]
257,229
<p>I am writing a quick application myself - first project, however I am trying to find the VBA code for writing the result of an input string to a named cell in Excel.</p> <p>For example, a input box asks the question "Which job number would you like to add to the list?"... the user would then enter a reference number such as "FX1234356". The macro then needs to write that information into a cell, which I can then use to finish the macro (basically a search in some data).</p>
[ { "answer_id": 257247, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 5, "selected": true, "text": "Range(\"C1\").Value = Inputbox(\"Which job number would you like to add to the list?)\n" }, { "answer_id": 25...
2008/11/02
[ "https://Stackoverflow.com/questions/257229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
257,250
<p>I'm relatively new to jQuery, but so far what I've seen I like. What I want is for a div (or any element) to be across the top of the page as if "position: fixed" worked in every browser.</p> <p>I do not want something complicated. I do not want giant CSS hacks. I would prefer if just using jQuery (version 1.2.6) is good enough, but if I need jQuery-UI-core, then that's fine too.</p> <p>I've tried $("#topBar").scrollFollow(); &lt;-- but that goes slow... I want something to appear really fixed.</p>
[ { "answer_id": 257972, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 7, "selected": true, "text": "<div id=\"myElement\" style=\"position: absolute\">This stays at the top</div>\n" }, { "answer_id": 258331, "author...
2008/11/02
[ "https://Stackoverflow.com/questions/257250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11917/" ]
257,251
<p>I swear I've seen someone do this, but I can't find it in the various lists of shortcuts.</p> <p>Given:</p> <pre><code>String s = "A very long ............................ String"; </code></pre> <p>Is there an Eclipse shortcut to turn it into:</p> <pre><code>String s = "A very long ............................ " + "String"; </code></pre>
[ { "answer_id": 257652, "author": "John Stoneham", "author_id": 2040146, "author_profile": "https://Stackoverflow.com/users/2040146", "pm_score": 0, "selected": false, "text": "StringBuilder" }, { "answer_id": 26861386, "author": "Tomáš Záluský", "author_id": 653539, "...
2008/11/02
[ "https://Stackoverflow.com/questions/257251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18995/" ]
257,255
<p>I'm looking for a really generic way to "fill out" a form based on a parameter string using javascript.</p> <p>for example, if i have this form:</p> <pre><code>&lt;form id="someform"&gt; &lt;select name="option1"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;/select&gt; &lt;select name="option2"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>I'd like to be able to take a param string like this: <code>option1=2&amp;option2=1</code></p> <p>And then have the correct things selected based on the options in the query string.</p> <p>I have a sort of ugly solution where I go through children of the form and check if they match the various keys, then set the values, but I really don't like it.</p> <p>I'd like a cleaner, <strong>generic</strong> way of doing it that would work for any form (assuming the param string had all the right keys).</p> <p>I'm using the prototype javascript library, so I'd welcome suggestions that take advantage of it.</p> <p>EDIT: this is what I've come up with so far (using prototype for <code>Form.getElements(form)</code>)</p> <pre><code>function setFormOptions(formId, params) { params = params.split('&amp;'); params.each(function(pair) { pair = pair.split('='); var key = pair[0]; var val = pair[1]; Form.getElements(form).each(function(element) { if(element.name == key) { element.value = val; } }); }); } </code></pre> <p>I feel that it could still be faster/cleaner however.</p>
[ { "answer_id": 257287, "author": "Shadow2531", "author_id": 1697, "author_profile": "https://Stackoverflow.com/users/1697", "pm_score": 1, "selected": false, "text": "function setFormSelectValues(form, dataset) {\n var sel = form.getElementsByTagName(\"select\");\n dataset.replace(...
2008/11/02
[ "https://Stackoverflow.com/questions/257255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12983/" ]
257,259
<pre><code>void addNewNode (struct node *head, int n) { struct node* temp = (struct node*) malloc(sizeof(struct node)); temp -&gt; data = n; temp -&gt; link = head; head = temp; } </code></pre> <p>The code give above is the popularly wrong version of a function for adding a new node at the head of a linked list. Generally the correct versions are like,</p> <pre><code>void addNewNode (struct node **head, int n); void addNewNode (struct node * &amp;head, int n); </code></pre> <p>I worked out another but simple function for the purpose which worked fine.</p> <pre><code>struct node* addNewNode (struct node *head, int n) { struct node* temp = (struct node*) malloc(sizeof(struct node)); temp -&gt; data = n; temp -&gt; link = head; return temp; } </code></pre> <p>But I haven't seen this being used or discussed in code and tutorials and thus I am curious to know if this approach has some flaw.</p>
[ { "answer_id": 257267, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 2, "selected": false, "text": "addNode" }, { "answer_id": 257268, "author": "Daniel Spiewak", "author_id": 9815, "author_profile": "htt...
2008/11/02
[ "https://Stackoverflow.com/questions/257259", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6561/" ]
257,286
<p>in C++ I have two chars holding hex values e.g.:</p> <pre><code>char t = 0x4; char q = 0x4; </code></pre> <p>How would i compare if the two values held in the char are the same?? I tried</p> <pre><code>if (t == q) // should give me true </code></pre> <p>but no, any help, thanks!</p>
[ { "answer_id": 257291, "author": "BobS", "author_id": 33481, "author_profile": "https://Stackoverflow.com/users/33481", "pm_score": -1, "selected": false, "text": "if (t & q)\n" }, { "answer_id": 257304, "author": "Brian R. Bondy", "author_id": 3153, "author_profile":...
2008/11/02
[ "https://Stackoverflow.com/questions/257286", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
257,288
<p>Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?</p> <p>Here's a simple example of what I would want to write:</p> <pre><code>template&lt;class T&gt; std::string optionalToString(T* obj) { if (FUNCTION_EXISTS(T-&gt;toString)) return obj-&gt;toString(); else return "toString not defined"; } </code></pre> <p>So, if <code>class T</code> has <code>toString()</code> defined, then it uses it; otherwise, it doesn't. The magical part that I don't know how to do is the "FUNCTION_EXISTS" part.</p>
[ { "answer_id": 257315, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 5, "selected": false, "text": "template <typename T>\nstruct response_trait {\n static bool const has_tostring = false;\n};\n\ntemplate <>\nstruc...
2008/11/02
[ "https://Stackoverflow.com/questions/257288", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21482/" ]
257,324
<p>I need to add 30 minutes to values in a Oracle date column. I do this in my SELECT statement by specifying </p> <p><code>to_char(date_and_time + (.000694 * 31)</code></p> <p>which works fine most of the time. But not when the time is on the AM/PM border. For example, adding 30 minutes to <code>12:30</code> [which is PM] returns <code>1:00</code> which is AM. The answer I expect is <code>13:00</code>. What's the correct way to do this?</p>
[ { "answer_id": 257337, "author": "Camilo Díaz Repka", "author_id": 861, "author_profile": "https://Stackoverflow.com/users/861", "pm_score": 1, "selected": false, "text": "SELECT to_char((to_date('12:40 PM', 'HH:MI AM') + (1/24/60) * 30), 'HH24:MI') as time\n FROM dual\n\nTIME\n--------...
2008/11/02
[ "https://Stackoverflow.com/questions/257324", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401/" ]
257,329
<p>I'm working on writing a kernel, and I have a few friends working with me on the project. We've been using DJGPP to compile the project for a while, but we're having some cross-platform compatibility issues with compiling this way that have left my main Partnet on the project unable to compile on Windows XP. (DJGPP's GCC is having issues with argument lists longer than 127 on windows XP, but not having issues with the same argument lists on Vista. So, for once, Vista works better than XP at something. o.O)</p> <p>Anywho, rather than try to work out some dirty hack to make the darn thing compile with DJGPP, we've decided that we want to ditch DJGPP entirely and work with a different version of GCC for windows. The trouble is, MinGW (to my knowledge) doesn't let us use NASM syntax for the assembly portions of the code, and it would be a bit of a pain to convert it all to AT&amp;T syntax at this point. Possible of course, since its fairly early in the project, but a pain.</p> <p>So now you know the issue. My question is this: What GCC compiler distro for Windows will allow us to most easily port this project to itself? Ideally, we're looking for something that can do NASM assembler syntax, not have any reliance on externel dlls (this is a kernel here, it won't have access to them) and will work consistantly on multiple versions on Windows. What are your recommendations about the best way to go about doing this, and what version of GCC for windows do you recommend?</p> <p>Note that if we are going to need to convert the project to AT&amp;T syntax that's OK, I'd just like to not do that. We're actually using NASM to assemble the assembly bits of it, and that produces a valid .o file, but MinGW isn't able to link that in for some reason. I think the inline assembly bits (maybe 5 lines) are already AT&amp;T syntax, as required by GCC.</p> <p>Thanks!</p>
[ { "answer_id": 7827309, "author": "Unsigned", "author_id": 629493, "author_profile": "https://Stackoverflow.com/users/629493", "pm_score": 1, "selected": false, "text": "elf32" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19521/" ]
257,331
<p>What is the clearest explanation of what computer scientists mean by "the naive implementation"? I need a good clear example which will illustrate — ideally, even to non-technical people — that the naive implementation may <em>technically</em> be a functioning solution to the problem, but <em>practically</em> be utterly unusable.</p>
[ { "answer_id": 257340, "author": "Quibblesome", "author_id": 1143, "author_profile": "https://Stackoverflow.com/users/1143", "pm_score": -1, "selected": false, "text": "foreach(object o in set1)\n{\n foreach(object p in set1)\n {\n // codez\n }\n}\n" }, { "answer_...
2008/11/02
[ "https://Stackoverflow.com/questions/257331", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33904/" ]
257,339
<p>I've never done it myself, and I've never subscribed to a feed, but it seems that I'm going to have to create one, so I'm wondering. The only way that seems apparent to me is that when the system is updated with a new item (blog post, news item, whatever), a new element should be written to the rss file. Or alternatively have a script that checks for updates to the system a few times a day and writes to the rss file is there is. There's probably a better way of doing it though.</p> <p>And also, should old elements be removed as new ones are added? </p> <p><strong>Edit</strong>: I should have mentioned, I'm working in PHP, specifically using CodeIgniter, with a mySQL database.</p>
[ { "answer_id": 257366, "author": "Nick", "author_id": 14072, "author_profile": "https://Stackoverflow.com/users/14072", "pm_score": 0, "selected": false, "text": "<%@ Page Language=\"C#\" EnableViewState=\"false\" %>\n<%@ OutputCache Duration=\"300\" VaryByParam=\"none\" %>\n\n<%@ Import...
2008/11/02
[ "https://Stackoverflow.com/questions/257339", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12765/" ]
257,343
<p>If I have a range of say <code>000080-0007FF</code> and I want to see if a char containing hex is within that range, how can I do it?</p> <p>Example</p> <pre><code>char t = 0xd790; if (t is within range of 000080-0007FF) // true </code></pre>
[ { "answer_id": 257346, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": false, "text": "wchar_t t = 0xd790;\n\nif (t >= 0x80 && t <= 0x7ff) ...\n" }, { "answer_id": 257372, "author": "Brian R. Bond...
2008/11/02
[ "https://Stackoverflow.com/questions/257343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33481/" ]
257,350
<p>I need to create a form with, half linear view (textboxes and dropdownlists in separate line) and the other half, non linear view i.e. the textboxes will appear next to each other, like first name and last name will be next to each other. </p> <p>I am aware how to acomplish the linear view with CSS. I am using</p> <pre><code>fieldset { clear: both; font-size: 100%; border-color: #000000; border-width: 1px 0 0 0; border-style: solid none none none; padding: 10px; margin: 0 0 0 0; } label { float: left; width: 10em; text-align:right; } </code></pre> <p>How can I get the non-linear view?</p>
[ { "answer_id": 257995, "author": "Cyril Gupta", "author_id": 33052, "author_profile": "https://Stackoverflow.com/users/33052", "pm_score": 0, "selected": false, "text": "display: inline" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
257,353
<p>Is there a native c++ variable type that's "bigger" than a double?<br> float is 7<br> double is 15 (of course depending on the compiler)<br> Is there anything bigger that's native, or even non-native?</p>
[ { "answer_id": 257359, "author": "C. K. Young", "author_id": 13, "author_profile": "https://Stackoverflow.com/users/13", "pm_score": 6, "selected": true, "text": "long double" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31325/" ]
257,391
<p>I have a const char arr[] parameter that I am trying to iterate over,</p> <pre><code>char *ptr; for (ptr= arr; *ptr!= '\0'; ptr++) /* some code*/ </code></pre> <p>I get an error: assignment discards qualifiers from pointer target type</p> <p>Are const char [] handled differently than non-const?</p>
[ { "answer_id": 257394, "author": "JaredPar", "author_id": 23283, "author_profile": "https://Stackoverflow.com/users/23283", "pm_score": 5, "selected": true, "text": "const char* ptr;\n" }, { "answer_id": 257420, "author": "Drew Hall", "author_id": 23934, "author_profi...
2008/11/02
[ "https://Stackoverflow.com/questions/257391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
257,396
<p>I'm having some trouble understanding how command parameter binding works.</p> <p>When I create an instance of the widget class before the call to InitializeComponent it seems to work fine. Modifications to the parameter(Widget) in the ExecuteCommand function will be "applied" to _widget. This is the behavior I expected. </p> <p>If the instance of _widget is created after InitializeComponent, I get null reference exceptions for e.Parameter in the ExecuteCommand function.</p> <p>Why is this? How do I make this work with MVP pattern, where the bound object may get created after the view is created?</p> <pre><code>public partial class WidgetView : Window { RoutedCommand _doSomethingCommand = new RoutedCommand(); Widget _widget; public WidgetView() { _widget = new Widget(); InitializeComponent(); this.CommandBindings.Add(new CommandBinding(DoSomethingCommand, ExecuteCommand, CanExecuteCommand)); } public Widget TestWidget { get { return _widget; } set { _widget = value; } } public RoutedCommand DoSomethingCommand { get { return _doSomethingCommand; } } private static void CanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) { if (e.Parameter == null) e.CanExecute = true; else { e.CanExecute = ((Widget)e.Parameter).Count &lt; 2; } } private static void ExecuteCommand(object sender, ExecutedRoutedEventArgs e) { ((Widget)e.Parameter).DoSomething(); } } &lt;Window x:Class="CommandParameterTest.WidgetView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WidgetView" Height="300" Width="300" DataContext="{Binding RelativeSource={RelativeSource Self}}"&gt; &lt;StackPanel&gt; &lt;Button Name="_Button" Command="{Binding DoSomethingCommand}" CommandParameter="{Binding TestWidget}"&gt;Do Something&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Window&gt; public class Widget { public int Count = 0; public void DoSomething() { Count++; } } </code></pre>
[ { "answer_id": 257508, "author": "Todd White", "author_id": 30833, "author_profile": "https://Stackoverflow.com/users/30833", "pm_score": 2, "selected": false, "text": "public static readonly DependencyProperty TestWidgetProperty =\n DependencyProperty.Register(\"TestWidget\", typeof(...
2008/11/02
[ "https://Stackoverflow.com/questions/257396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22522/" ]
257,398
<p>Is there a UI library to create a message box or input box in python?</p>
[ { "answer_id": 8678916, "author": "akoc kanor", "author_id": 1122830, "author_profile": "https://Stackoverflow.com/users/1122830", "pm_score": 1, "selected": false, "text": "import *\nimport os\n\n class Dialog(Toplevel):\n\n def __init__(self, parent, title = None):\n\n Top...
2008/11/02
[ "https://Stackoverflow.com/questions/257398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]
257,400
<p>I am trying to load <code>UIImage</code> object from <code>NSData</code>, and the sample code was to <code>NSImage</code>, I guess they should be the same. But just now loading the image, I am wondering what's the best to troubleshoot the <code>UIImage</code> loading <code>NSData</code> issue.</p>
[ { "answer_id": 257451, "author": "Noah Witherspoon", "author_id": 30618, "author_profile": "https://Stackoverflow.com/users/30618", "pm_score": 6, "selected": true, "text": "initWithData:" }, { "answer_id": 258122, "author": "leonho", "author_id": 30883, "author_profi...
2008/11/02
[ "https://Stackoverflow.com/questions/257400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32096/" ]
257,409
<p>I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. All the images are part of the HTML page.</p>
[ { "answer_id": 258511, "author": "Ryan Ginstrom", "author_id": 10658, "author_profile": "https://Stackoverflow.com/users/10658", "pm_score": 7, "selected": true, "text": "\"\"\"\ndumpimages.py\n Downloads all the images on the supplied URL, and saves them to the\n specified output ...
2008/11/02
[ "https://Stackoverflow.com/questions/257409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2220518/" ]
257,418
<p>I've been seeing that expression for over 10 years now. I've been trying to think what it's good for. Since I see it mostly in #defines, I assume it's good for inner scope variable declaration and for using breaks (instead of gotos.)</p> <p>Is it good for anything else? Do you use it?</p>
[ { "answer_id": 257421, "author": "Jere.Jones", "author_id": 19476, "author_profile": "https://Stackoverflow.com/users/19476", "pm_score": 7, "selected": false, "text": "do {\n // do something\n if (error) {\n break;\n }\n // do something else\n if (error) {\n break;\n }\n //...
2008/11/02
[ "https://Stackoverflow.com/questions/257418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31515/" ]
257,423
<p>I've been trying to trace down why I have 100% iowait on my box. If I do something like a mysql select query, system goes to 100% iowait (on more than one cpu on my server,) which kills my watchdogs and sometimes kills httpd itself. </p> <p>In vmstat I see that every 8 seconds or so, there's a 5MB disk write. And that causes at least one cpu (out of 4) to be blocking for one or two seconds. </p> <p>I have to say that there are a few million files in my ext3 (and I tried ext2, and I have no atime and no journaling enabled.) There is a hardware raid, mirroring two 300GB ides.</p> <p>I'm missing dtrace. Is there any way to find out what causes these writes? and how do I speed my filesystem up? </p> <p>Ideas are welcome!</p> <p>Thank you!</p>
[ { "answer_id": 257434, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 0, "selected": false, "text": "strace" }, { "answer_id": 257783, "author": "Charles Duffy", "author_id": 14122, "author_profile": "http...
2008/11/02
[ "https://Stackoverflow.com/questions/257423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31515/" ]
257,433
<p>I wonder if the UNIX domain socket connections with postgresql are faster then tcp connections from localhost in high concurrency rate and if it does, by how much?</p>
[ { "answer_id": 257490, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "read()" } ]
2008/11/02
[ "https://Stackoverflow.com/questions/257433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20955/" ]
257,462
<p>So I have this c# application that needs to ping my web server thats running linux/php stack.<br> I am having problems with the c# way of base 64 encoding bytes.</p> <p>my c# code is like:</p> <pre><code>byte[] encbuff = System.Text.Encoding.UTF8.GetBytes("the string"); String enc = Convert.ToBase64String(encbuff); </code></pre> <p>and php side:</p> <pre><code>$data = $_REQUEST['in']; $raw = base64_decode($data); </code></pre> <p>with larger strings 100+ chars it fails. I think this is due to c# adding '+'s in the encoding but not sure. any clues</p>
[ { "answer_id": 257470, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "byte[] bytes = new byte[1000];\nConsole.WriteLine(Convert.ToBase64String(bytes));\n" }, { "answer_id": 257473, ...
2008/11/02
[ "https://Stackoverflow.com/questions/257462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146637/" ]
257,505
<p>Within an unordered list:</p> <pre><code>&lt;li&gt;&lt;span&gt;&lt;/span&gt; The lazy dog.&lt;/li&gt; &lt;li&gt;&lt;span&gt;AND&lt;/span&gt; The lazy cat.&lt;/li&gt; &lt;li&gt;&lt;span&gt;OR&lt;/span&gt; The active goldfish.&lt;/li&gt; </code></pre> <p>Adding a class or style attribute is permitted but padding the text and adding or changing tags is not allowed.</p> <p>The page is rendering with Courier New.</p> <p>Goal is to have text after span lined up.</p> <pre><code> The lazy dog. AND The lazy cat. OR The active goldfish. </code></pre> <p>Justification of the "OR" is unimportant.</p> <p>The lazy animal text may be wrapped in an additional element but I'll have to double check.</p>
[ { "answer_id": 257524, "author": "Stephen Caldwell", "author_id": 33437, "author_profile": "https://Stackoverflow.com/users/33437", "pm_score": 10, "selected": true, "text": "ul {\n list-style-type: none;\n padding-left: 0px;\n}\n\nul li span {\n float: left;\n width: 40px;\n}" }, ...
2008/11/02
[ "https://Stackoverflow.com/questions/257505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1293/" ]
257,507
<p>I understand how the implementation of dynamic binding works and also the difference between static and dynamic binding, I am just having trouble wrapping my brain around the definition of dynamic binding. Basically other than it is a run-time binding type.</p>
[ { "answer_id": 257565, "author": "kings90", "author_id": 33269, "author_profile": "https://Stackoverflow.com/users/33269", "pm_score": 1, "selected": false, "text": "class Animal\n{\nvoid talk();\n}\n\nclass Dog extends Animal\n{\npublic void talk() { System.out.println(\"woof\"); }\n}\n...
2008/11/02
[ "https://Stackoverflow.com/questions/257507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29299/" ]
257,514
<p>I need to find out the pixel position of one element in a list that's been displayed using a <code>ListView</code>. It seems like I should get one of the <strong>TextView's</strong> and then use <code>getTop()</code>, but I can't figure out how to get a child view of a <code>ListView</code>.</p> <p><strong>Update:</strong> The children of the <code>ViewGroup</code> do not correspond 1-to-1 with the items in the list, for a <code>ListView</code>. Instead, the <code>ViewGroup</code>'s children correspond to only those views that are visible right now. So <code>getChildAt()</code> operates on an index that's internal to the <code>ViewGroup</code> and doesn't necessarily have anything to do with the position in the list that the <code>ListView</code> uses.</p>
[ { "answer_id": 340691, "author": "jasonhudgins", "author_id": 24590, "author_profile": "https://Stackoverflow.com/users/24590", "pm_score": -1, "selected": false, "text": " View element = listView.getListAdapter().getView(position, null, null);\n" }, { "answer_id": 2679284, ...
2008/11/02
[ "https://Stackoverflow.com/questions/257514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2652/" ]
257,519
<p>I'm completely new at C# and NUnit.</p> <p>In Boost.Test there is a family of <code>BOOST_*_THROW</code> macros. In Python's test module there is <code>TestCase.assertRaises</code> method.</p> <p>As far as I understand it, in C# with NUnit (2.4.8) the only method of doing exception test is to use <code>ExpectedExceptionAttribute</code>.</p> <p>Why should I prefer <code>ExpectedExceptionAttribute</code> over - let's say - Boost.Test's approach? What reasoning can stand behind this design decision? Why is that better in case of C# and NUnit?</p> <p>Finally, if I decide to use <code>ExpectedExceptionAttribute</code>, how can I do some additional tests after exception was raised and catched? Let's say that I want to test requirement saying that object has to be valid after some setter raised <code>System.IndexOutOfRangeException</code>. How would you fix following code to compile and work as expected?</p> <pre><code>[Test] public void TestSetterException() { Sth.SomeClass obj = new SomeClass(); // Following statement won't compile. Assert.Raises( "System.IndexOutOfRangeException", obj.SetValueAt( -1, "foo" ) ); Assert.IsTrue( obj.IsValid() ); } </code></pre> <hr> <p>Edit: Thanks for your answers. Today, I've found an <em>It's the Tests</em> <a href="http://nunit.com/blogs/?p=63" rel="nofollow noreferrer">blog entry</a> where all three methods described by you are mentioned (and one more minor variation). It's shame that I couldn't find it before :-(.</p>
[ { "answer_id": 257523, "author": "Cristian Libardo", "author_id": 16526, "author_profile": "https://Stackoverflow.com/users/16526", "pm_score": 3, "selected": false, "text": "Assert.That( delegate { ... }, Throws.Exception<ArgumentException>())\n" }, { "answer_id": 257526, "a...
2008/11/02
[ "https://Stackoverflow.com/questions/257519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26141/" ]
257,550
<p>I have put together a script which is very much like the flickr photostream feature. Two thumbnails next to each other, and when you click the next or prev links the next (or previous) two images slide in. Cool!</p> <p>Currently when the page loads it loads the two images. The first time nxt / prv is used then the next two images or previous two are loaded via ajax, with the id of the first image being passed in the url and the HTML for the two new images returned and displayed via ajax.</p> <p>simple enough, but it got me to thinking, on a slow connection, or heavy server load then the two images, although relatively small thumbnails could still take a while to load, and the nice things with sliding panes is the fact that the hidden data slides in quickly and smoothly preferbly without a loading delay.</p> <p>So I was wondering from a performance and good practice point of view which option is best, this is what I can think of for now, open to suggestions.</p> <p>1, call each set of images via JSON (its supposed to be fast?) </p> <p>2,load all the possible images into a json file and pull in the details that way - although browser will still have to load image. Plus sometimes there might be 4 images, other times there could be upto 1000!</p> <p>3, Load 10 images via php into a Json or other file, and load all 10 images into the browser hiding the 8 which are not on show, and always showing the middle two. Problem here is that each time someone clicks, the file has to reload the first and last images, which still takes up time, although i suppose the middle images will have all been cached via the browser by now though. But still there is a loading time.</p> <p>4, Is it possible to have a json image with all the image details (regardless of numbers) and use no 3 above to load 10 of those images, is it possible to use ajax to only read 10 lines and keep a pointer of the last one it read, so the json file can be loaded fast, short refresh and images either side are cached via the browser!!</p> <p>Hope thats clear, any suggestions on how you would handle this?</p>
[ { "answer_id": 257594, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 5, "selected": true, "text": "var img = new Image();\nimg.src = \"http://example.com/new/image.jpg\";\n" }, { "answer_id": 257601, "author":...
2008/11/02
[ "https://Stackoverflow.com/questions/257550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28241/" ]