qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
211,051 | <p>Because Canvas3D doesn't have the ability to resize dynamically with the parent frame, I would like to be able to track when a user resizes a window and then resize it manually myself. (If this ends up crashing Canvas3D, as some docs suggest, I will simply destroy and recreate it when the user resizes their window). Part of this procedure involves being able to accurately tell how big the container panel is to begin with.</p>
<p>The two methods I've tried:</p>
<pre>panel.getHeight();
panel.getPreferredSize().height;</pre>
<p>Don't seem to accurately report things: <code>getHeight()</code> is invariably zero, and <code>getPreferredSize()</code> returns numbers that don't actually have anything to do with the actual size of the panel.</p>
<p>Any ideas?</p>
<p><b>Edit</b>: So, I took a debugger to the panel object and manually inspected the non-object properties and I didn't see anything that resembled width/height. Granted, there are sub-objects that I didn't look at. Also, maybe the window has to be visible (it isn't, at the point I'm interfacing the object) when I query for height/object?</p>
<p><b>Edit 2</b>: So, Swing classes are subclasses of AWT classes, so I imagine if you're able to find the height/width of those, the approach would generalize. I've amended the title accordingly.</p>
| [
{
"answer_id": 211095,
"author": "Simon Lehmann",
"author_id": 27011,
"author_profile": "https://Stackoverflow.com/users/27011",
"pm_score": 5,
"selected": true,
"text": "public class WindowResizeTest extends JFrame {\n\n public static void main(String[] args) {\n new WindowRes... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23845/"
] |
211,055 | <p>Does Linux/Unix/Posix provide an API to user-space applications to access a monotonically increasing clock, with centisecond to millisecond accuracy?</p>
<p>On Linux, /proc/uptime provides a string-based representation of a floating point number of the number of seconds the system has been up.</p>
<p>gettimeofday(2) does not provide a monotonically increasing clock.</p>
<p>I could use getitimer(2) in the ITIMER_REAL time domain, set the timer to start at the (platform dependent) maximum and ignore the signal generated, but according to the man page the longest the timer can run for is approximately 100 days, which is shorter than my expected run time.</p>
| [
{
"answer_id": 211077,
"author": "DGentry",
"author_id": 4761,
"author_profile": "https://Stackoverflow.com/users/4761",
"pm_score": 3,
"selected": false,
"text": "struct timespec tp;\nclock_gettime(CLOCK_MONOTONIC, &tp);\n"
},
{
"answer_id": 211080,
"author": "Robert Gamble"... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23744/"
] |
211,062 | <p>I have an Excel spreadsheet with 1 column, 700 rows. I care about every seventh line. I don't want to have to go in and delete the 6 rows between each row I care about. So my solution was to create another sheet and specify a reference to each cell I want.</p>
<pre><code>=sheet1!a1
=sheet1!a8
=sheet1!a15
</code></pre>
<p>But I don't want to type in each of these formulas ... `100 times.I thought if I selected the three and dragged the box around, it would understand what I was trying to do, but no luck.</p>
<p>Any ideas on how to do this elegantly/efficiently?</p>
| [
{
"answer_id": 211098,
"author": "JFV",
"author_id": 1391,
"author_profile": "https://Stackoverflow.com/users/1391",
"pm_score": 1,
"selected": false,
"text": "Dim strValue As String\nDim strCellNum As String\nDim x As String\nx = 1\n\nFor i = 1 To 700 Step 7\n strCellNum = \"A\" & i\... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23105/"
] |
211,074 | <p>The mouse hovers over an element and a tip appears. The tip overflows the page, triggering a scrollbar, which changes the layout just enough so that the underlying element that triggered the tip is no longer under the mouse pointer, so the tip goes away.</p>
<p>The tip goes away, so the scrollbar goes away, and now the mouse is again over the element.</p>
<p>Wash, rinse, repeat.</p>
<p>If I could make sure that tip isn't too big so as to trigger scrollbars, that would solve my problem.</p>
<p>EDIT: After reading comments, some things to clarify:
The div contains text which can vary. If I can, I want to show all the text. The div's location needs to be near the element the mouse's tip is over. So the key is, I need to know whether to truncate the text.</p>
<p>I did find this link:<br>
<a href="http://www.howtocreate.co.uk/tutorials/javascript/browserwindow" rel="nofollow noreferrer">http://www.howtocreate.co.uk/tutorials/javascript/browserwindow</a><br>
which contains this piece of the puzzle, figuring out how big the browser window is: </p>
<pre><code>function alertSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
window.alert( 'Width = ' + myWidth );
window.alert( 'Height = ' + myHeight );
}
</code></pre>
| [
{
"answer_id": 211078,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 1,
"selected": false,
"text": "#tooltip {\n position: absolute;\n height: 100px;\n width: 200px;\n border: 1px solid #444444;\n background-color: #EEEEEE... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
211,099 | <p>I've recently gotten my hobby java project embedded into a page <a href="https://stackoverflow.com/questions/138157/java-console-like-web-applet">thanks to this very site</a>, but now I'm having some security issues.</p>
<p>I have the include:</p>
<pre><code>import java.sql.*;
</code></pre>
<p>and the line:</p>
<pre><code>Class.forName("com.mysql.jdbc.Driver").newInstance();
</code></pre>
<p>as well as a mysql .jar file in my src directory, it works from the console, and in the applet works fine from the applet - up until that forName() line in my code, where it throws the exception:</p>
<pre>
Exception: com.mysql.jdbc.Driverjava.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.-1)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkExit(Unknown Source)
at java.lang.Runtime.exit(Unknown Source)
at java.lang.System.exit(Unknown Source)
at applet.Database.connectDB(Database.java:80)
etc...
</pre>
<p>I think I may be able to fix it with a client.policy file, otherwise I might need to write an abstraction layer which uses a server-client network connection to query from the server-side...</p>
<p>I'm sure the Java gurus here probably know the best way about it.</p>
| [
{
"answer_id": 211140,
"author": "Cem Catikkas",
"author_id": 3087,
"author_profile": "https://Stackoverflow.com/users/3087",
"pm_score": 0,
"selected": false,
"text": "newInstance()"
},
{
"answer_id": 212976,
"author": "Leigh Caldwell",
"author_id": 3267,
"author_pro... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14966/"
] |
211,100 | <p>When using <code>__import__</code> with a dotted name, something like: <code>somepackage.somemodule</code>, the module returned isn't <code>somemodule</code>, whatever is returned seems to be mostly empty! what's going on here?</p>
| [
{
"answer_id": 211101,
"author": "dwestbrook",
"author_id": 3119,
"author_profile": "https://Stackoverflow.com/users/3119",
"pm_score": 7,
"selected": true,
"text": "__import__"
},
{
"answer_id": 214682,
"author": "Glyph",
"author_id": 13564,
"author_profile": "https:... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3119/"
] |
211,118 | <p>I'm using the following view function to iterate over all items in the database (in order to find a tag), but I think the performance is very poor if the dataset is large.
Any other approach?</p>
<pre><code>def by_tag(tag):
return '''
function(doc) {
if (doc.tags.length > 0) {
for (var tag in doc.tags) {
if (doc.tags[tag] == "%s") {
emit(doc.published, doc)
}
}
}
};
''' % tag
</code></pre>
| [
{
"answer_id": 213138,
"author": "Bahadır Yağan",
"author_id": 3812,
"author_profile": "https://Stackoverflow.com/users/3812",
"pm_score": 4,
"selected": true,
"text": "function(doc) {\n for (var tag in doc.tags) {\n emit([tag, doc.published], doc)\n }\n};\n"
},
{
"answer_id... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28809/"
] |
211,122 | <p>In an application that is hosting several WCF services, what would be the best way to add custom configuration information for each service? For example you may want to pass or set a company name or specify the connectionString a service or some other parameter. </p>
<p>I'm guessing this might be possible by implementing IServiceBehavior.</p>
<p>i.e something like....</p>
<pre><code><behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug />
<customBehavior myCompany="ABC" />
</behavior>
<behavior name="MyOtherBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug />
<customBehavior myCompany="DEF" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyBehavior" name="MyNameSpace.MyService">
<endpoint address="" behaviorConfiguration="" binding="netTcpBinding"
name="TcpEndpoint" contract="MyNameSpace.IMyService" />
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
name="TcpMexEndpoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4000/MyService" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="MyOtherBehavior" name="MyNameSpace.MyOtherService">
<endpoint address="" behaviorConfiguration="" binding="netTcpBinding"
name="TcpEndpoint" contract="MyNameSpace.IMyOtherService" />
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
name="TcpMexEndpoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4000/MyOtherService" />
</baseAddresses>
</host>
</service>
</services>
</code></pre>
<p>Would set ABC on MyService and DEF on MyOtherService (assuming they have some common interface with a company name).</p>
<p>Can anyone elaborate on how you implement this?</p>
<p>TIA</p>
<p>Michael</p>
| [
{
"answer_id": 619295,
"author": "Cheeso",
"author_id": 48082,
"author_profile": "https://Stackoverflow.com/users/48082",
"pm_score": 3,
"selected": false,
"text": "<%@ ServiceHost\n Language=\"C#\"\n Debug=\"true\"\n Service=\"Ionic.Samples.Webservices.Sep20.CustomConfigService\"\n Fact... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,133 | <p>Oracle has this concept of allowing database users to be identified by the operating system user who is running the program that is connecting to Oracle. See <a href="http://www.oracle-base.com/articles/misc/OsAuthentication.php" rel="noreferrer">here</a>.</p>
<p>This allows you to do, as that user on a unix machine for example, a command such as:</p>
<pre><code>sqlplus /
</code></pre>
<p>I am attempting to write a Java program for Oracle 10.2 which connects without a username or password. The obvious choice of url:</p>
<pre><code>jdbc:oracle:thin:/@localhost:1521:MYDBSID
</code></pre>
<p>doesn't work, giving an error (Sorry I don't have the error available right now).</p>
<p>I have attempted many other forms of doing this as well, but with no luck.</p>
<p>Does anyone have any suggestions on how I can connect a Java program to Oracle using the OS identification method?</p>
| [
{
"answer_id": 211228,
"author": "Tony BenBrahim",
"author_id": 80075,
"author_profile": "https://Stackoverflow.com/users/80075",
"pm_score": 4,
"selected": true,
"text": "jdbc:oracle:oci8:/@MYDBSID"
},
{
"answer_id": 30893239,
"author": "evgeny",
"author_id": 5019899,
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27308/"
] |
211,137 | <p>I have ASP.Net code similar to the following (this is inside a FIELDSET):</p>
<pre><code><ol>
<li>
<label>Some label</label>
<one or more form controls, ASP.Net controls, labels, etc.>
</li>
<li>
<label>Another label</label>
<... more of the same...>
</li>
...
</ol>
</code></pre>
<p>I'm trying to keep my markup as clean as I possibly can, but I've decided that for various reasons, I need to wrap a DIV around everything in the list item after the first label, like this:</p>
<pre><code><ol>
<li>
<label>Some label</label>
<div class="GroupThese">
<one or more form controls, ASP.Net controls, labels, etc.>
</div>
</li>
<li>
<label>Another label</label>
<div class="GroupThese">
<... more of the same...>
</div>
</li>
...
</ol>
</code></pre>
<p>I would rather do this with "unobtrusive Javascript" via jQuery instead of littering my page with extra markup so I can keep the form semantically "clean".</p>
<p>I know how to write a jQuery selector to get to the first label in each list item $("li+label") or use :first-child. I also know how to insert things after the selection.</p>
<p>What I can't figure out (at least this late at night) is how to find everything after the first label in the list item (or basically everything in the list item except for the first label would be another way to put it) and wrap a DIV around that in the document ready function. </p>
<p><strong>UPDATE:</strong></p>
<p>Owen's code worked once I removed the single quotes from around: <pre>$('this')</pre> and set the proper decendent selector: <pre>$("li label:first-child")</pre> in order to only select the first label that occurs after a list item.</p>
<p>Here is what I did:</p>
<pre><code>$(document).ready(function() {
$('li label:first-child').each(function() {
$(this).siblings().wrapAll('<div class="GroupThese"></div>');
});
});
</code></pre>
| [
{
"answer_id": 211150,
"author": "Matt",
"author_id": 2338,
"author_profile": "https://Stackoverflow.com/users/2338",
"pm_score": 2,
"selected": false,
"text": "var $div = $('li').wrapInner('<div></div>').children('div');\n$div.children('label').prependTo($div.parent());\n"
},
{
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14894/"
] |
211,143 | <p>I thought I understood Java generics pretty well, but then I came across the following in java.lang.Enum:</p>
<pre><code>class Enum<E extends Enum<E>>
</code></pre>
<p>Could someone explain how to interpret this type parameter? Bonus points for providing other examples of where a similar type parameter could be used.</p>
| [
{
"answer_id": 211161,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "public class StatusCode extends Enum<StatusCode>\n"
},
{
"answer_id": 758595,
"author": "Maurice Naftalin",
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] |
211,160 | <p>How do I get the inverse of a matrix in python? I've implemented it myself, but it's pure python, and I suspect there are faster modules out there to do it.</p>
| [
{
"answer_id": 211174,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 8,
"selected": true,
"text": "from numpy import matrix\nfrom numpy import linalg\nA = matrix( [[1,2,3],[11,12,13],[21,22,23]]) # Creates a matrix.\nx = mat... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
211,169 | <p>So I was wondering if there are any major differences between the various implementations of the hash algorithms, take the SHA series of algorithms for example. All of them have 3 implementations each, 1 in managed code and 2 wrappers around different native crypto APIs, but are there any major differences between using any of them? I can imagine that the wrapper versions could have higher performance since its being executed in native code, but surley hey all need to perform the exact same calculations and thus provide the same output ie hey are interchangable. Is this correct?</p>
<p>For instance SHA512CNG cant be used on XP SP2 (docs are wrong) but SHA512MANAGED can.</p>
<hr>
<p>@Maxim - Thank you, but not quite what I was asking for. I was asking if there is any difference, other than possibly performance, from using the Managed/CryptoServiceProvider/CNG implementations of a given hash algorithm. With .NET 3.5 you get all of the hash algorithms with three implementations, so</p>
<p>SHA512Managed
SHA512CryptoServiceProvider
SHA512Cng</p>
<p>The latter two being wrappers around native APIs. This is true for all SHAxxx implementations for example.</p>
| [
{
"answer_id": 1004127,
"author": "Joe Basirico",
"author_id": 20795,
"author_profile": "https://Stackoverflow.com/users/20795",
"pm_score": 2,
"selected": false,
"text": "CalculateHash(1, 1024, new SHA1CryptoServiceProvider());\n\nstatic long CalculateHash(UInt64 repetitions, UInt64 siz... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25319/"
] |
211,176 | <p>I am seeing following exception when I try to use dynamic proxy </p>
<pre><code> com.intellij.rt.execution.application.AppMain DynamicProxy.DynamicProxy
Exception in thread "main" java.lang.IllegalArgumentException: interface Interfaces.IPerson is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at DynamicProxy.Creator.getProxy(Creator.java:18)
at DynamicProxy.DynamicProxy.main(DynamicProxy.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
</code></pre>
<p>Any idea what I need to do to resolve it</p>
| [
{
"answer_id": 211226,
"author": "ddimitrov",
"author_id": 18187,
"author_profile": "https://Stackoverflow.com/users/18187",
"pm_score": 3,
"selected": false,
"text": "DynamicProxy"
},
{
"answer_id": 13379769,
"author": "omnomnom",
"author_id": 577812,
"author_profile... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,216 | <p>What are the lesser-known but useful features of the Haskell programming language. (I understand the language itself is lesser-known, but work with me. Even explanations of the simple things in Haskell, like defining the Fibonacci sequence with one line of code, will get upvoted by me.) </p>
<ul>
<li>Try to limit answers to the Haskell core</li>
<li>One feature per answer</li>
<li>Give an example and short description of the feature, not just a link to documentation</li>
<li>Label the feature using bold title as the first line</li>
</ul>
| [
{
"answer_id": 212014,
"author": "Jonathan Tran",
"author_id": 12887,
"author_profile": "https://Stackoverflow.com/users/12887",
"pm_score": 4,
"selected": false,
"text": "let {\n x = 40;\n y = 2\n } in\n x + y\n"
},
{
"answer_id": 212103,
"author": "Santiago Pa... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
211,219 | <p>Having some issues loading files from media hosting into swf shell (a swf loading swfs as assets). Mp3s and images work fine but a swf never loads. Code is like:</p>
<p>swfpath = "<a href="http://555.55.555.555/vir_dir/swf/N000001.swf" rel="nofollow noreferrer">http://555.55.555.555/vir_dir/swf/N000001.swf</a>"
movie_loader.loadMovie(swfpath, "mc_swfimage");</p>
<p>if the swfpath is set to "swf/N00001.swf" it loads fine and if I point firefox towards the http link above (555s as placeholders here) it opens the file in firefox just fine.</p>
<p>Is it some security or does loadMovie not handle http paths?</p>
<p>Note it works fine if I do loadAudio with the same thing pointing to an MP3.</p>
| [
{
"answer_id": 217664,
"author": "Ronnie Liew",
"author_id": 1987,
"author_profile": "https://Stackoverflow.com/users/1987",
"pm_score": 2,
"selected": true,
"text": "http://mysubdomain.mydomain.com/fu/bar/"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18309/"
] |
211,236 | <p>Since we cannot setup Eclipse's RSE to use at the tool for remote editing, I have installed <a href="http://www.cis.upenn.edu/~bcpierce/unison/docs.html" rel="nofollow noreferrer">Unison</a>. But how can I get Eclipse to automatically run unison on every file save? Is there an eclipse plugin available for this?</p>
<p>TIA</p>
| [
{
"answer_id": 271641,
"author": "javamonkey79",
"author_id": 27657,
"author_profile": "https://Stackoverflow.com/users/27657",
"pm_score": 3,
"selected": false,
"text": "@Override\npublic void start( final BundleContext context ) throws Exception {\n super.start( context );\n plug... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14351/"
] |
211,237 | <p>C++ guarantees that variables in a compilation unit (.cpp file) are initialised in order of declaration. For number of compilation units this rule works for each one separately (I mean static variables outside of classes).</p>
<p>But, the order of initialization of variables, is undefined across different compilation units.</p>
<p>Where can I see some explanations about this order for gcc and MSVC (I know that relying on that is a very bad idea - it is just to understand the problems that we may have with legacy code when moving to new GCC major and different OS)?</p>
| [
{
"answer_id": 211307,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 7,
"selected": true,
"text": "main()"
},
{
"answer_id": 211314,
"author": "Community",
"author_id": -1,
"author_profile": "https:... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18174/"
] |
211,241 | <p>My current solution for renaming the project folder is:</p>
<ul>
<li>Remove the project from the solution.</li>
<li>Rename the folder outside Visual Studio.</li>
<li>Re-add the project to the solution.</li>
</ul>
<p>Is there a better way?</p>
| [
{
"answer_id": 211268,
"author": "rabashani",
"author_id": 10977,
"author_profile": "https://Stackoverflow.com/users/10977",
"pm_score": 7,
"selected": false,
"text": "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Shani.Commands.Impl\", \"Shani.Commands.Impl\\Shani.Commands.Imp... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1740/"
] |
211,243 | <p>I have code looking something like this:</p>
<pre><code>$data = file_get_contents($tempFile); // perhaps 30MB of file data, now in PHP's memory
$hash = md5($data);
$query = "INSERT INTO some_table
SET BlobData = '" . mysql_real_escape_string($data) . "',
BlobHash = '$hash'
";
mysql_query($query);
</code></pre>
<p>I know this isn't very efficient as each of the '.' operators will reallocate a bigger memory block and the 30MB string will be copied several times.</p>
<p>Is there anything more efficient than the following solution?</p>
<pre><code>$data = file_get_contents($tempFile); // perhaps 30MB of file data, now in PHP's memory
$hash = md5($data);
$query = "INSERT INTO some_table SET BlobData = '%s', BlobHash = '$hash'";
mysql_query(sprintf($query, mysql_real_escape_string($data)));
</code></pre>
| [
{
"answer_id": 211265,
"author": "Don Neufeld",
"author_id": 13097,
"author_profile": "https://Stackoverflow.com/users/13097",
"pm_score": 0,
"selected": false,
"text": "ob_start();\necho 'INSERT INTO some_table SET BlobData = \\'', mysql_real_escape_string( $data ), '\\', BlobHash = \\'... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28835/"
] |
211,260 | <p>No extracted data output to data2.txt? What goes wrong to the code?</p>
<p><strong>MyFile.txt</strong></p>
<pre><code>ex1,fx2,xx1
mm1,nn2,gg3
EX1,hh2,ff7
</code></pre>
<p>This is my desired output in data2.txt:</p>
<pre><code>ex1,fx2,xx1
EX1,hh2,ff7
</code></pre>
<p><br></p>
<pre><code>#! /DATA/PLUG/pvelasco/Softwares/PERLINUX/bin/perl -w
my $infile ='My1.txt';
my $outfile ='data2.txt';
open IN, '<', $infile or die "Cant open $infile:$!";
open OUT, '>', $outfile or die "Cant open $outfile:$!";
while (<IN>) {
if (m/EX$HF|ex$HF/) {
print OUT $_, "\n";
print $_;
}
}
close IN;
close OUT;
</code></pre>
| [
{
"answer_id": 211269,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 1,
"selected": false,
"text": "My1.txt"
},
{
"answer_id": 211279,
"author": "raldi",
"author_id": 7598,
"author_profile": "https://Sta... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28607/"
] |
211,278 | <p>Is there a Maven archetype that will generate the same scaffolding as <code>maven-archetype-quickstart</code>, but will in addition create the basic project site layout generated by <code>maven-archetype-site</code>? Or do I always have to run each in sequence?</p>
| [
{
"answer_id": 721930,
"author": "paulgreg",
"author_id": 3122,
"author_profile": "https://Stackoverflow.com/users/3122",
"pm_score": 1,
"selected": false,
"text": "mvn site"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] |
211,299 | <p>I have implemented some table-per-type inheritance in my data model (basically have a <code>BaseEntity</code> type with all the base information for my items and a <code>Employer</code> type that inherits from the <code>BaseEntity</code> item). Everything appears to be set up correctly and when using the Entities (either via ADO.net Data Services or via Linq to Entities) I can see the <code>Employer</code> type and things appear to be fine. The issue starts when I create a new <code>Employer</code> entity and attempt to save it.</p>
<p>On the context that doesn't appear to be an <code>.AddToEmployer</code> item (only and <code>AddObject</code> or <code>AddToBaseEntity</code>).</p>
<p>If I use <code>AddObject("Employer", NewEmployer)</code> I get and error message of:</p>
<blockquote>
<p>The EntitySet name 'DataEntities.Employer' could not be found.</p>
</blockquote>
<p>If I use <code>AddToBaseEntity(NewEmployer)</code> I get an error message of:</p>
<blockquote>
<p>Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements orstore generated values.</p>
</blockquote>
<p>Have I missed a step in setting up the inheritance? Is there some specific way to save objects that are inherited? What am I doing wrong? I assume that the basic issue is that I should have an <code>AddToEmployer</code>, what do I need to do to get that exposed? It seems odd that it is not an option since I can see the Employer type on the client side and can do things such as:</p>
<p><code>var NewEmployer = new Employer()</code> - which seems to suggest that I can see the Employer type fine.</p>
| [
{
"answer_id": 369491,
"author": "Phani Raj",
"author_id": 46455,
"author_profile": "https://Stackoverflow.com/users/46455",
"pm_score": 3,
"selected": false,
"text": "ResolveName"
},
{
"answer_id": 4520699,
"author": "JohnMetta",
"author_id": 74919,
"author_profile":... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] |
211,311 | <p>I want to find out if length property for Java arrays is an int/long or something else.</p>
| [
{
"answer_id": 211324,
"author": "Sietse",
"author_id": 6400,
"author_profile": "https://Stackoverflow.com/users/6400",
"pm_score": 2,
"selected": false,
"text": "int"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28836/"
] |
211,319 | <p>i wonder if it is possible to cascade converters when using wpf databinding.
e.g. something like </p>
<pre><code><SomeControl Visibility="{Binding Path=SomeProperty, Converter={StaticResource firstConverter}, Converter={StaticResource secondConverter}}"/>
</code></pre>
<p>is it possible at all or do i have to create a custom converter that combines the functionality of converter A and B?</p>
| [
{
"answer_id": 211812,
"author": "Brad Leach",
"author_id": 708,
"author_profile": "https://Stackoverflow.com/users/708",
"pm_score": 4,
"selected": false,
"text": "<local:ValueConverterGroup x:Key=\"statusDisplayNameGroup\">\n <local:IntegerStringToProcessingStateConverter />\n <loca... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227/"
] |
211,329 | <p>What is a fast way to select a random row from a large mysql table?</p>
<p>I'm working in php, but I'm interested in any solution even if it's in another language.</p>
| [
{
"answer_id": 142311,
"author": "davr",
"author_id": 14569,
"author_profile": "https://Stackoverflow.com/users/14569",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM table \n WHERE id=\n (FLOOR(RAND() * \n (SELECT COUNT(*) FROM table)\n )\n );\n"
},... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3740/"
] |
211,335 | <p>I have a swf file that is not controlled by me. The swf expects a javascript call to set some variables after initialization. </p>
<p>The swf is embedded using the swfobject and I'm trying to call the as function right after the embed. This appears to be too soon because I get an error. Everything else should be fine since calling the as function manually via firebug does not produce the error.</p>
<p>So the question is how do I call the function when the embed is complete?</p>
| [
{
"answer_id": 211489,
"author": "jcoder",
"author_id": 417292,
"author_profile": "https://Stackoverflow.com/users/417292",
"pm_score": 1,
"selected": false,
"text": "window.onload = function() {\n // your code here \n}\n"
},
{
"answer_id": 217690,
"author": "MDCore",
"a... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22673/"
] |
211,336 | <p>How do you stay up-to-date when it comes to new software versions? Above all, I mean minor updates (new version for your Joomla-Installation, forum-software, FTP-Client, ...).</p>
<p>Versiontracker, RSS-Feeds, Newsletter... what else? Anyone wrote a script crawling websites for new versions or something similar?</p>
| [
{
"answer_id": 211343,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 2,
"selected": false,
"text": "emerge --sync && emerge -p world\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27404/"
] |
211,341 | <p>We have an Access DB which has a set of local tables and input forms etc. in which a user maintains their data.</p>
<p>We also have a SQL DB with the same tables which is used to displays the data in a web search form.</p>
<p>What is the best way to allow the user to udate his changes to the SQL db while keeping the working copy local so he can work offline and then push the files when he is happy with new version of the data?</p>
<p>My first thought was add the SQL tables as linked tables I could then truncate (access does like that) or delete the content in each table and then do an insert for each table.</p>
<p>Can I call a SP from access on the SQL to truncate the tables as I am have problem running deletes</p>
<p>I really do want to get it down to the user running a macro/sql call that is repeatable etc.</p>
<p>Thanks for your help</p>
| [
{
"answer_id": 211343,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 2,
"selected": false,
"text": "emerge --sync && emerge -p world\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3582/"
] |
211,345 | <p>To use <a href="http://en.wikipedia.org/wiki/Modular_exponentiation" rel="noreferrer">modular exponentiation</a> as you would require when using the <a href="http://en.wikipedia.org/wiki/Fermat_primality_test" rel="noreferrer">Fermat Primality Test</a> with large numbers (100,000+), it calls for some very large calculations.</p>
<p>When I multiply two large numbers (eg: 62574 and 62574) PHP seems to cast the result to a float. Getting the modulus value of that returns strange values.</p>
<pre><code>$x = 62574 * 62574;
var_dump($x); // float(3915505476) ... correct
var_dump($x % 104659); // int(-72945) ... wtf.
</code></pre>
<p>Is there any way to make PHP perform these calculations properly? Alternatively, is there another method for finding modulus values that would work for large numbers?</p>
| [
{
"answer_id": 211371,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 4,
"selected": false,
"text": "bcmod()"
},
{
"answer_id": 6027015,
"author": "K.Sya",
"author_id": 756824,
"author_profile": "https://Stac... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
211,346 | <p>I've read a number of books and websites on the subject of TDD, and they all make a lot of sense, especially Kent Beck's book. However, when I try to do TDD myself, i find myself staring at the keyboard wondering how to begin. Is there a process you use? What is your thought process? How do you identify your first tests?</p>
<p>The majority of the books on the subject do a great job of describing what TDD is, but not how to <em>practice</em> TDD in real world non-trivial applications. How do you do TDD?</p>
| [
{
"answer_id": 211362,
"author": "Nik Reiman",
"author_id": 14302,
"author_profile": "https://Stackoverflow.com/users/14302",
"pm_score": 3,
"selected": false,
"text": "int main(int argc, char *argv[]) {\n int result = 0;\n\n myApp &mw = getApp(); // Singleton method to return main app... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22912/"
] |
211,348 | <p>I created an ASMX file with a code behind file. It's working fine, but it is outputting XML.</p>
<p>However, I need it to output JSON. The ResponseFormat configuration doesn't seem to work. My code-behind is:</p>
<pre><code>[System.Web.Script.Services.ScriptService]
public class _default : System.Web.Services.WebService {
[WebMethod]
[ScriptMethod(UseHttpGet = true,ResponseFormat = ResponseFormat.Json)]
public string[] UserDetails()
{
return new string[] { "abc", "def" };
}
}
</code></pre>
| [
{
"answer_id": 10214090,
"author": "marc",
"author_id": 12260,
"author_profile": "https://Stackoverflow.com/users/12260",
"pm_score": 4,
"selected": false,
"text": " $.ajax({\n url: \"MyWebService.asmx/MethodName\",\n type: \"POST\",\n contentType:... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56/"
] |
211,355 | <p>A while ago I had a query that I ran quite a lot for one of my users. It was still being evolved and tweaked but eventually it stablised and ran quite quickly, so we created a stored procedure from it. </p>
<p>So far, so normal. </p>
<p>The stored procedure, though, was dog slow. No material difference between the query and the proc, but the speed change was massive. </p>
<p>[Background, we're running SQL Server 2005.]</p>
<p>A friendly local DBA (who no longer works here) took one look at the stored procedure and said "parameter spoofing!" (<strong>Edit:</strong> although it seems that it is possibly also known as 'parameter sniffing', which might explain the paucity of Google hits when I tried to search it out.) </p>
<p>We abstracted some of the stored procedure to a second one, wrapped the call to this new inner proc into the pre-existing outer one, called the outer one and, hey presto, it was as quick as the original query. </p>
<p>So, what gives? Can someone explain parameter spoofing? </p>
<p>Bonus credit for </p>
<ul>
<li>highlighting how to avoid it </li>
<li>suggesting how to recognise possible cause</li>
<li>discuss alternative strategies, e.g. stats, indices, keys, for mitigating the situation</li>
</ul>
| [
{
"answer_id": 215785,
"author": "6eorge Jetson",
"author_id": 23422,
"author_profile": "https://Stackoverflow.com/users/23422",
"pm_score": 5,
"selected": false,
"text": "CREATE PROCEDURE uspParameterSniffingAvoidance\n @SniffedFormalParameter int\nAS\nBEGIN\n\n DECLARE @SniffAvoi... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2902/"
] |
211,369 | <p>I'm writing a MFC app that uses the MS Mappoint OCX. I need to display the locations of people and vehicles on the map and the best of doing this appears to be with Pushpin objects. I have no problem displaying a stock pushpin icon with some text but want to change the icon to a custom designed one. From the limited amount of Mappoint programming info out there it appears the way to do this is to create a symbol object from a symbols object then assign this to a pushpin like this ..</p>
<pre><code>CSymbols symbols;
CSymbol symbol;
symbol=symbols.Add("c:/temp/myicon.ico");
pushpin.put_Symbol(symbol.get_ID());
</code></pre>
<p>But the program crashes with a unhandled exception on the symbols.add instruction.</p>
<p>Can anyone tell me what I am doing wrong here ? or am I on totally the wrong track ?</p>
<p>Thanks for your time</p>
<p>Ian</p>
| [
{
"answer_id": 221651,
"author": "IanW",
"author_id": 3875,
"author_profile": "https://Stackoverflow.com/users/3875",
"pm_score": 2,
"selected": false,
"text": "CSymbols symbols;\nCSymbol symbol;\n\nsymbols=map.get_Symbols();\nsymbol=symbols.Add(\"c:/temp/myicon.ico\");\npushpin.put_Symb... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3875/"
] |
211,376 | <p>I've got a big big code base that includes two main namespaces: the engine and the application. </p>
<p>The engine defines a vector3 class as a typedef of another vector3 class, with equality operators that sit in the engine namespace, not in the vector3 class. I added a class to the application that also had equality operators in the application namespace. </p>
<p>When I tried to compile, unrelated but near-by vector3 comparisons failed because it couldn't find an appropriate equality operator. I suspected I was causing a conflict so moved my equality operators into the class I added, and the compile succeeded.</p>
<pre><code>// engine.h
namespace Engine
{
class Vector3Impl { ... };
typedef Vector3Impl Vector3;
bool operator==(Vector3 const &lhs, Vector3 const &rhs) { ... }
}
// myfile.cpp
#include "engine.h"
namespace application
{
class MyClass { ... };
bool operator==(MyClass const &lhs, MyClass const &rhs) { ... }
void myFunc(...)
{
if ( myClassA == myClassB ) { ... } // builds
}
void anotherFunc(...)
{
Engine::Vector3 a, b;
...
if ( a == b ) { ... } // fails
}
}
</code></pre>
<p>However after thinking about it I can't see why the compile failed. There are no implicit conversions from vector3s to my class or vice-versa, and argument-dependent look-up should be pulling in the equality operator from the engine namespace and matching it.</p>
<p>I've tried reproducing this bug in a sample C++ project but that refuses to break. There must be something in the big big code base that is causing this problem, but I'm not sure where to start looking. Something like the opposite of a rogue "using Engine"? Anyone got any ideas?</p>
| [
{
"answer_id": 211386,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": -1,
"selected": false,
"text": "bool operator==(Vector3 const &lhs, Vector3 const &rhs) { ... }\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11801/"
] |
211,378 | <p>Shell scripts are often used as glue, for automation and simple one-off tasks. What are some of your favorite "hidden" features of the Bash shell/scripting language?</p>
<ul>
<li>One feature per answer</li>
<li>Give an example and short description of the feature, not just a link to documentation</li>
<li>Label the feature using bold title as the first line</li>
</ul>
<p>See also:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/132241/hidden-features-of-c">Hidden features of C</a></li>
<li><a href="https://stackoverflow.com/questions/9033/hidden-features-of-c">Hidden features of C#</a></li>
<li><a href="https://stackoverflow.com/questions/75538/hidden-features-of-c">Hidden features of C++</a></li>
<li><a href="https://stackoverflow.com/questions/102254/hidden-features-of-delphi">Hidden features of Delphi</a></li>
<li><a href="https://stackoverflow.com/questions/101268/hidden-features-of-python">Hidden features of Python</a></li>
<li><a href="https://stackoverflow.com/questions/15496/hidden-features-of-java">Hidden features of Java</a></li>
<li><a href="https://stackoverflow.com/questions/61088/hidden-features-of-javascript">Hidden features of JavaScript</a></li>
<li><a href="https://stackoverflow.com/questions/63998/hidden-features-of-ruby">Hidden features of Ruby</a></li>
<li><a href="https://stackoverflow.com/questions/61401/hidden-features-of-php">Hidden features of PHP</a></li>
<li><a href="https://stackoverflow.com/questions/161872/hidden-features-of-perl">Hidden features of Perl</a></li>
<li><a href="https://stackoverflow.com/questions/102084/hidden-features-of-vbnet">Hidden features of VB.Net</a></li>
</ul>
| [
{
"answer_id": 211382,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 3,
"selected": false,
"text": "if [ 2 -lt 3 ]\n then echo \"Numbers are still good!\"\nfi\n"
},
{
"answer_id": 211398,
"author": "Vinko Vrsalo... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/429/"
] |
211,383 | <p>I have the age-old problem of a <code>div</code> wrapping a two-column layout. My sidebar is floated, so my container <code>div</code> fails to wrap the content and sidebar.</p>
<pre class="lang-html prettyprint-override"><code><div id="container">
<div id="content"></div>
<div id="sidebar"></div>
</div>
</code></pre>
<p>There seem to be numerous methods of fixing the clear bug in Firefox:</p>
<ul>
<li><code><br clear="all"/></code></li>
<li><code>overflow:auto</code></li>
<li><code>overflow:hidden</code></li>
</ul>
<p>In my situation, the only one that seems to work correctly is the <code><br clear="all"/></code> solution, which is a little bit scruffy. <code>overflow:auto</code> gives me nasty scrollbars, and <code>overflow:hidden</code> must surely have side effects.
Also, IE7 apparently shouldn't suffer from this problem due to its incorrect behaviour, but in my situation it's suffering the same as Firefox.</p>
<p>Which method currently available to us is the most robust?</p>
| [
{
"answer_id": 211415,
"author": "Torkel",
"author_id": 24425,
"author_profile": "https://Stackoverflow.com/users/24425",
"pm_score": -1,
"selected": false,
"text": "<div style=\"clear:both;\"/>\n"
},
{
"answer_id": 461858,
"author": "Community",
"author_id": -1,
"aut... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] |
211,399 | <p>I need to execute a select and then update some of the rows in the <code>ResultSet</code> in an atomic way.</p>
<p>The code I am using looks like (simplified):</p>
<pre><code>stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery("SELECT ...");
while (rs.next()) {
if (conditions_to_update) {
rs.updateString(...);
rs.updateRow();
}
}
</code></pre>
<ul>
<li>Can I guarantee that the updates are going to be executed atomically ? If not, how could I assure that ?</li>
<li>What happens if any other process has changed the database row that you are updating via <code>updateRow()</code> ? Is there any way to lock the rows in the <code>ResultSet</code> ?</li>
</ul>
| [
{
"answer_id": 211502,
"author": "Ian",
"author_id": 4396,
"author_profile": "https://Stackoverflow.com/users/4396",
"pm_score": 3,
"selected": true,
"text": "...\ncon.setAutoCommit(false);\ntry {\n while (rs.next()) {\n if (conditions_to_update) {\n rs.updateString(...);\n ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] |
211,436 | <p>In my database, in one of the table I have a GUID column with allow nulls. I have a method with a Guid? parameter that inserts a new data row in the table. However when I say myNewRow.myGuidColumn = myGuid I get the following error: "Cannot implicitly convert type 'System.Guid?' to 'System.Guid'." </p>
| [
{
"answer_id": 211462,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 6,
"selected": true,
"text": "myNewRow.myGuidColumn = myGuid == null ? (object)DBNull.Value : myGuid.Value\n"
},
{
"answer_id": 211463,
"a... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1360/"
] |
211,448 | <p>I have a custom class that implements <code>ICollection</code>, and this class is readonly, ie. <code>IsReadOnly</code> returns true (as opposed to using the <code>readonly</code> keyword), and all functions that would normally modify the data in the collection throw <code>InvalidOperationException</code>'s.</p>
<p>Now, given such a construct, and a quick skim over the thread-safety issues when implementing <code>ICollection</code> (specifically <a href="http://msdn.microsoft.com/en-us/library/system.collections.icollection.issynchronized.aspx" rel="noreferrer"><code>ICollection.IsSynchronized</code></a> and friends), I came up with this quick and dirty solution.</p>
<pre><code>bool ICollection.IsSynchronised { get{ return true; } }
object ICollection.SyncRoot { get{ return new Object(); } }
</code></pre>
<p>Now, given the examples in MSDN, this won't cause different threads to lock properly, because they are getting different objects from <code>SyncRoot</code>. Given that this is a readonly collection though, is this an issue? Are there memory/GC issues with returning <code>new Object()</code>? Any other issues you can see with this implementation?</p>
| [
{
"answer_id": 211479,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "private readonly object lockObj = new object();\n"
},
{
"answer_id": 211491,
"author": "Kimoz",
"auth... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] |
211,477 | <p>I'd like to know how to - if even possible - reflect what method calls are executed inside the method during execution. I'm especially interested in either external method calls (that is, methods in other classes) or calling some specific method like getDatabaseConnection().</p>
<p>My intention would be to monitor predefined objects' actions inside methods and execute additional code if some specific conditions are met like some method is called with specific values. The monitor would be completely external class or a set of classes with no direct access to the object to be monitored by no other way than reflection.</p>
| [
{
"answer_id": 212474,
"author": "sakana",
"author_id": 28921,
"author_profile": "https://Stackoverflow.com/users/28921",
"pm_score": 2,
"selected": false,
"text": "pointcut profilling(): execution(public * *(..)) && (\n within(com.myPackage..*) ||\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,493 | <p>I'm just in the process of upgrading my Preview 5 application to Beta 1, and I'm nearly there save for this one error when trying to render a control:</p>
<blockquote>
<p>'System.Web.Mvc.HtmlHelper' does not
contain a definition for
'RenderPartial' and no extension
method 'RenderPartial' accepting a
first argument of type
'System.Web.Mvc.HtmlHelper' could be
found (are you missing a using
directive or an assembly reference?)</p>
</blockquote>
<p>My markup (in the .aspx View Content Page) is:</p>
<pre><code><% Html.RenderPartial("Controls/UserForm", ViewData); %>
</code></pre>
<p>I've tried using Microsoft.Web.Mvc but to no avail. Does anyone know where Html.RenderPartial has gone, or what alternative I could use?</p>
| [
{
"answer_id": 211524,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 3,
"selected": false,
"text": "<add assembly=\"System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n"
},
{
"answer_i... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] |
211,496 | <p>Is using a handrolled POCO queue class using pseudo code</p>
<pre><code>T Dequeue() {
lock(syncRoot) {
if(queue.Empty) Thread.Wait();
}
}
void Enqueue(T item) {
queue.Enqueue(item);
Thread.Notify();
}
</code></pre>
<p>For WCF is request queueing a scalable approach?</p>
| [
{
"answer_id": 211524,
"author": "tags2k",
"author_id": 192,
"author_profile": "https://Stackoverflow.com/users/192",
"pm_score": 3,
"selected": false,
"text": "<add assembly=\"System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n"
},
{
"answer_i... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] |
211,498 | <p>We use GUIDs for primary key, which you know is clustered by default.</p>
<p>When inserting a new row into a table it is inserted at a random page in the table (because GUIDs are random). This has a measurable performance impact because the DB will split data pages all the time (fragmentation). But the main reason I what a sequential GUID is because I want new rows to be inserted as the last row in the table... which will help when debugging.</p>
<p>I could make a clustered index on <code>CreateDate</code>, but our DB is auto-generated and in development, we need to do something extra to facilitate this. Also, <code>CreateDate</code> is not a good candidate for a clustered index.</p>
<p>Back in the day, I used <a href="http://www.informit.com/articles/article.aspx?p=25862" rel="nofollow noreferrer">Jimmy Nielsons COMB's</a>, but I was wondering if there is something in the .NET framework for this. In SQL 2005 Microsoft introduced <code>newsequentialid()</code> as an alternative to <code>newid()</code>, so I was hoping that they made a .NET equivalent because we generate the ID in the code.</p>
<p>PS: Please don't start discussing if this is right or wrong, because GUIDs should be unique etc.</p>
| [
{
"answer_id": 211542,
"author": "Scott Dorman",
"author_id": 1559,
"author_profile": "https://Stackoverflow.com/users/1559",
"pm_score": 1,
"selected": false,
"text": "newsequentialid()"
},
{
"answer_id": 211757,
"author": "John",
"author_id": 33,
"author_profile": "... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8547/"
] |
211,501 | <p>I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production.</p>
<p>What I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if/else statements, whichever is better).</p>
<p>I created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try/except before but figured this is a good time to learn).</p>
<p>Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.</p>
| [
{
"answer_id": 211541,
"author": "Mapad",
"author_id": 28165,
"author_profile": "https://Stackoverflow.com/users/28165",
"pm_score": 2,
"selected": false,
"text": "import sqlite3\nimport os\ndatabase_name = \"newdb.db\"\nif not os.path.isfile(database_name):\n print \"the database alr... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18676/"
] |
211,510 | <p>I am trying to come up with such a solution that the user is going to enter the URL of a web-service and it is going to be tested.</p>
<p>Although what I want is a URL change, I guarantee the Service Description is always going to be the same (except the wsdl:service tag of course which contains the soap:address); I just want to test different customers, running the same service.</p>
| [
{
"answer_id": 211517,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "Url"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22186/"
] |
211,535 | <h2>Note</h2>
<p>The question below was asked in 2008 about some code from 2003. As the OP's <strong>update</strong> shows, this entire post has been obsoleted by vintage 2008 algorithms and persists here only as a historical curiosity.</p>
<hr>
<p>I need to do a fast case-insensitive substring search in C/C++. My requirements are as follows:</p>
<ul>
<li>Should behave like strstr() (i.e. return a pointer to the match point).</li>
<li>Must be case-insensitive (doh).</li>
<li>Must support the current locale.</li>
<li>Must be available on Windows (MSVC++ 8.0) or easily portable to Windows (i.e. from an open source library).</li>
</ul>
<p>Here is the current implementation I am using (taken from the GNU C Library):</p>
<pre><code>/* Return the offset of one string within another.
Copyright (C) 1994,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/*
* My personal strstr() implementation that beats most other algorithms.
* Until someone tells me otherwise, I assume that this is the
* fastest implementation of strstr() in C.
* I deliberately chose not to comment it. You should have at least
* as much fun trying to understand it, as I had to write it :-).
*
* Stephen R. van den Berg, berg@pool.informatik.rwth-aachen.de */
/*
* Modified to use table lookup instead of tolower(), since tolower() isn't
* worth s*** on Windows.
*
* -- Anders Sandvig (anders@wincue.org)
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ctype.h>
#include <string.h>
typedef unsigned chartype;
char char_table[256];
void init_stristr(void)
{
int i;
char string[2];
string[1] = '\0';
for (i = 0; i < 256; i++)
{
string[0] = i;
_strlwr(string);
char_table[i] = string[0];
}
}
#define my_tolower(a) ((chartype) char_table[a])
char *
my_stristr (phaystack, pneedle)
const char *phaystack;
const char *pneedle;
{
register const unsigned char *haystack, *needle;
register chartype b, c;
haystack = (const unsigned char *) phaystack;
needle = (const unsigned char *) pneedle;
b = my_tolower (*needle);
if (b != '\0')
{
haystack--; /* possible ANSI violation */
do
{
c = *++haystack;
if (c == '\0')
goto ret0;
}
while (my_tolower (c) != (int) b);
c = my_tolower (*++needle);
if (c == '\0')
goto foundneedle;
++needle;
goto jin;
for (;;)
{
register chartype a;
register const unsigned char *rhaystack, *rneedle;
do
{
a = *++haystack;
if (a == '\0')
goto ret0;
if (my_tolower (a) == (int) b)
break;
a = *++haystack;
if (a == '\0')
goto ret0;
shloop:
;
}
while (my_tolower (a) != (int) b);
jin:
a = *++haystack;
if (a == '\0')
goto ret0;
if (my_tolower (a) != (int) c)
goto shloop;
rhaystack = haystack-- + 1;
rneedle = needle;
a = my_tolower (*rneedle);
if (my_tolower (*rhaystack) == (int) a)
do
{
if (a == '\0')
goto foundneedle;
++rhaystack;
a = my_tolower (*++needle);
if (my_tolower (*rhaystack) != (int) a)
break;
if (a == '\0')
goto foundneedle;
++rhaystack;
a = my_tolower (*++needle);
}
while (my_tolower (*rhaystack) == (int) a);
needle = rneedle; /* took the register-poor approach */
if (a == '\0')
break;
}
}
foundneedle:
return (char*) haystack;
ret0:
return 0;
}</code></pre>
<p>Can you make this code faster, or do you know of a better implementation?</p>
<p><strong>Note:</strong> I noticed that the GNU C Library now has <a href="http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/string/strstr.c?rev=1.2&content-type=text/x-cvsweb-markup&cvsroot=glibc" rel="nofollow noreferrer">a new implementation of <code>strstr()</code></a>, but I am not sure how easily it can be modified to be case-insensitive, or if it is in fact faster than the old one (in my case). I also noticed that <a href="http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/wcsmbs/wcsstr.c?rev=1.4&content-type=text/x-cvsweb-markup&cvsroot=glibc" rel="nofollow noreferrer">the old implementation is still used for wide character strings</a>, so if anyone knows why, please share.</p>
<p><strong>Update</strong></p>
<p>Just to make things clear—in case it wasn't already—I didn't write this function, it's a part of the GNU C Library. I only modified it to be case-insensitive.</p>
<p>Also, thanks for the tip about <code>strcasestr()</code> and checking out other implementations from other sources (like OpenBSD, FreeBSD, etc.). It seems to be the way to go. The code above is from 2003, which is why I posted it here in hope for a better version being available, which apparently it is. :)</p>
| [
{
"answer_id": 211561,
"author": "Chris Young",
"author_id": 9417,
"author_profile": "https://Stackoverflow.com/users/9417",
"pm_score": 2,
"selected": false,
"text": "char_table[i] = tolower(i);\n"
},
{
"answer_id": 211859,
"author": "freespace",
"author_id": 8297,
"... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1709/"
] |
211,536 | <p>Me and some friends are writing a MORPG in Java, and we would like to use a scripting language to, eg. to create quests.</p>
<p>We have non experience with scripting in Java. We have used Python, but we are very inexperienced with it. One of us also have used Javascript. </p>
<p>What scripting language should we use?
What scripting language should we not use? </p>
| [
{
"answer_id": 211555,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 3,
"selected": false,
"text": "javax.script"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26567/"
] |
211,583 | <p>I am using a microcontroller with a C51 core. I have a fairly timeconsuming and large subroutine that needs to be called every 500ms. An RTOS is not being used. </p>
<p>The way I am doing it right now is that I have an existing Timer interrupt of 10 ms. I set a flag after every 50 interrupts that is checked for being true in the main program loop. If the Flag is true the subroutine is called. The issue is that by the time the program loop comes round to servicing the flag, it is already more than 500ms,sometimes even >515 ms in case of certain code paths. The time taken is not accurately predictable.</p>
<p>Obviously, the subroutine cannot be called from inside the timer interrupt due to that large time it takes to execute.The subroutine takes 50ms to 89ms depending upon various conditions.</p>
<p>Is there a way to ensure that the subroutine is called in exactly 500ms each time?</p>
| [
{
"answer_id": 211893,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": true,
"text": "#define FUDGE_MARGIN 2 //In 10ms increments\n\nvolatile unsigned int ticks = 0;\n\nvoid timer_10ms_interrupt( void ) { tick... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27795/"
] |
211,586 | <p>I've recently heard about the <a href="http://msdn.microsoft.com/en-us/library/bb204633(VS.85).aspx" rel="nofollow noreferrer">CaptureStackBackTrace</a> function by reading <a href="https://stackoverflow.com/questions/105659/how-can-one-grab-a-stack-trace-in-c">this post</a>. I cannot find it in any of my Visual Studio 2005 header files however, and I'm guessing (from the MSDN URL which mentions VS.85) that this may only be a Visual Studio 2008 thing.</p>
<p>Is there a way, perhaps by manually finding the entry point in a system DLL somewhere, to get this function under Visual Studio 2005?</p>
| [
{
"answer_id": 211719,
"author": "pauldoo",
"author_id": 755,
"author_profile": "https://Stackoverflow.com/users/755",
"pm_score": 2,
"selected": false,
"text": "typedef USHORT (WINAPI *CaptureStackBackTraceType)(__in ULONG, __in ULONG, __out PVOID*, __out_opt PULONG);\nCaptureStackBackT... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/755/"
] |
211,611 | <p>I have a <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="noreferrer">Windows Forms</a> <a href="http://www.google.com/search?hl=en&q=TreeView%20msdn&btnG=Search" rel="noreferrer">TreeView</a> (node, subnodes). Each node contains some additional information in its Tag. Also, each nodes maps a file on the disk. What's the easiest way copy/cut/paste nodes/files in C#?</p>
<p>It would be nice to have some sample code.</p>
| [
{
"answer_id": 211619,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 6,
"selected": false,
"text": "StringCollection paths = new StringCollection();\npaths.Add(\"f:\\\\temp\\\\test.txt\");\npaths.Add(\"f:\\\\temp\\\\t... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,612 | <p>There are a dozen Rails plugins whose goal is to replace fixtures in testing. Here are a few I can think of:</p>
<ul>
<li>fixture replacement</li>
<li>factory girl</li>
<li>factories and workers</li>
<li>rails scenarios</li>
<li>fixture-scenarios</li>
<li>object daddy</li>
</ul>
<p>There are probably others. Which of these plugins do you prefer and why?</p>
| [
{
"answer_id": 211649,
"author": "Codebeef",
"author_id": 12037,
"author_profile": "https://Stackoverflow.com/users/12037",
"pm_score": 3,
"selected": false,
"text": "# spec/factory.rb\nmodule Factory\n def self.create_offer(options={})\n Offer.create({\n :code => Faker::Lorem.w... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11082/"
] |
211,616 | <p>Objective-C is getting wider use due to its use by Apple for Mac OS X and iPhone development. What are some of your favourite "hidden" features of the Objective-C language?</p>
<ul>
<li>One feature per answer.</li>
<li>Give an example and short description of the feature, not just a link to documentation.</li>
<li>Label the feature using a title as the first line.</li>
</ul>
| [
{
"answer_id": 211672,
"author": "splattne",
"author_id": 6461,
"author_profile": "https://Stackoverflow.com/users/6461",
"pm_score": 4,
"selected": false,
"text": "@interface CustomNSApplication : NSApplication\n@end\n\n@implementation CustomNSApplication\n- (void) setMainMenu: (NSMenu*... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2438/"
] |
211,621 | <p>I want to impersonate other user in Windows. For example:
I create a directory with permission only for user A and for the administrators, when logon with user B and run .exe I want to impersonate user A to have permission to edit/remove/insert in that specific directory.</p>
<p>I found this: <a href="http://msdn.microsoft.com/en-us/library/aa374731(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa374731(VS.85).aspx</a></p>
| [
{
"answer_id": 211811,
"author": "brianb",
"author_id": 27892,
"author_profile": "https://Stackoverflow.com/users/27892",
"pm_score": 0,
"selected": false,
"text": "AcquireCredentialsHandle()\nInitializeSecurityContext()\nAcceptSecurityContext()\nCompleteAuthToken()\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,622 | <p>I would like to have some kind of catch-all exceptions mechanism in the root of my code, so when an app terminates unexpectedly I can still provide some useful logging.</p>
<p>Something along the lines of</p>
<pre><code>static void Main () {
if (Debugger.IsAttached)
RunApp();
else {
try {
RunApp();
}
catch (Exception e) {
LogException(e);
throw;
}
}
}
</code></pre>
<p>While this all works fine, my problem is when I want to attach the debugger after the exception has been raised.</p>
<p>Since the exception escapes to the runtime, windows will prompt to attach visual studio, except, since it has been rethrown, all locals and parameters further up the stack have been lost.</p>
<p>Is there anyway to log these exceptions, while still providing a way to attach the debugger and retain all useful information?</p>
| [
{
"answer_id": 211641,
"author": "massimogentilini",
"author_id": 11673,
"author_profile": "https://Stackoverflow.com/users/11673",
"pm_score": 0,
"selected": false,
"text": "Exception e1 = e;\nLogException(e);\nthrow(e1);\n"
},
{
"answer_id": 211870,
"author": "Dan Goldstein... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28859/"
] |
211,629 | <p>How to remove the program icon from the Programs folder?</p>
| [
{
"answer_id": 211637,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": 3,
"selected": false,
"text": "File.Delete(path_to_lnk_file);\n"
},
{
"answer_id": 211657,
"author": "Isak Savo",
"author_id": 8521,... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,634 | <p>We have a Win32 application that hosts the .NET runtime and opens up .NET managed forms from the Win32 portion of the application.</p>
<p>These windows are always opened as modal windows.</p>
<p>On some machines, when these windows are closed, the Win32 window that lies behind does not get focus, but gets sent behind Word, Outlook, or whatever else you might have open.</p>
<p>Also, sometimes, if we open such a .NET form, then alt-tab to Word or some other application, and then click on the taskbar icon for our app, the Win32 window appear. This is of course still waiting for the modal .NET window to close, so it is of course unusable. If we alt-tab to something else and just minimize that other thing, then our .NET window reappears.</p>
<p>The inconsistent part is that this occurs on only some machines, and not all. On many machines, mine included, it works exactly as expected. Focus to the right window works every time.</p>
<p>I don't doubt we have done something wrong, but I can't figure out what the problem is.</p>
<p>Does anyone have any idea what I should be looking for? We've looked at the .NET runtimes installed, and since two such machines where it works on one but not the other are both developer machines, they contain the same service packs for .NET and so on.</p>
<hr>
<p><strong>Edit:</strong> Well, <a href="https://stackoverflow.com/users/7021/sam">@sam</a>, you were right in that we had some different setups in this lane. Both machines run Windows XP SP3, but mine was running classic windows theme, and the other was running the new XP theme. Changing theme on that other computer to classic removed the problem, but changing it back to the XP theme did not make it reappear.</p>
<p>So now we have two machines where it work, and the customer still has the problem, even though the customer apparently runs classic theme.</p>
| [
{
"answer_id": 211825,
"author": "thmsn",
"author_id": 28145,
"author_profile": "https://Stackoverflow.com/users/28145",
"pm_score": 0,
"selected": false,
"text": "Form2 form2 = new Form2();\nform2.ShowDialog();\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267/"
] |
211,648 | <p>I have a form, when I click on submit button, I want to communicate with the server and get something from the server to be displayed on the same page. Everything must be done in AJAX manner. How to do it in Google App Engine? If possible, I want to do it in JQuery.</p>
<p>Edit: The example in <a href="http://groups.google.com.my/group/google-appengine/browse_thread/thread/36dc8759dab4cc28?hl=en#" rel="nofollow noreferrer">code.google.com/appengine/articles/rpc.html</a> doesn't work on form. </p>
<hr>
<p>Edit: The rpc procedure <a href="http://groups.google.com.my/group/google-appengine/browse_thread/thread/36dc8759dab4cc28?hl=en#" rel="nofollow noreferrer">doesn't work for form</a>. </p>
| [
{
"answer_id": 220197,
"author": "Randy",
"author_id": 9361,
"author_profile": "https://Stackoverflow.com/users/9361",
"pm_score": 1,
"selected": false,
"text": "function jsonhandler(data) {\n // do stuff with the JSON data here\n}\n\nvar doajax = function () {\n arr = Object();\n ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
211,689 | <p>I'm using xsd.exe to make the C# classes for our settings. I have a setting that is per-server and per-database, so I want the class to behave like Dictionary<string, string[][]>. So I want to be able to say</p>
<pre><code>string serverName = "myServer";
int databaseId = 1;
FieldSettings fieldSettings = getFieldSettings();
string[] fields = fieldSettings[serverName][databaseId];
</code></pre>
<p>how do I represent that in XSD?</p>
| [
{
"answer_id": 211700,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 1,
"selected": false,
"text": "xsd"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15371/"
] |
211,693 | <p>What steps do I need to take to get HTML documentation automatically building via the build step in Visual Studio? I have all the comments in place and the comments.xml file being generated, and Sandcastle installed. I just need to know what to add to the post-build step in order to generate the docs.</p>
| [
{
"answer_id": 211710,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 3,
"selected": false,
"text": "<install-path>\\SandcastleBuilderConsole.exe ProjectName.shfb\n"
},
{
"answer_id": 5200822,
"author": "Chev",
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/986/"
] |
211,694 | <p>I am writing controls that work nice with JavaScript, but they have to work even without it. Now testing with selenium works fine for me. But all test with disabled JavaScript (in my browser) won't run with selenium. Is there a way to do automated test for this purpose?</p>
| [
{
"answer_id": 214739,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 2,
"selected": true,
"text": "use Test::More tests => 5;\nuse Test::WWW::Mechanize;\n\nmy $mech = Test::WWW::Mechanize->new;\n\n# Test you can get http:/... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,695 | <p>I would like to create a trivial one-off Python object to hold some command-line options. I would like to do something like this:</p>
<pre><code>options = ??????
options.VERBOSE = True
options.IGNORE_WARNINGS = False
# Then, elsewhere in the code...
if options.VERBOSE:
...
</code></pre>
<p>Of course I could use a dictionary, but <code>options.VERBOSE</code> is more readable and easier to type than <code>options['VERBOSE']</code>.</p>
<p>I <em>thought</em> that I should be able to do</p>
<pre><code>options = object()
</code></pre>
<p>, since <code>object</code> is the base type of all class objects and therefore should be something like a class with no attributes. But it doesn't work, because an object created using <code>object()</code> doesn't have a <code>__dict__</code> member, and so one cannot add attributes to it:</p>
<pre><code>options.VERBOSE = True
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'VERBOSE'
</code></pre>
<p>What is the simplest "pythonic" way to create an object that can be used this way, preferably without having to create an extra helper class?</p>
| [
{
"answer_id": 211774,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 4,
"selected": false,
"text": "import collections\nopt=collections.namedtuple('options','VERBOSE IGNORE_WARNINGS')\nmyoptions=opt(True, False)\n\n>>> myoptio... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24478/"
] |
211,703 | <p>Is this doable in either IE7 or Firefox?</p>
| [
{
"answer_id": 211732,
"author": "Pistos",
"author_id": 28558,
"author_profile": "https://Stackoverflow.com/users/28558",
"pm_score": 2,
"selected": false,
"text": "$('#myelement.').offset();\n"
},
{
"answer_id": 211737,
"author": "Greg",
"author_id": 24181,
"author_p... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
211,715 | <p>How does one execute some VBA code periodically, completely automated?</p>
| [
{
"answer_id": 211742,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 1,
"selected": false,
"text": "Sub MyTimer()\n Application.Wait Now + TimeValue(\"00:00:05\")\n MsgBox (\"5 seconds\")\nEnd Sub\n"
},
{
"ans... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9095/"
] |
211,717 | <p>Is there a function in Common Lisp that takes a string as an argument and returns a keyword?</p>
<p>Example: <code>(keyword "foo")</code> -> <code>:foo</code></p>
| [
{
"answer_id": 211786,
"author": "Jonathan Wright",
"author_id": 28840,
"author_profile": "https://Stackoverflow.com/users/28840",
"pm_score": -1,
"selected": false,
"text": "(intern \"foo\" \"KEYWORD\") -> :foo\n"
},
{
"answer_id": 211806,
"author": "C. K. Young",
"autho... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18480/"
] |
211,718 | <p>Why doesn't the code below work? The idea is that the page checks to see if the dropdown variable has changes since you last refreshed the page.</p>
<pre><code> <logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:equal name="Result" value = "-1">
<bean:define id="DropDownValue" name="smlMoverDetailForm" property="moverChangeType"
type="java.lang.String" toScope = "session" />
</logic:equal>
<-- when you fisrt access this page from the above are run -->
<bean:define id="NewDropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "sess
<-- this happens everytime the page is refreshed-->
<logic:equal name= DropDownValue value = NewDropDownValue>
<bean:define id="JOININGDATE" name="smlMoverDetailForm"
property="empFDJoiningDate" type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:notEqual name="DropDownValue" value = "NewDropDownValue">
<bean:define id="DropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "session"
/>
</logic:notEqual>
</code></pre>
| [
{
"answer_id": 211797,
"author": "Sietse",
"author_id": 6400,
"author_profile": "https://Stackoverflow.com/users/6400",
"pm_score": 0,
"selected": false,
"text": "<logic:equal name= DropDownValue value = NewDropDownValue>\n"
},
{
"answer_id": 216926,
"author": "Olaf Kock",
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,741 | <p>The string formatting concept found in <strong>sprintf</strong> can be found in almost any language today <em>(you know, smothering a string with %s %d %f etc. and providing a list of variables to fill their places)</em>. </p>
<p><strong>Which langugage was it originally that had a library function or language construct which offered this functionality?</strong></p>
<p>Please specify some kind of source reference to confirm your claim, so that we avoid pure speculation or guessing.</p>
<p>Regards</p>
<p>Robert</p>
| [
{
"answer_id": 211814,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": false,
"text": "writef()"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7891/"
] |
211,758 | <p>I have a sproc that returns a single line and column with a text, I need to set this text to a variable, something like:</p>
<pre><code>declare @bla varchar(100)
select @bla = sp_Name 9999, 99989999, 'A', 'S', null
</code></pre>
<p>but of course, this code doesn't work...</p>
<p>thanks!</p>
| [
{
"answer_id": 211778,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 4,
"selected": false,
"text": "CREATE PROCEDURE dbo.sp_Name\n @In INT,\n @Out VARCHAR(100) OUTPUT\n\nAS\nBEGIN\n SELECT @Out = 'Test'\nEND\nGO\n"
... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17648/"
] |
211,760 | <p>Is there any way to run ASDoc on your project via the Flex Builder UI? Or, is there a good (preferably free) plugin that will do so?</p>
<p>If there is no UI for it, does someone have a link to a tutorial on how to set it up to be automatic when I build my project, maybe via Ant (which I've never used, but am more than happy to try) or something?
(sorry for the multi-part question)</p>
| [
{
"answer_id": 6752185,
"author": "Will",
"author_id": 852622,
"author_profile": "https://Stackoverflow.com/users/852622",
"pm_score": 2,
"selected": false,
"text": "${project_loc}"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5421/"
] |
211,761 | <p>For a Silverlight 2 webapp. I added a combobox. I have an IEnumerable as Itemsource to populate the combobox. Works fine.</p>
<p>But I would like to add an extra item ("please select a....") to the combobox, anyone an idea how this can be done using the Silverlight 2 combobox.</p>
<p>Any more info about using a template for the ComboxboxItems is welcome as well.</p>
| [
{
"answer_id": 313815,
"author": "David Casey",
"author_id": 36588,
"author_profile": "https://Stackoverflow.com/users/36588",
"pm_score": 0,
"selected": false,
"text": "List<>"
},
{
"answer_id": 2861205,
"author": "Sitab Bhandari",
"author_id": 344505,
"author_profil... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,769 | <p>Coming from a Ruby background, I'm used to writing all my code using classes with methods and such. I do know javascript quite well, but I'm new to jQuery and its best practices.</p>
<p>Obviously there are a million ways to simulate classes in javascript. But, what is the actual jQuery community REALLY using in the real world?</p>
<p>Specific examples would be ideal. Or links to real production code. Links to fictional ideal code would also be helpful.</p>
<p>Thanks!</p>
| [
{
"answer_id": 222278,
"author": "Zac",
"author_id": 5630,
"author_profile": "https://Stackoverflow.com/users/5630",
"pm_score": 2,
"selected": false,
"text": "var Widget = {\n\n sound:'bleep',\n\n load:function(){\n\n // do stuff here that doesn't need to wait until the DOM... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2483628/"
] |
211,795 | <p>What are the established coding standards for JavaScript?</p>
| [
{
"answer_id": 214256,
"author": "Remy Sharp",
"author_id": 22617,
"author_profile": "https://Stackoverflow.com/users/22617",
"pm_score": 5,
"selected": false,
"text": "return // injected semicolon, therefore returns 'undefined'\n{\n javascript : \"fantastic\"\n}; // object constructs... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25174/"
] |
211,800 | <p>I have no idea. This causes seemingly random time-outs. These in turn break the flash that i am loading it into. Has anyone seen anything like this before?</p>
<pre><code><?php
require_once("../includes/class.database.php");
require_once("../includes/dbConnectInfo.inc");
require_once("../includes/functions.php");
include("../includes/conn.php");
$cat = $_GET['category'];
$result = mysql_query("SELECT * FROM media WHERE related_page_id=4 && type='copy' ORDER BY id ASC LIMIT 6");
$media = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$media .= "<content>\n";
while($row = mysql_fetch_array($result)) {
$media .="<member>\n";
$body = $row[copy];
if($row[title] == "") {
$media .= "<title><![CDATA[";
$media .= "Team";
$media .="]]></title>\n";
} elseif ($row['path']=="") {
$name = explode("/",$row[title],2);
$media .= "<name><![CDATA[";
$media .= $name[0];
$media .="]]></name>\n";
$media .= "<job><![CDATA[";
$media .= $name[1];
$media .="]]></job>\n";
}
if($body !="") {
$media .="<bio><![CDATA[";
$media .= $body;
$media .= "]]></bio>\n";
}
$something = $row['id'];
$result1 = mysql_query("SELECT * FROM media WHERE assets='$something'");
$media .= "<images>";
while($row1 = mysql_fetch_array($result1)) {
$img = explode("/",$row1[path],2);
$media .= "<image url='$img[1]' />";
}
$media .= "</images>\n";
$media .="</member>\n";
}
$media .= "</content>";
echo $media;
?>
</code></pre>
| [
{
"answer_id": 211807,
"author": "Thomas Owens",
"author_id": 572,
"author_profile": "https://Stackoverflow.com/users/572",
"pm_score": 3,
"selected": true,
"text": "set_time_limit(0);"
},
{
"answer_id": 211823,
"author": "Greg",
"author_id": 24181,
"author_profile": ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
211,819 | <p>When doing a <code>cvs update</code>, you get a nice summary of the state of the repository, for example:</p>
<pre><code>M src/file1.txt
M src/file2.txt
C src/file3.txt
A src/file4.txt
? src/file5.txt
</code></pre>
<p>Is there a way to get this without actually updating? I know there is <code>cvs status</code>, but this is way to verbose:</p>
<pre><code>===================================================================
File: file6.txt Status: Up-to-date
Working revision: 1.2
Repository revision: 1.2 /var/cvs/cvsroot/file6.txt,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
</code></pre>
<p>I could of course make a script to do the transformation from the latter to the former, but it seems a waste of time since cvs can obviously produce the former.</p>
| [
{
"answer_id": 211821,
"author": "jmcnamara",
"author_id": 10238,
"author_profile": "https://Stackoverflow.com/users/10238",
"pm_score": 6,
"selected": true,
"text": "cvs -q -n update\n"
},
{
"answer_id": 211915,
"author": "Pistos",
"author_id": 28558,
"author_profile... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3102/"
] |
211,834 | <p>OK... I'm a VB.NET WinForms guy trying to understand WPF and all of its awesomeness. I'm writing a basic app as a learning experience, and have been reading lots of information and watching tutorial videos, but I just can't get off the ground with simple DataBinding, and I know I'm missing some basic concept. As much as I'd love it, I haven't had that "Aha!" moment when reviewing source code yet.</p>
<p>So... In my Window class I defined a custom string Property. When I go into Blend, I try to databind my TextBox's Text to this property, but my Property doesn't show up in Blend as something that available for Binding to.</p>
<p>Can someone tell me what I need to add to my code/XAML below... and most importantly why?</p>
<p>My XAML:</p>
<pre><code><Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBox Text="How do I Bind my SomeText property here?"></TextBox>
</Grid>
</Window>
</code></pre>
<p>My Window Code:</p>
<pre><code>Class Window1
Private _sometext As String = "Hello World"
Public Property SomeText() As String
Get
Return _sometext
End Get
Set(ByVal value As String)
_sometext = value
End Set
End Property
End Class
</code></pre>
| [
{
"answer_id": 211990,
"author": "Samuel Jack",
"author_id": 1727,
"author_profile": "https://Stackoverflow.com/users/1727",
"pm_score": 4,
"selected": true,
"text": "<Window x:Class=\"Window1\" \n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" \n xmlns:x... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/641985/"
] |
211,839 | <p>We get this error in Visual Studio 2005 and TFS very often.</p>
<p>Can anyone help us pinpoint the cause for this message?</p>
<p>The full message is:</p>
<blockquote>
<p>There appears to be a discrepancy between the solution's source
control information about some project(s) and the information in the
project file(s).</p>
<p>To resolve this discrepancy it will be necessary to check out the
project file(s) and update them. If the check out fails, however, and
the solution is closed without saving, you will see this warning again
the next time you open the solution.</p>
</blockquote>
<p>Clicking OK eventually lead to a checkout box where it wants to check out a whole list of project files. However, the "Change source control" window doesn't show anything wrong, and saving everything and just checking it back in just ends up as "Nothing was changed, undoing everything" type of message.</p>
<p><strong>Edit:</strong> You're right, <a href="https://stackoverflow.com/users/2915/adam-davis">@Adam</a>, we have converted from VSS, but we went through such a procedure to cleanup the bindings when we did this a while ago and everything was peachy. The error has started cropping up lately.</p>
| [
{
"answer_id": 14160013,
"author": "user1948985",
"author_id": 1948985,
"author_profile": "https://Stackoverflow.com/users/1948985",
"pm_score": 0,
"selected": false,
"text": "SccProjectUniqueName6 = Project1\\\\Project1.csproj\nSccProjectName6 = \\u0022$/Project1\\u0022,\\u0020HSBAAAAA\... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267/"
] |
211,875 | <p>I have a string column in a database table which maps to an Enum in code. In my dbml file when I set the "Type" to <code>MyTypes.EnumType</code> I get the following error:</p>
<blockquote>
<p>Error 1 DBML1005: Mapping between DbType 'VarChar(50) NOT NULL' and
Type 'MyTypes.EnumType' in Column 'EnumCol' of Type 'Table1' is not
supported.</p>
</blockquote>
<p>This question:
<a href="https://stackoverflow.com/questions/4939/linq-to-sql-strings-to-enums">LINQ to SQL strings to enums</a>
indicates that what I am trying to do is possible, but how is it done?</p>
| [
{
"answer_id": 211894,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": true,
"text": "global::"
},
{
"answer_id": 1583931,
"author": "Pure.Krome",
"author_id": 30674,
"author_profile":... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211875",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28889/"
] |
211,885 | <p>When a script runs under Apache, I insert <code>$_SERVER['SERVER_NAME']</code> value into an error reporting e-mail message.</p>
<p>However, if a Web script forks a "worker" job with <code>nohup php ...</code>, <code>$_SERVER['SERVER_NAME']</code> appears to be empty there. Thus, if an error occurs, it's reported without a host name.</p>
<p>Can I reliably get the host name by means of PHP, without calling Unix <code>hostname</code> command? </p>
| [
{
"answer_id": 216417,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "_GLOBALS['MACHINENAME']"
},
{
"answer_id": 17710031,
"author": "ghbarratt",
"author_id": 729759,
"author_p... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6430/"
] |
211,934 | <p>I'm sure this problem has been solved before and I'm curious how its done. I have code in which, when run, I want to scan the contents of a directory and load in functionality.</p>
<p>Specifically, I am working with a scripting engine that I want to be able to add function calls to. I want the core engine to provide very limited functionality. The user should be able to add additional functions through 3rd party libraries, which I want the engine to scan for and load. How is this done?</p>
| [
{
"answer_id": 211949,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "LoadLibrary"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/211934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10093/"
] |
211,958 | <p><strong>EDIT: I missed a crucial point: .NET 2.0</strong></p>
<p>Consider the case where I have a list of unsorted items, for the sake of simplicity of a type like this:</p>
<pre><code>class TestClass
{
DateTime SomeTime;
decimal SomePrice;
// constructor
}
</code></pre>
<p>I need to create a report-like output, where the total prices for each day are accumulated. There should be one line for each item, folled by the appropriate summary lines.</p>
<p>Take this test data:</p>
<pre><code>List<TestClass> testList = new List<TestClass> {
new TestClass(new DateTime(2008,01,01), 12),
new TestClass(new DateTime(2007,01,01), 20),
new TestClass(new DateTime(2008,01,01), 18)
};
</code></pre>
<p>The desired output would be something like this:</p>
<pre><code>2007-01-01:
20
Total: 20
2008-01-01:
12
18
Total: 30
</code></pre>
<p>What's the best way to approach such scenarios? In the case of such a list, I would implement the IComparable interface for TestClass, so that the list can be sorted.</p>
<p>To create the report itself, something like this could be used (let's assume that we have methods for tasks like accumulating the prices, keeping track of the current date etc):</p>
<pre><code>for (int i=0;i<testList.Count;i++)
{
if (IsNewDate(testList[i]))
{
CreateSummaryLine();
ResetValuesForNewDate();
}
AddValues(testList[i]);
}
// a final summary line is needed to include the data for the last couple of items.
CreateSummaryLine();
</code></pre>
<p>This works alright, but I have a strange feeling as far as the second "CreateSummaryLines" is concerned.</p>
<p>In what ways do you handle such situations (especially considering the fact, the we need to work with a List<> of items rather than a pre-categorized Dictionary or something like that)?</p>
| [
{
"answer_id": 211978,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": " var groups = from row in testList\n group row by row.SomeTime;\n foreach (var group in... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17378/"
] |
211,971 | <p>WPF, Browserlike app.<br>
I got one page containing a ListView. After calling a PageFunction I add a line to the ListView, and want to scroll the new line into view:</p>
<pre><code> ListViewItem item = ItemContainerGenerator.ContainerFromIndex(index) as ListViewItem;
if (item != null)
ScrollIntoView(item);
</code></pre>
<p>This works. As long as the new line is in view the line gets the focus like it should.</p>
<p>Problem is, things don't work when the line is not visible.<br>
If the line is not visible, there is no ListViewItem for the line generated, so ItemContainerGenerator.ContainerFromIndex returns null.</p>
<p>But without the item, how do I scroll the line into view? Is there any way to scroll to the last line (or anywhere) without needing an ListViewItem?</p>
| [
{
"answer_id": 211984,
"author": "EFrank",
"author_id": 28572,
"author_profile": "https://Stackoverflow.com/users/28572",
"pm_score": 5,
"selected": true,
"text": "null"
},
{
"answer_id": 213095,
"author": "decasteljau",
"author_id": 12082,
"author_profile": "https://... | 2008/10/17 | [
"https://Stackoverflow.com/questions/211971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] |
212,006 | <p>I have a c++ header file containing a class.
I want to use this class in several projects, bu I don't want to create a separate library for it, so I'm putting both methods declarations and definitions in the header file: </p>
<pre><code>// example.h
#ifndef EXAMPLE_H_
#define EXAMPLE_H_
namespace test_ns{
class TestClass{
public:
void testMethod();
};
void TestClass::testMethod(){
// some code here...
}
} // end namespace test_ns
#endif
</code></pre>
<p>If inside the same project I include this header from more than one cpp file, I get an error saying "<code>multiple definition of test_ns::TestClass::testMethod()</code>", while if I put the method definition inside the class body this does not happen:</p>
<pre><code>// example.h
#ifndef EXAMPLE_H_
#define EXAMPLE_H_
namespace test_ns{
class TestClass{
public:
void testMethod(){
// some code here...
}
};
} // end namespace test_ns
#endif
</code></pre>
<p>Since the class is defined inside a namespace, shouldn't the two forms be equivalent? Why is the method considered to be defined twice in the first case?</p>
| [
{
"answer_id": 212019,
"author": "QBziZ",
"author_id": 11572,
"author_profile": "https://Stackoverflow.com/users/11572",
"pm_score": 5,
"selected": false,
"text": "namespace test_ns{\n\nclass TestClass{\npublic:\n inline void testMethod();\n};\n\nvoid TestClass::testMethod(){\n // ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15622/"
] |
212,028 | <p>I have a C# method which accepts a Predicate<Foo> and returns a list of matching items...</p>
<pre><code>public static List<Foo> FindAll( Predicate<Foo> filter )
{
...
}
</code></pre>
<p>The filter will often be one of a common set...</p>
<pre><code>public static class FooPredicates
{
public static readonly Predicate<Foo> IsEligible = ( foo => ...)
...
}
</code></pre>
<p>...but may be an anonymous delegate.</p>
<p>I'd now like to have this method cache its results in the ASP.NET cache, so repeated calls with the same delegate just return the cached result. For this, I need to create a cache key from the delegate. Will Delegate.GetHashCode() produce sensible results for this purpose? Is there some other member of Delegate that I should look at? Would you do this another way entirely?</p>
| [
{
"answer_id": 215035,
"author": "stevemegson",
"author_id": 25028,
"author_profile": "https://Stackoverflow.com/users/25028",
"pm_score": 2,
"selected": false,
"text": "public override int GetHashCode()\n{\n return base.GetType().GetHashCode();\n}\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/212028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25028/"
] |
212,031 | <p>I would like to break a long line of text assigned to the standard Label widget in GWT.
I was experimenting with inline <code><br /></code> elements but with no success.</p>
<p>Something like this: </p>
<pre><code>label = "My very very very long<br />long long text"
</code></pre>
| [
{
"answer_id": 286593,
"author": "smerten",
"author_id": 37288,
"author_profile": "https://Stackoverflow.com/users/37288",
"pm_score": 2,
"selected": false,
"text": "<br/>"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/212031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6482/"
] |
212,048 | <p>I'm using the ListView control (ASP.NET 2008) to show a bunch of lines of data, and at the bottom I want some totals. I was initially going to define the header and footer in the LayoutTemplate and get the totals with some local function, i.e. <%#GetTheSum()%>, but it appears that the LayoutTemplate does not process the <%#...%> syntax.</p>
<p>Another thought would be to put a Label in the LayoutTemplate and use FindControl to update it. Not sure if that's possible (will try shortly).</p>
<p>What's the best way to show totals using a ListView?</p>
<p>UPDATE: Solution <a href="https://stackoverflow.com/questions/212048/displaying-totals-in-the-listview-layouttemplate#212308">here</a>.</p>
| [
{
"answer_id": 212126,
"author": "craigmoliver",
"author_id": 12252,
"author_profile": "https://Stackoverflow.com/users/12252",
"pm_score": 1,
"selected": false,
"text": "<asp:Literal ID=\"litTotal\" runat=\"server\" />\n"
},
{
"answer_id": 212308,
"author": "gfrizzle",
"... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] |
212,050 | <p>In a spring configuration, what is the difference between using name vs id? I'm aware that XML restricts the "id" attribute to be unique in a document and limits the characters for using in the id. But otherwise when declaring a bean, what is the difference between using the "name" attribute vs the "id" attribute?</p>
| [
{
"answer_id": 212126,
"author": "craigmoliver",
"author_id": 12252,
"author_profile": "https://Stackoverflow.com/users/12252",
"pm_score": 1,
"selected": false,
"text": "<asp:Literal ID=\"litTotal\" runat=\"server\" />\n"
},
{
"answer_id": 212308,
"author": "gfrizzle",
"... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6580/"
] |
212,089 | <p>This is the way I read file:</p>
<pre><code> public static string readFile(string path)
{
StringBuilder stringFromFile = new StringBuilder();
StreamReader SR;
string S;
SR = File.OpenText(path);
S = SR.ReadLine();
while (S != null)
{
stringFromFile.Append(SR.ReadLine());
}
SR.Close();
return stringFromFile.ToString();
}
</code></pre>
<p>The problem is it so long (the .txt file is about 2.5 megs). Took over 5 minutes. Is there a better way?</p>
<p><strong>Solution taken</strong></p>
<pre><code> public static string readFile(string path)
{
return File.ReadAllText(path);
}
</code></pre>
<p>Took less than 1 second... :)</p>
| [
{
"answer_id": 212102,
"author": "pian0",
"author_id": 5692,
"author_profile": "https://Stackoverflow.com/users/5692",
"pm_score": 3,
"selected": false,
"text": "return System.IO.File.ReadAllText(path);\n"
},
{
"answer_id": 212104,
"author": "Konrad Rudolph",
"author_id":... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
212,115 | <p>What is the best method for displaying major/minor versions in a C# console application?</p>
<p>The <code>System.Windows.Forms</code> namespace includes a <code>ProductVersion</code> class that can be used to display the name/version information set via the Visual Studio project properties (Assembly Information). As such, here is my current mechanism:</p>
<pre class="lang-cs prettyprint-override"><code>Console.WriteLine("{0} ({1})",
System.Windows.Forms.Application.ProductName,
System.Windows.Forms.Application.ProductVersion);
</code></pre>
<p>Why is this part of <code>Forms</code>? Is this appropriate for a Console application?</p>
| [
{
"answer_id": 212135,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": true,
"text": "Assembly.GetExecutingAssembly().GetName().Version\n"
},
{
"answer_id": 213083,
"author": "Joe",
"author_id": 13... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/644/"
] |
212,124 | <p>Some friends and colleagues of mine have a little running contest to find or write the longest class/variable/property/method names possible. Keep in mind, we try to be good boys and girls and keep the naming intelligible and concise, while still explaining what the thing does via its name.</p>
<p>Sometimes it just doesn't happen though. Have you run in to this? I'd just like to see what's out there. (Maybe my friends and I aren't as crazy as we think)</p>
<p>Note: I'm not looking for <strong>bad</strong> naming. That's already <a href="https://stackoverflow.com/questions/143701/what-is-the-worst-classvariablefunction-name-you-have-ever-encountered">here</a>. I'm looking for <strong>good</strong> naming that just got a little long.</p>
| [
{
"answer_id": 212132,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 1,
"selected": false,
"text": "NSString.completePathInfoString:caseSensitive:matchesToArray:filterType\nNSString.stringByAddingPercentEscapesUsingEn... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8360/"
] |
212,125 | <p>Let's say I have a model like this</p>
<pre><code>class Foo(db.Model):
id = db.StringProperty()
bar = db.StringProperty()
baz = db.StringProperty()
</code></pre>
<p>And I'm going a GqlQuery like this</p>
<pre><code>foos = db.GqlQuery("SELECT * FROM Foo")
</code></pre>
<p><strong>I want to take the results of the GqlQuery and turn into some sort of JSON string that I can manipulate from different languages.</strong></p>
<hr>
<p>Here's how I'm doing it now</p>
<ol>
<li><p>Add a method to the <strong>Foo</strong> class that converts it into a dictionary</p>
<pre><code>def toDict(self):
return {
'id': self.id,
'bar': self.bar,
'baz': self'baz
}
</code></pre></li>
<li><p>Loop through the GqlQuery results and manually add each Foo instance to a dictionary</p>
<pre><code>fooDict = {}
for foo in foos:
fooDict[foo.id] = foo.toDict()
return simplejson.dumps(fooDict)
</code></pre></li>
</ol>
<hr>
<p>My approach above works but it feels kind of gross.</p>
<p>Is there a cleaner, more "Pythonic" way to handle this?</p>
<p><strong>The end format doesn't have to be exactly what I've done above. It just has to be something that converts nicely to JSON so I can deal with it from Javascript/PHP/whatever.</strong></p>
| [
{
"answer_id": 212351,
"author": "Alex Coventry",
"author_id": 1941213,
"author_profile": "https://Stackoverflow.com/users/1941213",
"pm_score": 1,
"selected": false,
"text": "class Foo:\n id = db.StringProperty() # etc.\n json_attrs = 'id bar baz'.split()\n\n# Depending on how eas... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] |
212,134 | <p>I need to scale calls into Tomcat and it's been suggested to launch threads internally. Has anyone needed to do this and, if so, what solutions did they come up with?</p>
| [
{
"answer_id": 212156,
"author": "johnstok",
"author_id": 27929,
"author_profile": "https://Stackoverflow.com/users/27929",
"pm_score": 1,
"selected": false,
"text": "java.util.concurrency"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/212134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
212,198 | <p>What is the purpose of the <code>Using</code> block in C#? How is it different from a local variable?</p>
| [
{
"answer_id": 212204,
"author": "Sam",
"author_id": 7021,
"author_profile": "https://Stackoverflow.com/users/7021",
"pm_score": 7,
"selected": false,
"text": "Using"
},
{
"answer_id": 212210,
"author": "plinth",
"author_id": 20481,
"author_profile": "https://Stackove... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17715/"
] |
212,201 | <p>A little benchmark with ASP.NET MVC. Viewpage code:</p>
<pre><code> public string Bechmark(Func<string> url)
{
var s = new Stopwatch();
var n = 1000;
s.Reset();
s.Start();
for (int i = 0; i < n; i++)
{
var u = url();
}
s.Stop();
return s.ElapsedMilliseconds + " ms, " + ((s.ElapsedMilliseconds) / (float)n) + " ms per link<br/>";
}
</code></pre>
<p>View code:</p>
<pre><code><%= Bechmark(() => Url.Action("Login", "Account")) %>
<%= Bechmark(() => Url.Action("Login", "Account", new {username="bla", password="bla2", returnurl="blabla32", rememberme=false} )) %>
<%= Bechmark(() => Html.BuildUrlFromExpression<AccountController>(a=>a.ChangePassword("bla", "bla", "ya")) ) %>
</code></pre>
<p>Running this on a typical Core2 notebook on the default new project template with ASP.NET MVC Beta yields these results:</p>
<blockquote>
<p>38 ms, 0,038 ms per link</p>
<p>120 ms, 0,12 ms per link</p>
<p>54 ms, 0,054 ms per link</p>
</blockquote>
<p>Running the same benchmark on a production project with about 10 controllers that have all in all around 100 methods and 30 routing table entries, the performance degrades greatly for the expression-based method:</p>
<blockquote>
<p>31 ms, 0,031 ms per link</p>
<p>112 ms, 0,112 ms per link</p>
<p>450 ms, 0,45 ms per link</p>
</blockquote>
<p>We use this method quite a lot (maintainability) and doing some performance benchmarking, this degrades the performance of the site greatly - pages quickly contain around 30 or more of such links, that means 10ms of additional overhead on a single page. Even 0.112ms per an URL is around 4ms of pure CPU overhead.</p>
<p>It should be noted that performance of all the three URL generation calls between MVC Preview 3 and Beta (released yesterday) got improved by a factor of 5.</p>
<p>Stack Overflow is supposedly powered by the same framework, how have you guys tackled this scaling problem? Liberal caching of the front page (lots of links) and pre-rendered controls?</p>
<p>Any other production websites in ASP.NET MVC with performance issues or some good tips?</p>
| [
{
"answer_id": 212327,
"author": "rudib",
"author_id": 28917,
"author_profile": "https://Stackoverflow.com/users/28917",
"pm_score": 1,
"selected": false,
"text": "<%= Bechmark(() => Url.Action(\"Login\", \"Account\", new Dictionary<string, object> {{\"username\", \"bla\"}, {\"password\"... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28917/"
] |
212,215 | <p>I'm trying to display a loading icon while my iPhone app downloads a network resource, but I can't figure out how to make it show up correctly.</p>
<p>I searched around and found some details on the <code>UIActivityView</code> class, but the available example source code didn't work, and the documentation is kind of terse.</p>
<p>Could someone provide a simple example on how to use this class?</p>
| [
{
"answer_id": 212564,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 5,
"selected": true,
"text": "UIActivityIndicator"
},
{
"answer_id": 213243,
"author": "Jablair",
"author_id": 24168,
"author_prof... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
212,228 | <p>I have read the GOLD Homepage ( <a href="http://www.devincook.com/goldparser/" rel="nofollow noreferrer">http://www.devincook.com/goldparser/</a> ) docs, FAQ and Wikipedia to find out what practical application there could possibly be for GOLD. I was thinking along the lines of having a programming language (easily) available to my systems such as ABAP on SAP or X++ on Axapta - but it doesn't look feasible to me, at least not easily - even if you use GOLD.</p>
<p>The final use of the parsed result produced by GOLD escapes me - what do you do with the result of the parse?</p>
<p>EDIT: A practical example (description) would be great.</p>
| [
{
"answer_id": 212529,
"author": "Will Hartung",
"author_id": 13663,
"author_profile": "https://Stackoverflow.com/users/13663",
"pm_score": 4,
"selected": true,
"text": "public void execute_if_statment(ParseTreeNode node) {\n // We already know we have a IF_STATEMENT node\n Value v... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535708/"
] |
212,234 | <p>I am building an MS Access application in which all the forms are modal. However, after data change in a form, I want to refresh the parent form of this form with newer data. Is there any way to do it. To elaborate further :</p>
<p>Consider there are two forms, Form A and Form B. Both are modal form. From Form A, I initiate Form B, and now Form B has the user attention. But at the close of form B, I want to refresh the Form A. Is there a way to do it?</p>
| [
{
"answer_id": 212303,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": false,
"text": "Forms!FormA.Requery\n"
},
{
"answer_id": 212482,
"author": "Fionnuala",
"author_id": 2548,
"author_pro... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6613/"
] |
212,237 | <p>I've read all the advice on const-correctness in C++ and that it is important (in part) because it helps the compiler to optimize your code. What I've never seen is a good explanation on how the compiler uses this information to optimize the code, not even the good books go on explaining what happens behind the curtains. </p>
<p>For example, how does the compiler optimize a method that is declared const vs one that isn't but should be. What happens when you introduce mutable variables? Do they affect these optimizations of const methods?</p>
| [
{
"answer_id": 212304,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "void someType::somefunc();\n\nvoid MyFunc()\n{\n someType A(4); // \n Fling(A.m_val);\n A.someFunc();\n ... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22247/"
] |
212,239 | <p>I am using Apache <a href="http://hc.apache.org/httpclient-3.x/" rel="noreferrer">HttpClient</a> and would like to communicate HTTP errors (400 Bad Request, 404 Not Found, 500 Server Error, etc.) via the Java exception mechanism to the calling code. Is there an exception in the Java standard library or in a widely used library that would be appropriate to use or to subclass for this purpose?</p>
<p>The alternative is to check status return codes. This appears to be the HttpClient design philosophy, but since these errors are truly exceptional in my app, I would like to have the stack trace and other nice exception things set up for me when they happen.</p>
| [
{
"answer_id": 47058425,
"author": "Paulo Merson",
"author_id": 317522,
"author_profile": "https://Stackoverflow.com/users/317522",
"pm_score": 4,
"selected": false,
"text": "MyBusinessException"
},
{
"answer_id": 54390878,
"author": "Wendel",
"author_id": 2057463,
"a... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28604/"
] |
212,257 | <p>It seems like this should be straightforward but I'm boggling. I've got my listview all setup and bound to my LINQ datasource. The source is dependent on a dropdown list which decides which branch information to show in the listview. My edit template works fine but my insert template won't work because it wants the branch ID which I want to get from the dropdownlist outside the listview but I don't know how to both bind that value and set it in my template. It looks like this:</p>
<pre><code><InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
</td>
<td>
<asp:TextBox ID="RechargeRateTextBox" runat="server"
Text='<%# Bind("RechargeRate") %>' />
</td>
<td>
<asp:Calendar SelectedDate='<%# Bind("StartDate") %>' ID="Calendar1" runat="server"></asp:Calendar>
</td>
</tr>
</InsertItemTemplate>
</code></pre>
<p>I need to get a label in there that binds to the value of a databound asp dropdownlist outside of the listview so that the insert will work.</p>
| [
{
"answer_id": 212341,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "protected void BranchDropDownList_OnSelectedIndexChanged( object sender, EventArgs e )\n{\n DropDownList ddl = (Drop... | 2008/10/17 | [
"https://Stackoverflow.com/questions/212257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12862/"
] |
212,270 | <p>This is an often-asked question that has views on both side. Those in favour will argue:</p>
<ul>
<li>To design a system for coders you must understand how to code (and be coding)</li>
<li>You can't design a system without being aware of what is happening at ground level</li>
<li>Architecture is not just about broad stroke design but about adapting to changing needs at the code level</li>
</ul>
<p>on the other hand,</p>
<ul>
<li>Architecture is a high-level role and should be not be concerned about implementation details</li>
<li>Coding is a detailed oriented, heads-down funtion which is at odds with the risk management, broad view nature of architecture</li>
<li>Architecture is about technical risk management and not implementation</li>
<li>Architecture is about leadership. It's difficult to lead from behind</li>
</ul>
<p>In my experience architects should not be spending a lot of time coding but must keep in touch with the code base primarily through lead developer communication, review and stand ups. If you spend a lot of time coding you lose sight of the high level issues and become ineffective at managing technical risk.</p>
| [
{
"answer_id": 1078128,
"author": "borjab",
"author_id": 16206,
"author_profile": "https://Stackoverflow.com/users/16206",
"pm_score": 1,
"selected": false,
"text": "* Coding is a detailed oriented, heads-down funtion which is at odds\n"
}
] | 2008/10/17 | [
"https://Stackoverflow.com/questions/212270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199234/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.