qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
153,507
<p>How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)?</p> <p>For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere.</p> <p>Any ideas? </p>
[ { "answer_id": 153517, "author": "Chris Johnson", "author_id": 23732, "author_profile": "https://Stackoverflow.com/users/23732", "pm_score": 6, "selected": true, "text": "s = s + u * dt;\nu = u + a * dt;\n" }, { "answer_id": 153551, "author": "freespace", "author_id": 829...
2008/09/30
[ "https://Stackoverflow.com/questions/153507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11911/" ]
153,527
<p>I have a page that contains a form. This page is served with content type text/html;charset=utf-8. I need to submit this form to server using ISO-8859-1 character encoding. Is this possible with Internet Explorer?</p> <p>Setting accept-charset attribute to form element, like this, works for Firefox, Opera etc. but not for IE.</p> <pre><code>&lt;form accept-charset="ISO-8859-1"&gt; ... &lt;/form&gt; </code></pre> <p>Edit: This form is created by server A and will be submitted to server B. I have no control over server B.</p> <p>If I set server A to serve content with charset ISO-8859-1 everything works, but I am looking a way to make this work without changes to server A's encoding. I have another question <a href="https://stackoverflow.com/questions/153482/setting-iso-8859-1-encoding-for-a-single-tapestry-4-page-in-application-that-is">about setting the encoding in server A.</a></p>
[ { "answer_id": 153578, "author": "pdc", "author_id": 8925, "author_profile": "https://Stackoverflow.com/users/8925", "pm_score": -1, "selected": false, "text": "accept-charset" }, { "answer_id": 1213849, "author": "Community", "author_id": -1, "author_profile": "https...
2008/09/30
[ "https://Stackoverflow.com/questions/153527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1431/" ]
153,573
<p>Take the following C# class:</p> <pre><code>c1 { event EventHandler someEvent; } </code></pre> <p>If there are a lot of subscriptions to <code>c1</code>'s <code>someEvent</code> event and I want to clear them all, what is the best way to achieve this? <strong>Also consider that subscriptions to this event could be/are lambdas/anonymous delegates.</strong></p> <p>Currently my solution is to add a <code>ResetSubscriptions()</code> method to <code>c1</code> that sets <code>someEvent</code> to null. I don't know if this has any unseen consequences.</p>
[ { "answer_id": 153577, "author": "programmer", "author_id": 5289, "author_profile": "https://Stackoverflow.com/users/5289", "pm_score": 5, "selected": false, "text": "public class c1\n{\n event EventHandler someEvent;\n public ResetSubscriptions() => someEvent = null; \n}\n" }...
2008/09/30
[ "https://Stackoverflow.com/questions/153573", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5289/" ]
153,581
<p>Is it possible to assign a global hotkey to a specific feature in an Adobe AIR app, i.e. the app feature responds to the hotkey whether the app is active or not (it must be running of course, but only in the system tray).</p>
[ { "answer_id": 155786, "author": "davr", "author_id": 14569, "author_profile": "https://Stackoverflow.com/users/14569", "pm_score": 3, "selected": true, "text": "c:\\programs\\thvo42\\coolapp.exe --hotkey q" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/153581", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13041/" ]
153,584
<p>How do I iterate over a timespan after days, hours, weeks or months?</p> <p>Something like:</p> <pre><code>for date in foo(from_date, to_date, delta=HOURS): print date </code></pre> <p>Where foo is a function, returning an iterator. I've been looking at the calendar module, but that only works for one specific year or month, not between dates.</p>
[ { "answer_id": 153667, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 6, "selected": false, "text": "from datetime import date, datetime, timedelta\n\ndef datespan(startDate, endDate, delta=timedelta(days=1)):\n currentDat...
2008/09/30
[ "https://Stackoverflow.com/questions/153584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/473/" ]
153,585
<p>In MS Transact SQL, let's say I have a table (Orders) like this:</p> <pre><code> Order Date Order Total Customer # 09/30/2008 8.00 1 09/15/2008 6.00 1 09/01/2008 9.50 1 09/01/2008 1.45 2 09/16/2008 4.50 2 09/17/2008 8.75 3 09/18/2008 2.50 3 </code></pre> <p>What I need out of this is: for each customer the average order amount for the most recent two orders. So for Customer #1, I should get 7.00 (and not 7.83).</p> <p>I've been staring at this for an hour now (inside a larger problem, which I've solved) and I think my brain has frozen. Help for a simple problem?</p>
[ { "answer_id": 153601, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 4, "selected": true, "text": "select avg(total), customer \nfrom orders o1 \nwhere orderdate in \n ( select top 2 date \n from orders o2 \n wher...
2008/09/30
[ "https://Stackoverflow.com/questions/153585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8173/" ]
153,592
<p>I'm using .NET to make an application with a drawing surface, similar to Visio. The UI connects two objects on the screen with Graphics.DrawLine. This simple implementation works fine, but as the surface gets more complex, I need a more robust way to represent the objects. One of these robust requirements is determining the intersection point for two lines so I can indicate separation via some kind of graphic.</p> <p>So my question is, can anyone suggest a way to do this? Perhaps with a different technique (maybe GraphViz) or an algorithm?</p>
[ { "answer_id": 153780, "author": "Chris Johnson", "author_id": 23732, "author_profile": "https://Stackoverflow.com/users/23732", "pm_score": 4, "selected": true, "text": "a = (v2.v2 v1.(x2-x1) - v1.v2 v2.(x2-x1)) / ((v1.v1)(v2.v2) - (v1.v2)^2)\nb = (v1.v2 v1.(x2-x1) - v1.v1 v2.(x2-x1)) /...
2008/09/30
[ "https://Stackoverflow.com/questions/153592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7565/" ]
153,596
<p>What would be the most efficient way of recording to a log (.txt) from a console program on C# and .NET 2.2? My program loops multiple times always outputting different data based on what the user wants, so I'm searching for the most efficient way to achieve this.</p> <p>I know I can always reopen a stream and then close it, but everytime I do that it would be writing just one line, then next time around (seconds later) the program reloops and needs tor write again. In my opinion, that doesn't seem very resourse friendly.</p> <p>I'm using multiple threads that all have output data that I want to log (opening/closing the same file or accessing the same file on different threads might be bad). The "holds a reference to a stream writer that auto-flushes" sounds like a good idea, however I don't know how to do that.</p>
[ { "answer_id": 153672, "author": "Wolfwyrd", "author_id": 15570, "author_profile": "https://Stackoverflow.com/users/15570", "pm_score": 3, "selected": true, "text": "private Tracing trace = new Tracing(\"My.Namespace.Class\");\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/153596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22582/" ]
153,598
<p>I have a simple query:</p> <pre><code>SELECT u_name AS user_name FROM users WHERE user_name = "john"; </code></pre> <p>I get <code>Unknown Column 'user_name' in where clause</code>. Can I not refer to <code>'user_name'</code> in other parts of the statement even after <code>select 'u_name as user_name'</code>?</p>
[ { "answer_id": 153614, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": false, "text": "SELECT u_name AS user_name FROM users WHERE u_name = 'john';\n" }, { "answer_id": 153626, "author": "Davi...
2008/09/30
[ "https://Stackoverflow.com/questions/153598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
153,617
<p>How can I write a scheduler application in C# .NET?</p>
[ { "answer_id": 153688, "author": "Chris Wenham", "author_id": 5548, "author_profile": "https://Stackoverflow.com/users/5548", "pm_score": 0, "selected": false, "text": "// Set event to occur on October 1st, 2008 at 12:30pm.\nDateTime eventStarts = new DateTime(2008,10,1,12,30,00);\nTimer...
2008/09/30
[ "https://Stackoverflow.com/questions/153617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
153,630
<p>Unfortunately, I need to do this. I'm using ELMAH for my error log. Before I route to my error.aspx view, I have to grab the default ELMAH error log so I can log the exception. You used to be able to use </p> <pre><code>Elmah.ErrorLog.Default </code></pre> <p>However, this is now marked as obsolete. The compiler directs me to use the method</p> <pre><code>Elmah.ErrorLog.GetDefault(HttpContext context) </code></pre> <p>MVC's context is of type HttpContextBase, which enables us to mock it (YAY!). How can we deal with MVC-unaware libraries that require the old style HttpContext?</p>
[ { "answer_id": 153683, "author": "SHODAN", "author_id": 2622, "author_profile": "https://Stackoverflow.com/users/2622", "pm_score": 8, "selected": true, "text": "System.Web.HttpContext.Current" }, { "answer_id": 1469734, "author": "rodrigo caballero", "author_id": 178234,...
2008/09/30
[ "https://Stackoverflow.com/questions/153630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
153,633
<p>Is there an elegant way to have performant, natural sorting in a MySQL database?</p> <p>For example if I have this data set:</p> <ul> <li>Final Fantasy</li> <li>Final Fantasy 4</li> <li>Final Fantasy 10</li> <li>Final Fantasy 12</li> <li>Final Fantasy 12: Chains of Promathia</li> <li>Final Fantasy Adventure</li> <li>Final Fantasy Origins</li> <li>Final Fantasy Tactics</li> </ul> <p>Any other <strong>elegant</strong> solution than to split up the games' names into their components </p> <ul> <li><em>Title</em>: "Final Fantasy"</li> <li><em>Number</em>: "12"</li> <li><em>Subtitle</em>: "Chains of Promathia"</li> </ul> <p>to make sure that they come out in the right order? (10 after 4, not before 2).</p> <p>Doing so is a pain in the a** because every now and then there's another game that breaks that mechanism of parsing the game title (e.g. "Warhammer 40,000", "James Bond 007")</p>
[ { "answer_id": 153660, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 4, "selected": false, "text": "ORDER BY" }, { "answer_id": 153699, "author": "JeeBee", "author_id": 17832, "author_profile": "https://S...
2008/09/30
[ "https://Stackoverflow.com/questions/153633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/999/" ]
153,639
<p>Greetings!</p> <p>I have a WebService that contains a WebMethod that does some work and returns a boolean value. The work that it does may or may not take some time, so I'd like to call it asynchronously.</p> <pre><code>[WebService(Namespace = "http://tempuri.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class MyWebSvc : System.Web.Services.WebService { [WebMethod] public bool DoWork() { bool succ = false; try { // do some work, which might take a while } catch (Exception ex) { // handle succ = false; } return succ; } } </code></pre> <p>This WebService exists on each server in a web farm. So to call the DoWork() method on each server, I have a class library to do so, based on a list of server URLs:</p> <pre><code>static public class WebSvcsMgr { static public void DoAllWork(ICollection&lt;string&gt; servers) { MyWebSvc myWebSvc = new MyWebSvc(); foreach (string svr_url in servers) { myWebSvc.Url = svr_url; myWebSvc.DoWork(); } } } </code></pre> <p>Finally, this is called from the Web interface in an asp:Button click event like so:</p> <pre><code>WebSvcsMgr.DoAllWork(server_list); </code></pre> <p>For the static DoAllWork() method called by the Web Form, I plan to make this an asynchronous call via IAsyncResult. However, I'd like to report a success/fail of the DoWork() WebMethod for each server in the farm as the results are returned. What would be the best approach to this in conjuction with an UpdatePanel? A GridView? Labels? And how could this be returned by the static helper class to the Web Form?</p>
[ { "answer_id": 153854, "author": "craigmoliver", "author_id": 12252, "author_profile": "https://Stackoverflow.com/users/12252", "pm_score": 0, "selected": false, "text": "<asp:UpdatePanel ID=\"up\" runat=\"server\" UpdateMode=\"Conditional\">\n <ContentTemplate>\n <asp:Literal ID=\...
2008/09/30
[ "https://Stackoverflow.com/questions/153639", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27870/" ]
153,644
<p>Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array <code>@myarray</code> and a hash <code>%myhash</code>, why do you need to do:</p> <pre><code>$x = $myarray[1]; $y = $myhash{'foo'}; </code></pre> <p>instead of just doing :</p> <pre><code>$x = myarray[1]; $y = myhash{'foo'}; </code></pre> <p>Why are the above ambiguous? </p> <p>Wouldn't it be illegal Perl code if it was anything but a $ in that place? For example, aren't all of the following illegal in Perl?</p> <pre><code>@var[0]; @var{'key'}; %var[0]; %var{'key'}; </code></pre>
[ { "answer_id": 153668, "author": "Paul Dixon", "author_id": 6521, "author_profile": "https://Stackoverflow.com/users/6521", "pm_score": 3, "selected": false, "text": "$x = myarray[1];\n" }, { "answer_id": 153692, "author": "zigdon", "author_id": 4913, "author_profile"...
2008/09/30
[ "https://Stackoverflow.com/questions/153644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
153,666
<p>I'm having a problem with some mail merge code that is supposed to produce letters within our application. I'm aware that this code is a bit rough at the moment, but we're in the "Get something working" phase before we tidy it up.</p> <p>Now the way this is supposed to work, and the way it works when we do it manually, is we have a file (the fileOut variable + ".template") which is a template for the letter. We open that template, merge it, and then save it as the filename in the fileOut variable.</p> <p>However, what it is doing is saving a copy of the template file to the fileout filename, instead of the output of the merge.</p> <p>I've searched, and I seem to be banging my head against a brick wall.</p> <p>datafile is the datafile that contains the merge data.</p> <p>Using the same files, it all works if you do it manually.</p> <pre><code>Public Function processFile(ByVal datafile As String, ByVal fileOut As String) As String Dim ans As String = String.Empty errorLog = "C:\Temp\Template_error.log" If (File.Exists(datafile)) Then Try ' Create an instance of Word and make it invisible.' wrdApp = CreateObject("Word.Application") wrdApp.Visible = False ' Add a new document.' wrdDoc = wrdApp.Documents.Add(fileOut &amp; ".template") wrdDoc.Select() Dim wrdSelection As Word.Selection Dim wrdMailMerge As Word.MailMerge wrdDoc.MailMerge.OpenDataSource(datafile) wrdSelection = wrdApp.Selection() wrdMailMerge = wrdDoc.MailMerge() With wrdMailMerge .Execute() End With wrdDoc.SaveAs(fileOut) wrdApp.Quit(False) ' Release References.' wrdSelection = Nothing wrdMailMerge = Nothing wrdDoc = Nothing wrdApp = Nothing ans = "Merged OK" Call writeToLogFile(errorLog, "This worked, written to " &amp; fileOut) Catch ex As Exception ans = "error : exception thrown " &amp; ex.ToString Call writeToLogFile(errorLog, ans) End Try Else ans = "error ; unable to open Date File : " &amp; datafile If (logErrors) Then Call writeToLogFile(errorLog, "The specified source csv file does not exist. Unable " &amp; _ "to process it. Filename provided: " &amp; datafile) End If End If Return ans End Function </code></pre>
[ { "answer_id": 153793, "author": "micahwittman", "author_id": 11181, "author_profile": "https://Stackoverflow.com/users/11181", "pm_score": 0, "selected": false, "text": "wrdDoc.MailMerge.OpenDataSource(templateName)\n" }, { "answer_id": 156509, "author": "hulver", "autho...
2008/09/30
[ "https://Stackoverflow.com/questions/153666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11496/" ]
153,685
<p>So I've got an application whose window behavior I would like to behave more like Photoshop CS. In Photoshop CS, the document windows always stay behind the tool windows, but are still top level windows. For MDI child windows, since the document window is actually a child, you can't move it outside of the main window. In CS, though, you can move your image to a different monitor fine, which is a big advantage over docked applications like Visual Studio, and over regular MDI applications.</p> <p>Anyway, here's my research so far. I've tried to intercept the WM_MOUSEACTIVATE message, and use the DeferWindowPos commands to do my own ordering of the window, and then return MA_NOACTIVATEANDEAT, but that causes the window to not be activated properly, and I believe there are other commands that "activate" a window without calling WM_MOUSEACTIVATE (like SetFocus() I think), so that method probably won't work anyway.</p> <p>I believe Windows' procedure for "activating" a window is 1. notify the unactivated window with the WM_NCACTIVATE and WM_ACTIVATE messages 2. move the window to the top of the z-order (sending WM_POSCHANGING, WM_POSCHANGED and repaint messages) 3. notify the newly activated window with WM_NCACTIVATE and WM_ACTIVATE messages.</p> <p>It seems the cleanest way to do it would be to intercept the first WM_ACTIVATE message, and somehow notify Windows that you're going to override their way of doing the z-ordering, and then use the DeferWindowPos commands, but I can't figure out how to do it that way. It seems once Windows sends the WM_ACTIVATE message, it's already going to do the reordering its own way, so any DeferWindowPos commands I use are overridden.</p> <p>Right now I've got a basic implementation quasy-working that makes the tool windows topmost when the app is activated, but then makes them non-topmost when it's not, but it's very quirky (it sometimes gets on top of other windows like the task manager, whereas Photoshop CS doesn't do that, so I think Photoshop somehow does it differently) and it just seems like there would be a more intuitive way of doing it.</p> <p>Anyway, does anyone know how Photoshop CS does it, or a better way than using topmost?</p>
[ { "answer_id": 8124168, "author": "Eugene Belyakov", "author_id": 851473, "author_profile": "https://Stackoverflow.com/users/851473", "pm_score": 2, "selected": false, "text": "public class BaseForm : Form\n{\n public virtual int TopMostLevel\n {\n get { return 0; }\n }\n...
2008/09/30
[ "https://Stackoverflow.com/questions/153685", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23812/" ]
153,689
<p>I'm designing an application which deals with two sets of data - Users and Areas. The data is read from files produced by a third party. I have a User class and an Area class, and the data is read into a Users array and an Areas array (or other appropriate memory structure, depending on the technology we go with).</p> <p>Both classes have a unique ID member which is read from the file, and the User class contains an array of Area IDs, giving a relationship where one user is associated with many Areas.</p> <p>The requirements are quite straightforward:</p> <ul> <li>List of Users</li> <li>List of Areas</li> <li>List of Users for Specified Area</li> <li>List of Areas for Specified Users</li> </ul> <p>My first thought was to leave the data in the two arrays, then for each of the requirements, have a seperate method which would interrogate one or both arrays as required. This would be easy to implement, but I'm not convinced it's necessarily the best way.</p> <p>Then I thought about having a 'Get Areas' method on the User class and a 'Get Users' member on the Area class which would be more useful if for example I'm at a stage where I have an Area object, I could find it's users by a property, but then how would a 'Get Users' method on the Area class be aware of/have access to the Users array.</p> <p>I've had this problem a number of times before, but never really came up with a definitive solution. Maybe I'm just making it more complicated than it actually is. Can anyone provide any tips, URLs or books that would help me with this sort of design?</p> <p>UPDATE: Thank you all for taking your time to leave some tips. Your comments are very much appreciated.</p> <p>I agree that the root of this problem is a many-to-many relationship. I understand how that would be modelled in a relational database, that's pretty simple.</p> <p>The data I receive is in the form of binary files from a third party, so I have no control over the structure of these, but I can store it whichever way is best when I read it in. It is a bit square pegs in round holes, but I thought reading it in then storing it in a database, the program would then have to query the database to get to the results. It's not a massive amount of data, so I thought it would be possible to get out what I need by storing it in memory structures.</p>
[ { "answer_id": 153708, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 3, "selected": false, "text": "User <<--->> Area\n" }, { "answer_id": 153719, "author": "chessguy", "author_id": 1908025, "autho...
2008/09/30
[ "https://Stackoverflow.com/questions/153689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8354/" ]
153,706
<p>It seems to me that phpMyAdmin imports tables by default with collation latin1_swedish_ci, how i change this?</p>
[ { "answer_id": 153765, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": false, "text": "$dbname = 'my_databaseName';\nmysql_connect('127.0.0.1', 'root', '');\nmysql_query(\"ALTER DATABASE `$dbname` DEFAULT CHAR...
2008/09/30
[ "https://Stackoverflow.com/questions/153706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
153,707
<p>Suppose I have the following declaration:</p> <pre><code>class Over1 { protected: class Under1 { }; }; </code></pre> <p>I know that I could do the following:</p> <pre><code>class Over2 : public Over1 { protected: class Under2 : public Under1 { }; }; </code></pre> <p>But is there a way to declare Under2 without Over2? </p> <p>Since you would have to extend Over1 to use any derivative of Under1 this may seem silly, but in this situation there might be 30 different flavors of Under. I can either:</p> <ul> <li>Put them all inside Over1 : Not attractive since Over2 may only use 1 or 2 of them </li> <li>Put them each in their own version of Over : Not attractive since then you will have to multiply inherit from almost the same class. </li> <li>Find a way to create children of Under1 without creating children of Over1</li> </ul> <p>So is this possible?</p> <p>Thanks.</p>
[ { "answer_id": 153830, "author": "Richard Corden", "author_id": 11698, "author_profile": "https://Stackoverflow.com/users/11698", "pm_score": 2, "selected": true, "text": "class Over1\n{\nprotected:\n class Under1\n {\n };\n\n template <typename T>\n class UnderImplementor;\n};\n\ns...
2008/09/30
[ "https://Stackoverflow.com/questions/153707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23829/" ]
153,716
<p>Is there any way to verify in Java code that an e-mail address is valid. By valid, I don't just mean that it's in the correct format (someone@domain.subdomain), but that's it's a real active e-mail address.</p> <p>I'm almost certain that there's no 100% reliable way to do this, because such a technique would be the stuff of spammer's dreams. But perhaps there's some technique that gives some useful indication about whether an address is 'real' or not.</p>
[ { "answer_id": 153751, "author": "MBCook", "author_id": 18189, "author_profile": "https://Stackoverflow.com/users/18189", "pm_score": 6, "selected": false, "text": "private static final Pattern rfc2822 = Pattern.compile(\n \"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\\\.[a-z0-9!#$%&'*+/=?^...
2008/09/30
[ "https://Stackoverflow.com/questions/153716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2648/" ]
153,724
<p>What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.</p> <p>I also would like only significant digits to be displayed - i.e. there should not be any trailing zeroes.</p> <p>I know one method of doing this is to use the <code>String.format</code> method:</p> <pre><code>String.format("%.5g%n", 0.912385); </code></pre> <p>returns:</p> <pre><code>0.91239 </code></pre> <p>which is great, however it always displays numbers with 5 decimal places even if they are not significant: </p> <pre><code>String.format("%.5g%n", 0.912300); </code></pre> <p>returns:</p> <pre><code>0.91230 </code></pre> <p>Another method is to use the <code>DecimalFormatter</code>:</p> <pre><code>DecimalFormat df = new DecimalFormat("#.#####"); df.format(0.912385); </code></pre> <p>returns:</p> <pre><code>0.91238 </code></pre> <p>However as you can see this uses half-even rounding. That is it will round down if the previous digit is even. What I'd like is this:</p> <pre><code>0.912385 -&gt; 0.91239 0.912300 -&gt; 0.9123 </code></pre> <p>What is the best way to achieve this in Java?</p>
[ { "answer_id": 153753, "author": "asterite", "author_id": 20459, "author_profile": "https://Stackoverflow.com/users/20459", "pm_score": 9, "selected": false, "text": "value" }, { "answer_id": 153764, "author": "Chris Cudmore", "author_id": 18907, "author_profile": "ht...
2008/09/30
[ "https://Stackoverflow.com/questions/153724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12149/" ]
153,731
<p>I am looking for validation framework and while I am already using NHibernate I am thinking of using NHibernate.validator from contrib project however I also look at MS Validation Block which seem to be robust but i am not yet get into detail of each one yet so I wonder has anyone had step into these two frameworks and how is the experience like?</p>
[ { "answer_id": 787580, "author": "mookid8000", "author_id": 6560, "author_profile": "https://Stackoverflow.com/users/6560", "pm_score": 4, "selected": true, "text": "var engine = new ValidatorEngine();\nInvalidValue[] errors = engine.Validate(someModelObjectWithAttributes);\n\nforeach(va...
2008/09/30
[ "https://Stackoverflow.com/questions/153731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15396/" ]
153,748
<p>I've tried this:</p> <pre><code>string newScript = textBox1.Text; HtmlElement head = browserCtrl.Document.GetElementsByTagName("head")[0]; HtmlElement scriptEl = browserCtrl.Document.CreateElement("script"); lblStatus.Text = scriptEl.GetType().ToString(); scriptEl.SetAttribute("type", "text/javascript"); head.AppendChild(scriptEl); scriptEl.InnerHtml = "function sayHello() { alert('hello') }"; </code></pre> <p>scriptEl.InnerHtml and scriptEl.InnerText both give errors:</p> <pre><code>System.NotSupportedException: Property is not supported on this type of HtmlElement. at System.Windows.Forms.HtmlElement.set_InnerHtml(String value) at SForceApp.Form1.button1_Click(Object sender, EventArgs e) in d:\jsight\installs\SForceApp\SForceApp\Form1.cs:line 31 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message&amp; m) at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m) at System.Windows.Forms.Button.WndProc(Message&amp; m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) </code></pre> <p>Is there an easy way to inject a script into the dom?</p>
[ { "answer_id": 154330, "author": "ZeroBugBounce", "author_id": 11314, "author_profile": "https://Stackoverflow.com/users/11314", "pm_score": 3, "selected": false, "text": "IHTMLElement iScriptEl = (IHTMLElement)scriptEl.DomElement;\n" }, { "answer_id": 154496, "author": "Atan...
2008/09/30
[ "https://Stackoverflow.com/questions/153748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1432/" ]
153,759
<p>How do I use the jQuery Datepicker with a textbox input:</p> <pre><code>$("#my_txtbox").datepicker({ // options }); </code></pre> <p>that doesn't allow the user to input random text in the textbox. I want the Datepicker to pop up when the textbox gains focus or the user clicks on it, but I want the textbox to ignore any user input using the keyboard (copy &amp; paste, or any other). I want to fill the textbox exclusively from the Datepicker calendar.</p> <p>Is this possible?</p> <p>jQuery 1.2.6<br/> Datepicker 1.5.2</p>
[ { "answer_id": 153804, "author": "Adam Bellaire", "author_id": 21632, "author_profile": "https://Stackoverflow.com/users/21632", "pm_score": 9, "selected": true, "text": "<input type='text' id='foo' readonly='true'>\n" }, { "answer_id": 153817, "author": "Eduardo Molteni", ...
2008/09/30
[ "https://Stackoverflow.com/questions/153759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024/" ]
153,762
<p>Our graphics person uses Adobe Illustrator and we'd like to use her images inside our WPF application as paths. Is there a way to do this?</p>
[ { "answer_id": 26541828, "author": "DuckMaestro", "author_id": 29152, "author_profile": "https://Stackoverflow.com/users/29152", "pm_score": 2, "selected": false, "text": "<DrawingGroup>" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/153762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3047/" ]
153,769
<p>As in subject... is there a way of looking at an empty table schema without inserting any rows and issuing a SELECT?</p>
[ { "answer_id": 153779, "author": "Plasmer", "author_id": 397314, "author_profile": "https://Stackoverflow.com/users/397314", "pm_score": 4, "selected": true, "text": "db2 describe table user1.department" }, { "answer_id": 5348256, "author": "Amit", "author_id": 665523, ...
2008/09/30
[ "https://Stackoverflow.com/questions/153769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437/" ]
153,775
<p>i have a library with some entities that share the same interface. clients and service share this assembly. now i wonder if there is a way to have this Interface-type as Parameter in my service contracts so that i can use the same method for all classes implementing the interface.</p> <p>the entities themselve are all decorated with datacontract-attribute and its members with datamember attributes.</p> <p>is it possible at all? probably with the <em>NetDataContractSerializer</em>? i know that i can do it with a base class (some abstract class e.g.) and the <em>knowntype</em>-attribute but i´d definitely prefer the Interface as identificator of the objects cause it is used widely in the client app and would ease development.</p> <p>thanks</p>
[ { "answer_id": 214451, "author": "lesscode", "author_id": 18482, "author_profile": "https://Stackoverflow.com/users/18482", "pm_score": 0, "selected": false, "text": "namespace SharedInterfaces {\n public interface ICompositeType {\n bool BoolValue { get; set; }\n string...
2008/09/30
[ "https://Stackoverflow.com/questions/153775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20227/" ]
153,776
<p>I am inside of...</p> <pre><code>public class bgchange : IMapServerDropDownBoxAction { void IServerAction.ServerAction(ToolbarItemInfo info) { Some code... </code></pre> <p>and after "some code" I want to trigger</p> <pre><code>[WebMethod] public static void DoSome() { } </code></pre> <p>Which triggers some javascript. Is this possible?</p> <p>Ok, switch methods here. I was able to call dosome(); which fired but did not trigger the javascript. I have tried to use the registerstartupscript method but don't fully understand how to implement it. Here's what I tried:</p> <pre><code>public class bgchange : IMapServerDropDownBoxAction { void IServerAction.ServerAction(ToolbarItemInfo info) { ...my C# code to perform on dropdown selection... //now I want to trigger some javascript... // Define the name and type of the client scripts on the page. String csname1 = "PopupScript"; Type cstype = this.GetType(); // Get a ClientScriptManager reference from the Page class. ClientScriptManager cs = Page.ClientScript; // Check to see if the startup script is already registered. if (!cs.IsStartupScriptRegistered(cstype, csname1)) { String cstext1 = "alert('Hello World');"; cs.RegisterStartupScript(cstype, csname1, cstext1, true); } } </code></pre> <p>}</p> <p>I got the registerstartupscript code from an msdn example. Clearly I am not implementing it correctly. Currently vs says "An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.ClientScript.get' refering to the piece of code "Page.Clientscript;" Thanks.</p>
[ { "answer_id": 153873, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 3, "selected": true, "text": "<asp:ScriptManager ID=\"scriptManager1\" \n runat=\"server\" EnablePageMethods=\"true\" />\n" }, { "answer_i...
2008/09/30
[ "https://Stackoverflow.com/questions/153776", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5234/" ]
153,782
<p>I am using a codebehind page in ASP.NET to perform a SQL query. The query is loaded into a string, the connection is established (To Oracle), and we get it started by having the connection perform .ExecuteReader into a OleDBDataReader (We'll call it DataRead). I'll try to hammer out an example below. (Consider Drop as an ASP DropDownList control)</p> <pre><code>Dim LookFor as String = "Fuzzy Bunnies" While DataRead.Read If LookFor = DataRead.Item("Kinds of Bunnies") Then 'Meets special critera, do secondary function' Drop.Items.Add(DataRead.Item("Subgroup of Bunnies")) ... End if ... End While </code></pre> <p>This is the only way I know of doing a dynamic add to a DropDownList. However, each item in a DropDownList has a .text property and a .value property. How can we define the .value as being different from the .text in code?</p>
[ { "answer_id": 153788, "author": "John Sheehan", "author_id": 1786, "author_profile": "https://Stackoverflow.com/users/1786", "pm_score": 1, "selected": false, "text": "Dim item as New ListItem()\nitem.Value = \"foo\"\nitem.Text = \"bar\"\n\nDrop.Items.Add(item)\n" }, { "answer_i...
2008/09/30
[ "https://Stackoverflow.com/questions/153782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12545/" ]
153,795
<p>I'm getting some objects from an external library and I need to store those objects in a database. Is there a way to create the tables and relationships starting from the objects, or I have to dig into them and create migrations and models by hand?</p> <p>Thanks! Roberto</p>
[ { "answer_id": 155764, "author": "Orion Edwards", "author_id": 234, "author_profile": "https://Stackoverflow.com/users/234", "pm_score": 2, "selected": false, "text": "class Animal\n attr_accessor :name, :number_of_legs\nend\na = SomeThirdPartyLibrary.get_animal\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/153795", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22083/" ]
153,796
<p>I'm trying to loop through all the controls on a sharepoint page, for the purposes of testing i just want to output the control ID</p> <p>this is the code i'm using</p> <p>Public Shared Sub SubstituteValues3(ByVal CurrentPage As Page, ByRef s As StringBuilder)</p> <pre><code> 'Page() '- MasterPage '- HtmlForm '- ContentPlaceHolder '- The TextBoxes, etc. For Each ctlMaster As Control In CurrentPage.Controls If TypeOf ctlMaster Is MasterPage Then HttpContext.Current.Response.Output.Write("Master Page &lt;br/&gt;") For Each ctlForm As Control In ctlMaster.Controls If TypeOf ctlForm Is HtmlForm Then HttpContext.Current.Response.Output.Write("HTML Form &lt;br/&gt;") For Each ctlContent As Control In ctlForm.Controls If TypeOf ctlContent Is ContentPlaceHolder Then HttpContext.Current.Response.Output.Write("Content Placeholder &lt;br/&gt;") For Each ctlChild As Control In ctlContent.Controls HttpContext.Current.Response.Output.Write(ctlChild.ID.ToString &amp; "&lt;br /&gt;") Next End If Next End If Next End If Next HttpContext.Current.Response.Output.Write("--------------") HttpContext.Current.Response.End() </code></pre> <p>however it's not getting past the 'MasterPage' output.</p> <p>I would expect to see the names of all the controls i have inside my content placeholder but i find it all a bit confusing.</p>
[ { "answer_id": 160539, "author": "Cruiser", "author_id": 16971, "author_profile": "https://Stackoverflow.com/users/16971", "pm_score": 1, "selected": false, "text": " For Each ctlForm As Control In Page.Master.Controls\n\n If TypeOf ctlForm Is HtmlForm Then\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/153796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
153,801
<p>I've got a script that takes a user uploaded RTF document and merges in some person data into the letter (name, address, etc), and does this for multiple people. I merge the letter contents, then combine that with the next merge letter contents, for all people records.</p> <p>Affectively I'm combining a single RTF document into itself for as many people records to which I need to merge the letter. However, I need to first remove the closing RTF markup and opening of the RTF markup of each merge or else the RTF won't render correctly. This sounds like a job for regular expressions.</p> <p>Essentially I need a regex that will remove the entire string:</p> <p>}\n\page ANYTHING \par</p> <p>Example, this regex would match this:</p> <pre><code>crap } \page{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\f0\fs20 September 30, 2008\par more crap </code></pre> <p>So I could make it just:</p> <pre><code>crap \page more crap </code></pre> <p>Is RegEx the best approach here?</p> <p>UPDATE: Why do I have to use RTF?</p> <p>I want to enable the user to upload a form letter that the system will then use to create the merged letters. Since RTF is plain text, I can do this pretty easily in code. I know, RTF is a disaster of a spec, but I don't know any other good alternative.</p>
[ { "answer_id": 155094, "author": "Randy", "author_id": 9361, "author_profile": "https://Stackoverflow.com/users/9361", "pm_score": 3, "selected": true, "text": "$output = preg_replace(\"/}\\s?\\n\\\\\\\\page.*?\\\\\\\\par\\s?\\n/ms\", \"\\\\page\\n\", $input);\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/153801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43/" ]
153,812
<p>In SVN, <code>trunk</code> is the recommended place for the main development and I use this convention for all of my projects. However, this means that <strong>trunk is sometimes unstable, or even broken</strong>. This happens for instance when</p> <ul> <li>I commit something by mistake</li> <li>When the trunk simply has to be broken because of the way SVN works. Canonical example is file renames - you must commit any file renames first and do any further modifications later; however, file rename may require code refactoring to reflect namespace or class name change so you basically need to commit a single logic operation in two steps. And the build is broken between steps 1 and 2.</li> </ul> <p>I can imagine there would be tools to prevent commiting something by mistake (TeamCity and delayed commits, for instance) but can you really overcome the second problem? If not, wouldn't it be better to do the "wild development" on some branch like <code>/branch/dev</code> and only merge to trunk when the build is reasonably solid?</p>
[ { "answer_id": 154324, "author": "JesperE", "author_id": 13051, "author_profile": "https://Stackoverflow.com/users/13051", "pm_score": 2, "selected": false, "text": "# Create new branch and switch to it\nfunction svn_bswitch()\n{\n branch=$1; shift\n msg=\"$1\"; shift\n\n URL=$(svn...
2008/09/30
[ "https://Stackoverflow.com/questions/153812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21728/" ]
153,815
<p>I am coming from the SQL server world where we had uniqueidentifier. Is there an equivalent in oracle? This column will be frequently queried so performance is the key.</p> <p>I am generating the GUID in .Net and will be passing it to Oracle. For a couple reasons it cannot be generated by oracle so I cannot use sequence. </p>
[ { "answer_id": 153849, "author": "Turnkey", "author_id": 13144, "author_profile": "https://Stackoverflow.com/users/13144", "pm_score": 7, "selected": true, "text": "CREATE table test (testguid RAW(16) default SYS_GUID() ) \n" }, { "answer_id": 153851, "author": "hamishmcn", ...
2008/09/30
[ "https://Stackoverflow.com/questions/153815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1514/" ]
153,825
<p>I've got the following query to determine how many votes a story has received:</p> <pre><code>SELECT s_id, s_title, s_time, (s_time-now()) AS s_timediff, ( (SELECT COUNT(*) FROM s_ups WHERE stories.q_id=s_ups.s_id) - (SELECT COUNT(*) FROM s_downs WHERE stories.s_id=s_downs.s_id) ) AS votes FROM stories </code></pre> <p>I'd like to apply the following mathematical function to it for upcoming stories (I think it's what reddit uses) - <a href="http://redflavor.com/reddit.cf.algorithm.png" rel="noreferrer">http://redflavor.com/reddit.cf.algorithm.png</a></p> <p>I can perform the function on the application side (which I'm doing now), but I can't sort it by the ranking which the function provides.</p> <p>Any advise?</p>
[ { "answer_id": 154094, "author": "J.J.", "author_id": 21204, "author_profile": "https://Stackoverflow.com/users/21204", "pm_score": 2, "selected": false, "text": "DELIMINATOR //\n\nCREATE FUNCTION y_element(x INT) \n RETURNS INT\n\nBEGIN\n DECLARE y INT;\n\nIF x > 0 SET y = 1;\nELSE...
2008/09/30
[ "https://Stackoverflow.com/questions/153825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
153,846
<p>We have a WCF service deployed on a Windows 2003 server that is exhibiting some problems. The configuration is using <code>wsHttpBinding</code> and we are specifying the IP address. The services is being hosted by a Windows Service.</p> <p>When we start the service up, most of the time it grabs the wrong IP address. A few times it bound to the correct address only to drop that binding and go to the other address (there are 2) bound to the NIC after processing for a short while.</p> <p>It is currently using port 80 (we've configured IIS to bind to only 1 address via <code>httpcfg</code>) although we have tried it using different ports with the same results.</p> <p>When the Windows Service starts hosting the WCF service, the properties show that it is being bound to the correct address; however, tcpview shows that it is indeed listening on the incorrect address.</p> <p>Here is the portion of the config that sets up tehe baseAddress. The one that gets bound to ends up being .4 instead of .9</p> <pre><code>&lt;services&gt; &lt;service name="Service.MyService" behaviorConfiguration="serviceBehavior"&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;add baseAddress="http://xx.xx.xx.9:80/" /&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;endpoint address="MyService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" contract="Service.IMyService" /&gt; &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt; &lt;/service&gt; &lt;/services&gt; </code></pre> <ul> <li>Is there some other configuration that needs to be set? </li> <li>Is there a tool that can help track down where this is getting bound to the wrong address?</li> </ul>
[ { "answer_id": 155083, "author": "palehorse", "author_id": 312, "author_profile": "https://Stackoverflow.com/users/312", "pm_score": 0, "selected": false, "text": "Description:\nUnable to bind to the underlying transport for xx.xx.xx.4:80. The IP Listen-Only list may contain a reference ...
2008/09/30
[ "https://Stackoverflow.com/questions/153846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/312/" ]
153,861
<p>What do the brackets do in a sql statement?</p> <p>For example, in the statement: </p> <pre>insert into table1 ([columnname1], columnname2) values (val1, val2)</pre> <p>Also, what does it do if the table name is in brackets?</p>
[ { "answer_id": 153870, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 3, "selected": false, "text": "CREATE TABLE test\n(\n [select] varchar(15)\n)\n\nINSERT INTO test VALUES('abc')\n\nSELECT [select] FROM test\n" }...
2008/09/30
[ "https://Stackoverflow.com/questions/153861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/673/" ]
153,863
<p>I have a large 'Manager' class which I think is doing too much but I am unsure on how to divide it into more logical units. </p> <p>Generally speaking the class basically consists of the following methods:</p> <pre> class FooBarManager { GetFooEntities(); AddFooEntity(..); UpdateFooEntity(..); SubmitFooEntity(..); GetFooTypes(); GetBarEntities(); } </pre> <p>The Manager class is part of my business logic and constains an instance of another "Manager" class on the data access level which contains all CRUD operations for all entities.</p> <p>I have different entities coming from the data access layer and therefore have a converter in place outside of the Manager class to convert data entities to business entities.</p> <p>The reason for the manager classes was that I wanted to be able to mock out each of the "Manager" classes when I do unittesting. Each of the manager classes is now over 1000 loc and contain 40-50 methods each. I consider them to be quite bloated and find it awkward to put all of the data access logic into a single class. What should I be doing differently?</p> <p>How would I go about splitting them and is there any specific design-pattern should I be using?</p>
[ { "answer_id": 153917, "author": "scable", "author_id": 8942, "author_profile": "https://Stackoverflow.com/users/8942", "pm_score": 0, "selected": false, "text": " / FooManager\nManager (derive from Manager)\n \\ BarManager\n" }, { "answer_id": 153926...
2008/09/30
[ "https://Stackoverflow.com/questions/153863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15771/" ]
153,874
<h3>See: <a href="https://stackoverflow.com/questions/5727/understanding-pointers">Understanding Pointers</a></h3> <hr /> <p>In many C flavoured languages, and some older languages like Fortran, one can use <strong>Pointers</strong>.</p> <p>As someone who has only really programmed in basic, javascript, and actionscript, can you explain to me what a Pointer is, and what it is most useful for?</p> <p>Thanks!</p>
[ { "answer_id": 153880, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 3, "selected": false, "text": "// x is an integer variable\nint x = 5;\n// xpointer is a variable that references (points to) integer variables\nint ...
2008/09/30
[ "https://Stackoverflow.com/questions/153874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10875/" ]
153,877
<p>I have read the documentation on this and I think I understand. An <a href="http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent.aspx" rel="noreferrer"><code>AutoResetEvent</code></a> resets when the code passes through <code>event.WaitOne()</code>, but a <a href="http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx" rel="noreferrer"><code>ManualResetEvent</code></a> does not.</p> <p>Is this correct?</p>
[ { "answer_id": 154005, "author": "Dan Goldstein", "author_id": 23427, "author_profile": "https://Stackoverflow.com/users/23427", "pm_score": 11, "selected": true, "text": "ManualResetEvent" }, { "answer_id": 154442, "author": "Michael Damatov", "author_id": 23372, "au...
2008/09/30
[ "https://Stackoverflow.com/questions/153877", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455/" ]
153,879
<p>As part of a build setup on a windows machine I need to add a registry entry and I'd like to do it from a simple batch file.</p> <p>The entry is for a third party app so the format is fixed.</p> <p>The entry takes the form of a REG_SZ string but needs to contain newlines ie. 0xOA characters as separators.</p> <p>I've hit a few problems.</p> <p>First attempt used regedit to load a generated .reg file. This failed as it did not seem to like either either long strings or strings with newlines. I discovered that export works fine import fails. I was able to test export as the third party app adds similar entries directly through the win32 api.</p> <p>Second attempt used the command REG ADD but I can't find anyway to add the newline characters everything I try just ends up with a literal string being added.</p>
[ { "answer_id": 153952, "author": "tloach", "author_id": 14092, "author_profile": "https://Stackoverflow.com/users/14092", "pm_score": 3, "selected": true, "text": "set WSHShell = CreateObject(\"WScript.Shell\") \nWSHShell.RegWrite \"HKEY_LOCAL_MACHINE\\SOMEKEY\", \"value\", \"type\"\n" ...
2008/09/30
[ "https://Stackoverflow.com/questions/153879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5427/" ]
153,890
<p>I'm trying to find a good way to print leading <code>0</code>, such as <code>01001</code> for a <a href="https://en.wikipedia.org/wiki/ZIP_Code" rel="noreferrer">ZIP Code</a>. While the number would be stored as <code>1001</code>, what is a good way to do it?</p> <p>I thought of using either <code>case</code> statements or <code>if</code> to figure out how many digits the number is and then convert it to an <code>char</code> array with extra <code>0</code>'s for printing, but I can't help but think there may be a way to do this with the <code>printf</code> format syntax that is eluding me.</p>
[ { "answer_id": 153895, "author": "EvilTeach", "author_id": 7734, "author_profile": "https://Stackoverflow.com/users/7734", "pm_score": 10, "selected": true, "text": "printf(\"%05d\", zipCode);\n" }, { "answer_id": 153898, "author": "Trent", "author_id": 9083, "author_...
2008/09/30
[ "https://Stackoverflow.com/questions/153890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9628/" ]
153,909
<p>I call my JavaScript function. Why do I <em>sometimes</em> get the error 'myFunction is not defined' when it <em>is</em> defined?</p> <p>For example. I'll occasionally get 'copyArray is not defined' even in this example:</p> <pre><code>function copyArray( pa ) { var la = []; for (var i=0; i &lt; pa.length; i++) la.push( pa[i] ); return la; } Function.prototype.bind = function( po ) { var __method = this; var __args = []; // Sometimes errors -- in practice I inline the function as a workaround. __args = copyArray( arguments ); return function() { /* bind logic omitted for brevity */ } } </code></pre> <p>As you can see, copyArray is defined <em>right there</em>, so this can't be about the order in which script files load.</p> <p>I've been getting this in situations that are harder to work around, where the calling function is located in another file that <em>should</em> be loaded after the called function. But this was the simplest case I could present, and appears to be the same problem.</p> <p>It doesn't happen 100% of the time, so I do suspect some kind of load-timing-related problem. But I have no idea what.</p> <p>@Hojou: That's part of the problem. The function in which I'm now getting this error is itself my addLoadEvent, which is basically a standard version of the common library function.</p> <p>@James: I understand that, and there is no syntax error in the function. When that is the case, the syntax error is reported as well. In this case, I am getting only the 'not defined' error.</p> <p>@David: The script in this case resides in an external file that is referenced using the normal &lt;script src="file.js"&gt;&lt;/script&gt; method in the page's head section.</p> <p>@Douglas: Interesting idea, but if this were the case, how could we <em>ever</em> call a user-defined function with confidence? In any event, I tried this and it didn't work.</p> <p>@sk: This technique has been tested across browsers and is basically copied from the <a href="http://en.wikipedia.org/wiki/Prototype_JavaScript_Framework" rel="noreferrer">Prototype</a> library.</p>
[ { "answer_id": 153951, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 0, "selected": false, "text": "(function() {\n function copyArray(pa) {\n // Details\n }\n\n Function.prototype.bind = function ( po ...
2008/09/30
[ "https://Stackoverflow.com/questions/153909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4525/" ]
153,912
<p>I'm looking for a good way to visualize ASP.NET session state data stored in SQL server, preferably without creating a throwaway .aspx page. Is there a good way to get a list of the keys (and serialized data, if possible) directly from SQL server?</p> <p>Ideally, I'd like to run some T-SQL commands directly against the database to get a list of session keys that have been stored for a given session ID. It would be nice to see the serialized data for each key as well.</p>
[ { "answer_id": 153951, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 0, "selected": false, "text": "(function() {\n function copyArray(pa) {\n // Details\n }\n\n Function.prototype.bind = function ( po ...
2008/09/30
[ "https://Stackoverflow.com/questions/153912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23632/" ]
153,920
<p>Code I am trying to run:</p> <pre><code>$query = "DESCRIBE TABLE TABLENAME"; $result = odbc_exec($h, $query); </code></pre> <p>The result:</p> <blockquote> <p>PHP Warning: odbc_exec(): SQL error: [unixODBC][IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0104 - Token TABLENAME was not valid. Valid tokens: INTO., SQL state 37000 in SQLExecDirect in ...</p> </blockquote> <p>There were no other problems with SELECT, INSERT, UPDATE or DELETE queries on the same connection. Is this a syntax error?</p>
[ { "answer_id": 173865, "author": "pmg", "author_id": 25324, "author_profile": "https://Stackoverflow.com/users/25324", "pm_score": 0, "selected": false, "text": "select * from <TABLE> where 0 = 1\n" }, { "answer_id": 184474, "author": "Ian McLaird", "author_id": 18796, ...
2008/09/30
[ "https://Stackoverflow.com/questions/153920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437/" ]
153,928
<p>We currently are using both Visual Source Safe and Team Foundation Server at work (VSS for old projects, TFS for current or new projects).</p> <p>We have always used Labels in source control for each build. In VSS if you chose to see a file history you could include labels. In TFS I cannot find an option to include the lables in the history window.</p> <p>Since one of the most common questions that I get asked by support or management is 'What version did we fix/add/remove/change xxxx?', I have always relied on our build labels showing up in the history. </p> <p>Can I get Labels to show up in a file history? </p>
[ { "answer_id": 6822899, "author": "Mike Sage", "author_id": 862414, "author_profile": "https://Stackoverflow.com/users/862414", "pm_score": 1, "selected": false, "text": "select DisplayName, cs.CreationDate, Comment, 'CheckIn' \nfrom TfsVersionControl.dbo.tbl_Identity i, TfsVersionContro...
2008/09/30
[ "https://Stackoverflow.com/questions/153928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5882/" ]
153,934
<p>I'm trying to modify the class of an element if an ajax call based on that element is successful</p> <pre><code>&lt;script type='text/javascript'&gt; $("#a.toggle").click(function(e){ $.ajax({ url: '/changeItem.php', dataType: 'json', type: 'POST', success: function(data,text){ if(data.error=='') { if($(this).hasClass('class1')) { $(this).removeClass('class1'); $(this).addClass('class2'); } else if($(this).hasClass('class2')) { $(this).removeClass('class2'); $(this).addClass('class1'); } } else(alert(data.error)); } }); return false; }); &lt;/script&gt; &lt;a class="toggle class1" title='toggle-this'&gt;Item&lt;/a&gt; </code></pre> <p>My understanding of the problem is that in the success function <em>this</em> references the ajax object parameters, NOT the calling dom element like it does within other places of the click function. So, how do I reference the calling dom element and check / add / remove classes?</p>
[ { "answer_id": 153948, "author": "Dan Goldstein", "author_id": 23427, "author_profile": "https://Stackoverflow.com/users/23427", "pm_score": 5, "selected": true, "text": "$(\"#a.toggle\").click(function(e)\n{\n var target = $(this);\n $.ajax({\n url: '/changeItem.php',\n da...
2008/09/30
[ "https://Stackoverflow.com/questions/153934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/144/" ]
153,942
<p>After developing a WPF application without Source Control, I decided to add the solution to TFS.</p> <p>After doing so whenever I opened the main window.xaml file in Design View Visual Studio would disappear and the following event would be logged in the Application Event log:</p> <blockquote> <p>.NET Runtime version 2.0.50727.3053 - Fatal Execution Engine Error (7A035E00) (80131506)</p> <p>For more information, see Help and Support Center at <a href="http://go.microsoft.com/fwlink/events.asp" rel="noreferrer">http://go.microsoft.com/fwlink/events.asp</a>.</p> </blockquote>
[ { "answer_id": 463719, "author": "Zhaph - Ben Duguid", "author_id": 33051, "author_profile": "https://Stackoverflow.com/users/33051", "pm_score": 3, "selected": false, "text": "<dependentAssembly>\n <assemblyIdentity name=\"office\" publicKeyToken=\"71e9bce111e9429c\" culture=\"neutral\...
2008/09/30
[ "https://Stackoverflow.com/questions/153942", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13368/" ]
153,944
<p>Is SQL case sensitive? I've used <a href="https://en.wikipedia.org/wiki/MySQL" rel="nofollow noreferrer">MySQL</a> and <a href="https://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a> which both seem to be case insensitive. Is this always the case? Does the standard define case-sensitivity?</p>
[ { "answer_id": 153964, "author": "Dana", "author_id": 7856, "author_profile": "https://Stackoverflow.com/users/7856", "pm_score": 2, "selected": false, "text": "select cOL1, col2 FrOM taBLeName WheRE ...\n" }, { "answer_id": 153965, "author": "cmcculloh", "author_id": 58,...
2008/09/30
[ "https://Stackoverflow.com/questions/153944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/415/" ]
153,953
<p>I’m trying to debug a memory leak problem. I’m using <a href="http://www.gnu.org/software/libc/manual/html_node/Tracing-malloc.html#Tracing-malloc" rel="noreferrer">mtrace()</a> to get a malloc/free/realloc trace. I’ve ran my prog and have now a huge log file. So far so good. But I have problems interpreting the file. Look at these lines:</p> <pre><code>@ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x1502570 0x68 @ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x1502620 0x30 @ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x2aaab43a1700 0xa80 @ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x1501460 0xa64 </code></pre> <p>The strange about this is that one call (same return address) is responsible for 4 allocations.</p> <p>Even stranger:</p> <pre><code>@ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x2aaab43a1700 0xa2c … @ /usr/java/ibm-java2-x86_64-50/jre/bin/libj9prt23.so:[0x2b270a384a34] + 0x2aaab43a1700 0xa80 </code></pre> <p>Between those two lines the block 0x2aaab43a1700 is never being freed.</p> <p>Does anyone know how to explain this? How could one call result in 4 allocations? And how could malloc return an address which was already allocated previously?</p> <p>edit 2008/09/30: The script to analyze the mtrace() output provided by GLIBC (mtrace.pl) isn't of any help here. It will just say: Alloc 0x2aaab43a1700 duplicate. But how could this happen?</p>
[ { "answer_id": 154419, "author": "Sufian", "author_id": 9241, "author_profile": "https://Stackoverflow.com/users/9241", "pm_score": 3, "selected": false, "text": "$ gcc -g -o test test.c\n$ MALLOC_TRACE=mtrace.out ./test\n$ mtrace test mtrace.out\n\nMemory not freed:\n-----------------\n...
2008/09/30
[ "https://Stackoverflow.com/questions/153953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17428/" ]
153,974
<p>I'm wondering how (un)common it is to encapsulate an algorithm into a class? More concretely, instead of having a number of separate functions that forward common parameters between each other:</p> <pre><code>void f(int common1, int param1, int *out1); void g(int common1, int common2, int param1, int *out2) { f(common1, param1, ..); } </code></pre> <p>to encapsulate common parameters into a class and do all of the work in the constructor:</p> <pre><code>struct Algo { int common1; int common2; Algo(int common1, int common2, int param) { // do most of the work } void f(int param1, int *out1); void g(int param1, int *out2); }; </code></pre> <p>It seems very practical not having to forward common parameters and intermediate results through function arguments.. But I haven't seen this "pattern" being widely used.. What are the possible downsides?</p>
[ { "answer_id": 154001, "author": "David Segonds", "author_id": 13673, "author_profile": "https://Stackoverflow.com/users/13673", "pm_score": 1, "selected": false, "text": "class MyFunctor {\n public:\n MyFunctor( /* List of Parameters */ );\n bool execute();\n private:\...
2008/09/30
[ "https://Stackoverflow.com/questions/153974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2583/" ]
153,983
<p>For some reason the Windows command prompt is "special" in that you have to go to a properties dialog to resize it horizontally rather than just dragging the corner of the window like every other app. Unsurprisingly this feature made it into P-P-P-Powershell as well -- is there any way around this via command prompt replacement or Windows hackery?</p>
[ { "answer_id": 188086, "author": "avgbody", "author_id": 8737, "author_profile": "https://Stackoverflow.com/users/8737", "pm_score": 4, "selected": false, "text": "##\n## Author : Roman Kuzmin\n## Synopsis : Resize console window/buffer using arrow keys\n##\n\nfunction Size($w, $h)\n{\...
2008/09/30
[ "https://Stackoverflow.com/questions/153983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/327/" ]
153,988
<p>I need to copy some records from our SQLServer 2005 test server to our live server. It's a flat lookup table, so no foreign keys or other referential integrity to worry about.</p> <p>I could key-in the records again on the live server, but this is tiresome. I could export the test server records and table data in its entirety into an SQL script and run that, but I don't want to overwrite the records present on the live system, only add to them.</p> <p>How can I select just the records I want and get them transferred or otherwise into the live server? We don't have Sharepoint, which I understand would allow me to copy them directly between the two instances.</p>
[ { "answer_id": 154071, "author": "Kwirk", "author_id": 21879, "author_profile": "https://Stackoverflow.com/users/21879", "pm_score": 7, "selected": true, "text": "Execute sp_addlinkedserver PRODUCTION_SERVER_NAME\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/153988", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7703/" ]
153,989
<p>I have a little logging app (written in wxPython) that receives data from a bit of kit we're developing, and I want to display the text in a scrolling window. As it stands I'm using a wx.TextCtrl for the text display, but I'm having some issues with the scrolling behaviour.</p> <p>Basically, I'd like it so that if the scrollbar is at the bottom of the window (i.e. the end of the incoming data), adding more data should scroll the view onwards. If, however the view has been scrolled up a little (i.e. the user is looking at something interesting like an error message), the app should just add the text on the end without scrolling any more.</p> <p>I've got two problems at the moment:</p> <ol> <li>I can't work out how to retrieve the current scroll position (calls to GetScrollPos() don't seem to work - they just return 0).</li> <li>I can't work out how to retrieve the current range of the scroll bar (calls to GetScrollRange() just return 1).</li> </ol> <p>I've googled a bit and there seem to be a few hints that suggest GetScrollPos and GetScrollRange won't work for a wx.TextCtrl? Has anyone else had any experience in this area? Is there a nice easy way to solve the problem or am I going to have to roll my own wx.TextCtrl?</p>
[ { "answer_id": 154225, "author": "DzinX", "author_id": 18745, "author_profile": "https://Stackoverflow.com/users/18745", "pm_score": 2, "selected": true, "text": "GetScrollPos(0)" }, { "answer_id": 155781, "author": "Jon Cage", "author_id": 15369, "author_profile": "h...
2008/09/30
[ "https://Stackoverflow.com/questions/153989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15369/" ]
153,994
<p>I want to have a class which implements an interface, which specifies the specific subclass as a parameter.</p> <pre><code>public abstract Task implements TaskStatus&lt;Task&gt; { TaskStatus&lt;T&gt; listener; protected complete() { // ugly, unsafe cast callback.complete((T) this); } } public interface TaskStatus&lt;T&gt; { public void complete(T task); } </code></pre> <p>But instead of just task, or , I want to guarantee the type-arg used is that of the specific class extending this one.</p> <p>So the best I've come up with is:</p> <pre><code>public abstract Task&lt;T extends Task&gt; implements TaskStatus&lt;T&gt; { } </code></pre> <p>You'd extend that by writing:</p> <pre><code>public class MyTask extends Task&lt;MyTask&gt; { } </code></pre> <p>But this would also be valid:</p> <pre><code>public class MyTask extends Task&lt;SomeOtherTask&gt; { } </code></pre> <p>And the invocation of callback will blow up with ClassCastException. So, is this approach just wrong and broken, or is there a right way to do this I've somehow missed?</p>
[ { "answer_id": 154340, "author": "Bruno De Fraine", "author_id": 6918, "author_profile": "https://Stackoverflow.com/users/6918", "pm_score": 3, "selected": true, "text": "Task" }, { "answer_id": 154363, "author": "Tom Hawtin - tackline", "author_id": 4725, "author_pro...
2008/09/30
[ "https://Stackoverflow.com/questions/153994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/758/" ]
154,004
<p>I have a link that I dynamically create which looks something like the following:</p> <pre><code>&lt;a onclick="Edit('value from a text column here')" href="javascript:void(null);"&gt;Edit&lt;/a&gt; </code></pre> <p>with the Edit function then taking the passed in value and putting it into a Yahoo Rich Text Editor. This works well except for when there is a single quote in the text being passed. The obvious problem being that the link then looks something like:</p> <pre><code>&lt;a onclick="Edit('I'm a jelly donut')" href="javascript:void(null);"&gt;Edit&lt;/a&gt; </code></pre> <p>Any suggestions on what I can do? I'd rather not stray too far from the structure I am currently using because it is something of a standard (and maybe the standard sucks, but that's another question altogether).</p> <p>Note: I am using ASP as my server side language.</p>
[ { "answer_id": 154018, "author": "Chris Johnson", "author_id": 23732, "author_profile": "https://Stackoverflow.com/users/23732", "pm_score": 5, "selected": true, "text": "&quot;" }, { "answer_id": 155095, "author": "paercebal", "author_id": 14089, "author_profile": "h...
2008/09/30
[ "https://Stackoverflow.com/questions/154004", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22777/" ]
154,013
<p>My Django app has a Person table, which contains the following text in a field named <code>details</code>:</p> <p><code>&lt;script&gt;alert('Hello');&lt;/script&gt;</code></p> <p>When I call <code>PersonForm.details</code> in my template, the page renders the script accordingly (a.k.a., an alert with the word "Hello" is displayed). I'm confused by this behavior because I always thought <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs" rel="nofollow noreferrer">Django 1.0 autoescaped</a> template content by default.</p> <p>Any idea what may be going on here?</p> <p><strong>UPDATE:</strong> Here's the snippet from my template. Nothing terribly sexy:</p> <pre><code>{{ person_form.details }} </code></pre> <p><strong>UPDATE 2:</strong> I have tried <code>escape</code>, <code>force-escape</code>, and <code>escapejs</code>. None of these work.</p>
[ { "answer_id": 154027, "author": "Jon Cage", "author_id": 15369, "author_profile": "https://Stackoverflow.com/users/15369", "pm_score": 4, "selected": true, "text": "{{ value|safe }}\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10040/" ]
154,031
<pre><code>Pattern pattern = Pattern.compile("^[a-z]+$"); String string = "abc-def"; assertTrue( pattern.matcher(string).matches() ); // obviously fails </code></pre> <p>Is it possible to have the character class match a "-" ?</p>
[ { "answer_id": 154037, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 3, "selected": false, "text": "[a-z\\\\-]\n" }, { "answer_id": 154040, "author": "Tomalak", "author_id": 18771, "author_profile": "...
2008/09/30
[ "https://Stackoverflow.com/questions/154031", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11858/" ]
154,042
<p>I'm using spring 2.5 and annotations to configure my spring-mvc web context. Unfortunately, I am unable to get the following to work. I'm not sure if this is a bug (seems like it) or if there is a basic misunderstanding on how the annotations and interface implementation subclassing works.</p> <p>For example,</p> <pre><code>@Controller @RequestMapping("url-mapping-here") public class Foo { @RequestMapping(method=RequestMethod.GET) public void showForm() { ... } @RequestMapping(method=RequestMethod.POST) public String processForm() { ... } } </code></pre> <p>works fine. When the context starts up, the urls this handler deals with are discovered, and everything works great. </p> <p>This however does not:</p> <pre><code>@Controller @RequestMapping("url-mapping-here") public class Foo implements Bar { @RequestMapping(method=RequestMethod.GET) public void showForm() { ... } @RequestMapping(method=RequestMethod.POST) public String processForm() { ... } } </code></pre> <p>When I try to pull up the url, I get the following nasty stack trace:</p> <pre><code>javax.servlet.ServletException: No adapter for handler [com.shaneleopard.web.controller.RegistrationController@e973e3]: Does your handler implement a supported interface like Controller? org.springframework.web.servlet.DispatcherServlet.getHandlerAdapter(DispatcherServlet.java:1091) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) javax.servlet.http.HttpServlet.service(HttpServlet.java:627) </code></pre> <p>However, if I change Bar to be an abstract superclass and have Foo extend it, then it works again.</p> <pre><code>@Controller @RequestMapping("url-mapping-here") public class Foo extends Bar { @RequestMapping(method=RequestMethod.GET) public void showForm() { ... } @RequestMapping(method=RequestMethod.POST) public String processForm() { ... } } </code></pre> <p>This seems like a bug. The @Controller annotation should be sufficient to mark this as a controller, and I should be able to implement one or more interfaces in my controller without having to do anything else. Any ideas?</p>
[ { "answer_id": 2358726, "author": "Michal Bachman", "author_id": 220912, "author_profile": "https://Stackoverflow.com/users/220912", "pm_score": 4, "selected": false, "text": "<bean class=\"org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping\"/>\n<bean class=\"...
2008/09/30
[ "https://Stackoverflow.com/questions/154042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9955/" ]
154,059
<p>Is there a <code>string.Empty</code> in JavaScript, or is it just a case of checking for <code>&quot;&quot;</code>?</p>
[ { "answer_id": 154068, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 13, "selected": true, "text": "if (strValue) {\n // strValue was non-empty string, true, 42, Infinity, [], ...\n}\n" }, { "answer_id": 154073, ...
2008/09/30
[ "https://Stackoverflow.com/questions/154059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5619/" ]
154,075
<p>I have a Virtual Machine in Virtual PC 2007.</p> <p>To start it from the desktop, I have the following command in a batch file:</p> <pre><code>"c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch </code></pre> <p>But that leaves a dos prompt on the host machine until the virtual machine shuts down, and I exit out of the Virtual PC console. That's annoying.</p> <p>So I changed my command to use the START command, instead:</p> <pre><code>start "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc MY-PC -launch </code></pre> <p>But it chokes on the parameters passed into Virtual PC.</p> <p><code>START /?</code> indicates that parameters do indeed go in that location. Has anyone used START to launch a program with multiple command-line arguments?</p>
[ { "answer_id": 154083, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": -1, "selected": false, "text": "start \"c:\\program files\\Microsoft Virtual PC\\Virtual PC.exe\" \"-pc MY-PC -launch\"\n" }, { "answer_id": 15...
2008/09/30
[ "https://Stackoverflow.com/questions/154075", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
154,078
<p>When I open a file in eclipse it shows with the improper line spacing showing an extra line break between every line. When I open the file with notepad or wordpad it doesn't show these extra line breaks that only eclipse shows. How do I get eclipse to read these files like notepad and wordpad without those line breaks?</p> <p>-edit: I don't have this problem with all files but only a select few where I have made local changes > uploaded them to our sun station > then pulled those files back to my local workstation for future modifications.</p>
[ { "answer_id": 154125, "author": "Nate", "author_id": 12779, "author_profile": "https://Stackoverflow.com/users/12779", "pm_score": 3, "selected": false, "text": "File -> Convert Line Delimiters To..." } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5831/" ]
154,079
<p>I have a number of RGBA pixels, each of them has an alpha component.</p> <p>So I have a list of pixels: (<em>p0 p1 p2 p3 p4 ... pn</em>) where p_0_ is the front pixel and p_n_ is the farthest (at the back).</p> <p>The last (or any) pixel is not necessary opaque, so the resulting blended pixel can be somehow transparent also. I'm blending from the beginning of the list to the end, not vice-versa (yes, it is raytracing). So if the result at any moment becomes opaque enough I can stop with correct enough result. I'll apply the blending algorithm in this way: ((((<em>p0</em> @ <em>p1</em>) @ <em>p2</em>) @ <em>p3</em>) ... )</p> <p>Can anyone suggest me a correct blending formula not only for R, G and B, but for A component also?</p> <p><strong>UPD</strong>: I wonder how is it possible that for determined process of blending colors we can have many formulas? Is it some kind of aproximation? This looks crazy, as for me: formulas are not so different that we really gain efficiency or optimization. Can anyone clarify this?</p>
[ { "answer_id": 154108, "author": "Chris Johnson", "author_id": 23732, "author_profile": "https://Stackoverflow.com/users/23732", "pm_score": 2, "selected": false, "text": "lightr=lightg=lightb=0" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20514/" ]
154,089
<p>Anyone know how to programmatically mute the Windows XP Volume using C#?</p>
[ { "answer_id": 154128, "author": "Jorge Ferreira", "author_id": 6508, "author_profile": "https://Stackoverflow.com/users/6508", "pm_score": 4, "selected": false, "text": "private const int APPCOMMAND_VOLUME_MUTE = 0x80000;\nprivate const int WM_APPCOMMAND = 0x319;\n\n[DllImport(\"user32....
2008/09/30
[ "https://Stackoverflow.com/questions/154089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1316/" ]
154,097
<p>I've switched computers a few times recently, and somewhere along the way I lost my .emacs. I'm trying to build it up again, but while I'm at it, I thought I'd pick up other good configurations that other people use.</p> <p>So, if you use Emacs, what's in <i>your</i> .emacs?</p> <p>Mine is pretty barren right now, containing only:</p> <ol> <li>Global font-lock-mode! <code>(global-font-lock-mode 1)</code></li> <li>My personal preferences with respect to indentation, tabs, and spaces.</li> <li>Use cperl-mode instead of perl-mode.</li> <li>A shortcut for compilation.</li> </ol> <p>What do you think is useful?</p>
[ { "answer_id": 154105, "author": "David Nehme", "author_id": 14167, "author_profile": "https://Stackoverflow.com/users/14167", "pm_score": 1, "selected": false, "text": "(put 'erase-buffer 'disabled nil)\n(put 'downcase-region 'disabled nil)\n(set-variable 'visible-bell t)\n(set-variable...
2008/09/30
[ "https://Stackoverflow.com/questions/154097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3508/" ]
154,109
<p>When using the ObsoleteAtribute in .Net it gives you compiler warnings telling you that the object/method/property is obsolete and somthing else should be used. I'm currently working on a project that requires a lot of refactoring an ex-employees code. I want to write a custom attribute that I can use to mark methods or properties that will generate compiler warnings that give messages that I write. Something like this</p> <pre class="lang-cs prettyprint-override"><code>[MyAttribute("This code sux and should be looked at")] public void DoEverything() { } </code></pre> <pre class="lang-vb prettyprint-override"><code>&lt;MyAttribute("This code sux and should be looked at")&gt; Public Sub DoEverything() End Sub </code></pre> <p>I want this to generate a compiler warning that says, "This code sux and should be looked at". I know how to create a custom attribute, the question is how do I cause it to generate compiler warnings in visual studio.</p>
[ { "answer_id": 154120, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 6, "selected": false, "text": "#warning \"Do not use ABC, which is deprecated. Use XYZ instead.\"\n" }, { "answer_id": 154254, "author": ...
2008/09/30
[ "https://Stackoverflow.com/questions/154109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17744/" ]
154,112
<p>Without running this code, identify which <code>Foo</code> method will be called:</p> <pre><code>class A { public void Foo( int n ) { Console.WriteLine( "A::Foo" ); } } class B : A { /* note that A::Foo and B::Foo are not related at all */ public void Foo( double n ) { Console.WriteLine( "B::Foo" ); } } static void Main( string[] args ) { B b = new B(); /* which Foo is chosen? */ b.Foo( 5 ); } </code></pre> <p>Which method? And why? No cheating by running the code.</p> <p>I found this puzzle on the web; I like it and I think I'm going to use it as an interview question...Opinions?</p> <p>EDIT: I wouldn't judge a candidate on getting this wrong, I'd use it as a way to open a fuller discussion about the C# and CLR itself, so I can get a good understanding of the candidates abilities.</p> <p><strong>Source:</strong> <a href="http://netpl.blogspot.com/2008/06/c-puzzle-no8-beginner.html" rel="noreferrer">http://netpl.blogspot.com/2008/06/c-puzzle-no8-beginner.html</a></p>
[ { "answer_id": 155771, "author": "Mike Rosenblum", "author_id": 10429, "author_profile": "https://Stackoverflow.com/users/10429", "pm_score": 3, "selected": false, "text": "Public Class Form1\n Private Sub Button1_Click(ByVal sender As System.Object, _\n B...
2008/09/30
[ "https://Stackoverflow.com/questions/154112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1965/" ]
154,119
<p>This was an interview question. Given Visual Studio 2008 and an icon saved as a .PNG file, they required the image as an embedded resource and to be used as the icon within the title bar of a form.</p> <p>I'm looking for what would have been the model answer to this question, Both (working!) code and any Visual Studio tricks. (Model answer is one that should get me the job if I meet it next time around.)</p> <p>Specifically I don't know how to load the image once it is an embedded resource nor how to get it as the icon for the title bar.</p> <p>As a part solution, ignoring the embedded bit, I copied the resource to the ouput directory and tried the following:-</p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Icon = new Icon("Resources\\IconImage.png"); } } </code></pre> <p>This failed with the error "Argument 'picture' must be a picture that can be used as a Icon."</p> <p>I presuming that the .PNG file actually needed to be a .ICO, but I couldn't see how to make the conversion. Is this presumption correct or is there a different issue?</p>
[ { "answer_id": 156118, "author": "Silver Dragon", "author_id": 9440, "author_profile": "https://Stackoverflow.com/users/9440", "pm_score": 7, "selected": true, "text": " public Form1()\n {\n InitializeComponent();\n Bitmap bmp = WindowsFormsApplication10.Prop...
2008/09/30
[ "https://Stackoverflow.com/questions/154119", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
154,132
<p>What are the most common browser compatibility issues across the major desktop browsers?</p> <p>No dups please. Up-vote problems you've run into. I'm hoping for the list to self-sort. "IE sux" is not a pitfall, but a call for down-vote.</p> <p>[Edit] Yes, I know it's a poll - I'm not posting answers in this to gather points - I'm actually interested in knowing what people typically run into.</p>
[ { "answer_id": 155639, "author": "Adam Franco", "author_id": 15872, "author_profile": "https://Stackoverflow.com/users/15872", "pm_score": 2, "selected": false, "text": "function getOffsetTop (element) {\n var offset = 0;\n\n if (element.offsetTop)\n offset = offset + elemen...
2008/09/30
[ "https://Stackoverflow.com/questions/154132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4489/" ]
154,136
<p>In many C/C++ macros I'm seeing the code of the macro wrapped in what seems like a meaningless <code>do while</code> loop. Here are examples.</p> <pre><code>#define FOO(X) do { f(X); g(X); } while (0) #define FOO(X) if (1) { f(X); g(X); } else </code></pre> <p>I can't see what the <code>do while</code> is doing. Why not just write this without it?</p> <pre><code>#define FOO(X) f(X); g(X) </code></pre>
[ { "answer_id": 154138, "author": "jfm3", "author_id": 11138, "author_profile": "https://Stackoverflow.com/users/11138", "pm_score": 11, "selected": true, "text": "do ... while" }, { "answer_id": 154239, "author": "Michael Burr", "author_id": 12711, "author_profile": "...
2008/09/30
[ "https://Stackoverflow.com/questions/154136", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11138/" ]
154,159
<p>Looking for good techniques to justify "great than normal" machine for developers. The company I work for buys the same underpowered $500 dollar systems for everyone, and looking for ways to prove ROI or arguments to use. Sorry, I didn't say this in the initial question, the stack is VS 2008, SQL 2005/2008. As duties dictate we are SQL admins as well as Web/Winform/WebService Developers. So its very typical to have 2 VS sessions and at least one SQL session open at the same time.</p>
[ { "answer_id": 154229, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 2, "selected": false, "text": "AnnualSavings := DeveloperCostPerHour * (AnnualWaitHours(OldPC) - AnnualWaitHours(NewPC));\n\nif AnnualSavings > (Machine...
2008/09/30
[ "https://Stackoverflow.com/questions/154159", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
154,163
<p>I need to detect whether my application is running within a virtualized OS instance or not.</p> <p>I've found <A HREF="http://www.codeproject.com/KB/system/VmDetect.aspx" rel="noreferrer">an article</A> with some useful information on the topic. The same article appears in multiple places, I'm unsure of the original source. <A HREF="http://www.vmware.com/" rel="noreferrer">VMware</A> implements a particular invalid x86 instruction to return information about itself, while <A HREF="http://www.microsoft.com/windows/products/winfamily/virtualpc/default.mspx" rel="noreferrer">VirtualPC</A> uses a magic number and I/O port with an IN instruction.</p> <p>This is workable, but appears to be undocumented behavior in both cases. I suppose a future release of VMWare or VirtualPC might change the mechanism. Is there a better way? Is there a supported mechanism for either product?</p> <p>Similarly, is there a way to detect <A HREF="http://www.xen.org/" rel="noreferrer">Xen</A> or <A HREF="http://www.virtualbox.org/" rel="noreferrer">VirtualBox</A>?</p> <p>I'm not concerned about cases where the platform is deliberately trying to hide itself. For example, honeypots use virtualization but sometimes obscure the mechanisms that malware would use to detect it. I don't care that my app would think it is not virtualized in these honeypots, I'm just looking for a "best effort" solution.</p> <p>The application is mostly Java, though I'm expecting to use native code plus JNI for this particular function. Windows XP/Vista support is most important, though the mechanisms described in the referenced article are generic features of x86 and don't rely on any particular OS facility.</p>
[ { "answer_id": 154222, "author": "sven", "author_id": 46, "author_profile": "https://Stackoverflow.com/users/46", "pm_score": 7, "selected": true, "text": " int swallow_redpill () {\n unsigned char m[2+4], rpill[] = \"\\x0f\\x01\\x0d\\x00\\x00\\x00\\x00\\xc3\";\n *((unsigned*)&rpill[...
2008/09/30
[ "https://Stackoverflow.com/questions/154163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4761/" ]
154,179
<p>I'm refactoring some code currently implemented in stored procedures to use LinqToSql (for use in training). Is it possible to use SQL functions in a linqToSql Query?</p>
[ { "answer_id": 16965126, "author": "jpierson", "author_id": 83658, "author_profile": "https://Stackoverflow.com/users/83658", "pm_score": 0, "selected": false, "text": " [Function(Name=\"SoundEx\", IsComposable = true)]\n public string SoundsLike(string input)\n {\n throw...
2008/09/30
[ "https://Stackoverflow.com/questions/154179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
154,185
<p>I have heard this concept used frequently, but I don't have a really good grasp of what it is.</p>
[ { "answer_id": 154214, "author": "Firas Assaad", "author_id": 23153, "author_profile": "https://Stackoverflow.com/users/23153", "pm_score": 3, "selected": false, "text": "srcplayer = Player.new\n# marshal (store it as string)\nstr = Marshal.dump(srcplayer)\n#unmarshal (get it back)\ndest...
2008/09/30
[ "https://Stackoverflow.com/questions/154185", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3208/" ]
154,204
<p>Is there any way to change the default tab size in a .NET RichTextBox? It currently seems to be set to the equivalent of 8 spaces which is kinda large for my taste.</p> <p>Edit: To clarify, I want to set the global default of "\t" displays as 4 spaces for the control. From what I can understand, the SelectionTabs property requires you to select all the text first and then the the tab widths via the array. I will do this if I have to, but I would rather just change the global default once, if possible, sot that I don't have to do that every time.</p>
[ { "answer_id": 154255, "author": "Scott Nichols", "author_id": 4299, "author_profile": "https://Stackoverflow.com/users/4299", "pm_score": 6, "selected": true, "text": "private void Form1_Load(object sender, EventArgs e)\n{\n richTextBox1.SelectionTabs = new int[] { 100, 200, 300, 400...
2008/09/30
[ "https://Stackoverflow.com/questions/154204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/194/" ]
154,206
<p>I am trying to use a DynamicResource in Storyboard contained within a ControlTemplate.</p> <p>But, when I try to do this, I get a 'Cannot freeze this Storyboard timeline tree for use across threads' error.</p> <p>What is going on here?</p>
[ { "answer_id": 71658836, "author": "SWSBB", "author_id": 11776148, "author_profile": "https://Stackoverflow.com/users/11776148", "pm_score": 0, "selected": false, "text": "DynamicResource" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154206", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22294/" ]
154,245
<p>Ok, this is a bit of a cheeky question. I want to build a simple text editor (using my own text mode screen handling). I just want a good example of data structures that can be used to represent the text buffer, and some simple examples of char/text insertion/deletion. I can handle all the rest of the code myself (file i/o, console i/o etc). A link to a nice simple editor source would be great (C or C++).</p>
[ { "answer_id": 154349, "author": "Kluge", "author_id": 8752, "author_profile": "https://Stackoverflow.com/users/8752", "pm_score": 2, "selected": false, "text": "while (editing) {\n GetCharacter();\n ProcessCharacter();\n UpdateDisplay();\n}\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3685/" ]
154,248
<p>I tried:</p> <pre><code>DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(f); Node mapNode = getMapNode(doc); System.out.print("\r\n elementName "+ mapNode.getNodeName());//This works fine. Element e = (Element) mapNode; //This is where the error occurs //it seems to work on my machine, but not on the server. e.setAttribute("objectId", "OBJ123"); </code></pre> <p>But this throws a java.lang.ClassCastException error on the line that casts it to Element. <strong>mapNode is a valid node.</strong> I already have it printing out </p> <p>I think maybe this code does not work in Java 1.4. What I really need is an alternative to using Element. I tried doing</p> <pre><code>NamedNodeMap atts = mapNode.getAttributes(); Attr att = doc.createAttribute("objId"); att.setValue(docId); atts.setNamedItem(att); </code></pre> <p>But getAttributes() returns null on the server. Even though its not and I am using the same document locally as on the server. And it can print out the getNodeName() its just that the getAttributes() does not work.</p>
[ { "answer_id": 154297, "author": "Garth Gilmour", "author_id": 2635682, "author_profile": "https://Stackoverflow.com/users/2635682", "pm_score": 0, "selected": false, "text": "System.out.println(doc.getFirstChild().getClass().getName());\n" }, { "answer_id": 154370, "author":...
2008/09/30
[ "https://Stackoverflow.com/questions/154248", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5653/" ]
154,256
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/105372/c-how-to-enumerate-an-enum">C#: How to enumerate an enum?</a> </p> </blockquote> <p>The subject says all. I want to use that to add the values of an enum in a combobox.</p> <p>Thanks</p> <p>vIceBerg</p>
[ { "answer_id": 154263, "author": "albertein", "author_id": 23020, "author_profile": "https://Stackoverflow.com/users/23020", "pm_score": 6, "selected": true, "text": "string[] names = Enum.GetNames (typeof(MyEnum));\n" }, { "answer_id": 154266, "author": "JosephStyons", "...
2008/09/30
[ "https://Stackoverflow.com/questions/154256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17766/" ]
154,261
<p>I frequently run into problems of this form and haven't found a good solution yet:</p> <p>Assume we have two database tables representing an e-commerce system.</p> <pre><code>userData (userId, name, ...) orderData (orderId, userId, orderType, createDate, ...) </code></pre> <p>For all users in the system, select their user information, their most recent order information with type = '1', and their most recent order information with type = '2'. I want to do this in one query. Here is an example result:</p> <pre><code>(userId, name, ..., orderId1, orderType1, createDate1, ..., orderId2, orderType2, createDate2, ...) (101, 'Bob', ..., 472, '1', '4/25/2008', ..., 382, '2', '3/2/2008', ...) </code></pre>
[ { "answer_id": 154272, "author": "Patrick Desjardins", "author_id": 13913, "author_profile": "https://Stackoverflow.com/users/13913", "pm_score": 0, "selected": false, "text": "SELECT * FROM\n\"orderData\", \"userData\"\nWHERE\n\"userData\".\"userId\" =\"orderData\".\"userId\"\nAND \"or...
2008/09/30
[ "https://Stackoverflow.com/questions/154261", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9304/" ]
154,262
<p>It's very easy to mark an image file to become an embedded resource however how does one access the image thereafter. Please can I have some example code?</p>
[ { "answer_id": 154276, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 4, "selected": false, "text": "YourProjectsBaseNamespace.Properties.Resources.YourImageResourceName\n" }, { "answer_id": 154278, "author": "Gulza...
2008/09/30
[ "https://Stackoverflow.com/questions/154262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22284/" ]
154,270
<p>It's been a while since I've programmed a GUI program, so this may end up being super simple, but I can't find the solution anywhere online. </p> <p>Basically my problem is that when I maximize my program, all the things inside of the window (buttons, textboxes, etc.) stay in the same position in the window, which results in a large blank area near the bottom and right side. </p> <p>Is there a way of making the the elements in the program to stretch to scale?</p>
[ { "answer_id": 154359, "author": "Brian Ensink", "author_id": 1254, "author_profile": "https://Stackoverflow.com/users/1254", "pm_score": 0, "selected": false, "text": "FlowLayoutPanel" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23875/" ]
154,295
<p>In the latest MVC preview, I'm using this route for a legacy URL:</p> <pre><code>routes.MapRoute( "Legacy-Firefox", // Route name "Firefox-Extension/", // URL with parameters new { controller = "Home", action = "Firefox", id = "" } // Parameter defaults ); </code></pre> <p>The problem is that both of these URL's work: <a href="http://example.com/Firefox-Extension" rel="nofollow noreferrer">http://example.com/Firefox-Extension</a> <a href="http://example.com/Firefox-Extension/" rel="nofollow noreferrer">http://example.com/Firefox-Extension/</a></p> <p>I only want the second to work (for SEO). Also, when I create a link to that page, the routing engine gives me back a URL without a trailing slash.</p> <p>This is the code I'm using to generate the link:</p> <pre><code>&lt;%= Html.ActionLink("Firefox Extension", "Firefox", "Home")%&gt; </code></pre> <p>I believe can fix the first problem by using an HTTP handler to do a 301 redirect to the URL with the trailing slash. However, I want to link to the URL with the trailing slash, and I'm hoping to not have to hard-code the version with the slash.</p> <p>Anyone know how to force the route to use a trailing slash?</p>
[ { "answer_id": 955620, "author": "Murad X", "author_id": 68294, "author_profile": "https://Stackoverflow.com/users/68294", "pm_score": 2, "selected": false, "text": "public static string RouteLinkEx(this HtmlHelper helper,string text,string routeName,RouteValueDictionary rvd,object htmlA...
2008/09/30
[ "https://Stackoverflow.com/questions/154295", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23837/" ]
154,299
<p>I am debugging a VB6 executable. The executable loads dlls and files from it's current directory, when running. When run in debugger, the current directory seems to be VB6's dir. </p> <p>How do I set working directory for VB6?</p>
[ { "answer_id": 154327, "author": "Gulzar Nazim", "author_id": 4337, "author_profile": "https://Stackoverflow.com/users/4337", "pm_score": 2, "selected": false, "text": "'Declaration\nPrivate Declare Function SetCurrentDirectory Lib \"kernel32\" _\nAlias \"SetCurrentDirectoryA\" (ByVal lp...
2008/09/30
[ "https://Stackoverflow.com/questions/154299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/814/" ]
154,305
<p>Given the following canvas:</p> <pre><code>&lt;Canvas&gt; &lt;Canvas.LayoutTransform&gt; &lt;ScaleTransform ScaleX="1" ScaleY="1" CenterX=".5" CenterY=".5" /&gt; &lt;/Canvas.LayoutTransform&gt; &lt;Button x:Name="scaleButton" Content="Scale Me" Canvas.Top="10" Canvas.Left="10" /&gt; &lt;Button x:Name="dontScaleButton" Content="DON'T Scale Me" Canvas.Top="10" Canvas.Left="50" /&gt; &lt;/Canvas&gt; </code></pre> <p>Is it possible to scale 1 button, but not the other when ScaleX and ScaleY changes?</p>
[ { "answer_id": 154500, "author": "Joel B Fant", "author_id": 22211, "author_profile": "https://Stackoverflow.com/users/22211", "pm_score": 2, "selected": false, "text": "Canvas" }, { "answer_id": 5671474, "author": "H.B.", "author_id": 546730, "author_profile": "https...
2008/09/30
[ "https://Stackoverflow.com/questions/154305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4580/" ]
154,307
<p>I just saw this behaviour and I'm a bit surprised by it...</p> <p>If I add 3 or 4 elements to a Dictionary, and then do a "For Each" to get all the keys, they appear in the same order I added them.</p> <p>The reason this surprises me is that a Dictionary is supposed to be a HashTable internally, so I expected things to come out in ANY order (ordered by the hash of the key, right?)</p> <p>What am I missing here? Is this a behaviour I can count on?</p> <p>EDIT: OK, I thought already of many of the reasons why this <em>might</em> happen (like the separate list to entries, whether this is a coincidence, etc). My question is, does anyone <strong>know</strong> how this really works?</p>
[ { "answer_id": 976871, "author": "Dolphin", "author_id": 110672, "author_profile": "https://Stackoverflow.com/users/110672", "pm_score": 6, "selected": true, "text": "add 1\nadd 2\nadd 3\nadd 4\nremove 2\nadd 5\n" } ]
2008/09/30
[ "https://Stackoverflow.com/questions/154307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
154,309
<p>One of our programs is sometimes getting an <code>OutOfMemory</code> error on one user's machine, but of course not when I'm testing it. I just ran it with JProfiler (on a 10 day evaluation license because I've never used it before), and filtering on our code prefix, the biggest chunk both in total size and number of instances is 8000+ instances of a particular simple class. </p> <p>I clicked the "Garbage Collect" button on JProfiler, and most instances of other classes of ours went away, but not these particular ones. I ran the test again, still in the same instance, and it created 4000+ more instances of the class, but when I clicked "Garbage Collect", those went away leaving the 8000+ original ones.</p> <p>These instances do get stuck into various Collections at various stages. I assume that the fact that they're not garbage collected must mean that something is holding onto a reference to one of the collections so that's holding onto a reference to the objects.</p> <p>Any suggestions how I can figure out what is holding onto the reference? I'm looking for suggestions of what to look for in the code, as well as ways to find this out in JProfiler if there are.</p>
[ { "answer_id": 154454, "author": "18Rabbit", "author_id": 12662, "author_profile": "https://Stackoverflow.com/users/12662", "pm_score": 3, "selected": false, "text": "Map<String, Object> map = new HashMap<String, Object>(); // 1 Object\nString name = \"test\"; // 2 Objects\nO...
2008/09/30
[ "https://Stackoverflow.com/questions/154309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3333/" ]
154,314
<p>I've found a couple of references (<a href="http://www.javapractices.com/topic/TopicAction.do?Id=23" rel="noreferrer">for example</a>) that suggest using <code>final</code> as much as possible and I'm wondering how important that is. This is mainly in the the context of method parameters and local variables, not final methods or classes. For constants, it makes obvious sense.</p> <p>On one hand, the compiler can make some optimizations and it makes the programmer's intent clearer. On the other hand, it adds verbosity and the optimizations may be trivial.</p> <p>Is it something I should make an effort to remember?</p>
[ { "answer_id": 154510, "author": "Alex Miller", "author_id": 7671, "author_profile": "https://Stackoverflow.com/users/7671", "pm_score": 9, "selected": true, "text": "if" }, { "answer_id": 155881, "author": "Sam Stokes", "author_id": 20131, "author_profile": "https://...
2008/09/30
[ "https://Stackoverflow.com/questions/154314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23669/" ]
154,332
<p>I'm using <strong>mysqldump</strong> to replicate a database between accounts on a particular machine. Everything works just great, except when we get to our defined views. Because the dump includes a line like the following ...</p> <pre><code>/*!50013 DEFINER=`user_a`@`localhost` SQL SECURITY DEFINER */ </code></pre> <p>... when loading the dump into mysql on user_b we receive an error: </p> <pre><code>ERROR 1227 (42000) at line 657: Access denied; you need the SUPER privilege for this operation </code></pre> <p>Needless to say, I don't have SUPER privilege on this mysql instance. Is there a way to convince <strong>mysqldump</strong> to dump the views in a user-agnostic way? I can't find anything in the manual on this point. Do I have to actually parse the dumpfile to replace the usernames? Or am I missing something?</p>
[ { "answer_id": 313854, "author": "user40237", "author_id": 40237, "author_profile": "https://Stackoverflow.com/users/40237", "pm_score": 6, "selected": true, "text": "mysqldump -uuser1 -ppassword1 database1 > backup.sql\n\nsed '/^\\/\\*\\!50013 DEFINER/d' backup.sql > backup_without_5001...
2008/09/30
[ "https://Stackoverflow.com/questions/154332", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21632/" ]
154,365
<p>I need to find occurrences of ~ 25 000 words within a text. What is the most suitable algorithm/library for this purpose?</p> <p>target language is C++</p>
[ { "answer_id": 154381, "author": "Justin R.", "author_id": 4593, "author_profile": "https://Stackoverflow.com/users/4593", "pm_score": 4, "selected": false, "text": "int capacity = 2000000; // the number of items you expect to add to the filter\nFilter<string> filter = new Filter<string>...
2008/09/30
[ "https://Stackoverflow.com/questions/154365", "https://Stackoverflow.com", "https://Stackoverflow.com/users/127878/" ]
154,372
<p>How do I get a list of all the tables defined for the database when using active record?</p>
[ { "answer_id": 155524, "author": "Jay Stramel", "author_id": 3547, "author_profile": "https://Stackoverflow.com/users/3547", "pm_score": 2, "selected": false, "text": "Dir[\"app/models/*.rb\"].each do |file_path|\n require file_path # Make sure that the model has been loaded.\n\n basen...
2008/09/30
[ "https://Stackoverflow.com/questions/154372", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3547/" ]
154,387
<p>I'm trying to get something very subtle to work, it looks pretty awful right now. I'm trying to paint the background of a TGroupBox which I have overloaded the paint function of so that the corners are show through to their parent object. I've got a bunch of nested group boxes that look very decent without XPThemes. </p> <p>Is there a way to paint part of a background transparent at runtime. I'm programming the form generator, not using Delphi design view.</p>
[ { "answer_id": 154470, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 2, "selected": true, "text": " object GroupBox1: TGroupBox\n Left = 64\n Top = 56\n Width = 481\n Height = 361\n Margins.Left = 10\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/154387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1765/" ]
154,411
<p>I am having trouble getting Team Build to execute my MbUnit unit tests. I have tried to edit TFSBuild.proj and added the following parts:</p> <pre><code>&lt;Project ...&gt; &lt;UsingTask TaskName="MbUnit.MSBuild.Tasks.MbUnit" AssemblyFile="path_to_MbUnit.MSBuild.Tasks.dll" /&gt; ... ... &lt;ItemGroup&gt; &lt;TestAssemblies Include="$(OutDir)\Project1.dll" /&gt; &lt;TestAssemblies Include="$(OutDir)\Project2.dll" /&gt; &lt;/ItemGroup&gt; &lt;Target Name="Tests"&gt; &lt;MbUnit Assemblies="@(TestAssemblies)" ReportTypes="html" ReportFileNameFormat="buildreport{0}{1}" ReportOutputDirectory="." /&gt; &lt;/Target&gt; ... &lt;/Project&gt; </code></pre> <p>But I have yet to get the tests to run.</p>
[ { "answer_id": 154807, "author": "Martin Woodward", "author_id": 6438, "author_profile": "https://Stackoverflow.com/users/6438", "pm_score": 0, "selected": false, "text": " <PropertyGroup>\n <TestDependsOn>\n $(TestDependsOn);\n CallMbUnitTests;\n </TestDependsOn>\n </P...
2008/09/30
[ "https://Stackoverflow.com/questions/154411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4582/" ]
154,427
<p>What's the object type returned by Datepicker? Supposing I have the following:</p> <pre><code>$("#txtbox").datepicker({ onClose: function(date){ //something } }); </code></pre> <p>What is <code>date</code>? I'm interested in reading the date object from another Datepicker for comparison, something like:</p> <pre><code> function(date){ oDate = $("#oDP").datepicker("getDate"); if(oDate == date) //do one else if(oDate &gt; date) //do two } </code></pre> <p>However, this kind of comparison is not working. I'm guessing there is some sort of comparison method for Date object, but I don't know. I also tried comparing the String representation of the dates like <code>oDate.toString() > date.toString()</code> to no avail.</p>
[ { "answer_id": 157441, "author": "ConroyP", "author_id": 2287, "author_profile": "https://Stackoverflow.com/users/2287", "pm_score": 3, "selected": false, "text": "Date" }, { "answer_id": 234380, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverf...
2008/09/30
[ "https://Stackoverflow.com/questions/154427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024/" ]
154,430
<p>I need to store encrypted data (few small strings) between application runs. I do not want the user to provide a passphrase every time (s)he launches the application. I.e. after all it goes down to storing securely the encryption key(s).</p> <p>I was looking into RSACryptoServiceProvider and using PersistentKeyInCsp, but I'm not sure how it works. Is the key container persistent between application runs or machine restarts? If yes, is it user specific, or machine specific. I.e. if I store my encrypted data in user's roaming profile, can I decrypt the data if the user logs on a different machine?</p> <p>If the above does not work, what are my options (I need to deal with roaming profiles).</p>
[ { "answer_id": 154687, "author": "Michael Petrotta", "author_id": 23897, "author_profile": "https://Stackoverflow.com/users/23897", "pm_score": 6, "selected": true, "text": "byte[] plaintextBytes = GetDataToProtect();\nbyte[] encodedBytes = ProtectedData.Protect(plaintextBytes, null, Dat...
2008/09/30
[ "https://Stackoverflow.com/questions/154430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8220/" ]
154,434
<p>How do you get spreadsheet data in Excel to recalculate itself from within VBA, without the kluge of just changing a cell value?</p>
[ { "answer_id": 154439, "author": "Lance Roberts", "author_id": 13295, "author_profile": "https://Stackoverflow.com/users/13295", "pm_score": 7, "selected": true, "text": "ActiveSheet.EnableCalculation = False \nActiveSheet.EnableCalculation = True \n" }, { "answer_id": 154562, ...
2008/09/30
[ "https://Stackoverflow.com/questions/154434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13295/" ]
154,441
<p>I need to test some HTTP interaction with a client I'd rather not modify. What I need to test is the behavior of the server when the client's requests include a certain, static header.</p> <p>I'm thinking the easiest way to run this test is to set up an HTTP proxy that inserts the header on every request. What would be the simplest way to set this up?</p>
[ { "answer_id": 154641, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 7, "selected": true, "text": "NameVirtualHost *\n<VirtualHost *>\n <Proxy http://127.0.0.1:8080/*>\n Allow from all\n </Proxy>\n <LocationM...
2008/09/30
[ "https://Stackoverflow.com/questions/154441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3518/" ]
154,443
<p>Can I run the python interpreter without generating the compiled .pyc files?</p>
[ { "answer_id": 154617, "author": "Constantin", "author_id": 20310, "author_profile": "https://Stackoverflow.com/users/20310", "pm_score": 9, "selected": true, "text": "sys.dont_write_bytecode" }, { "answer_id": 154640, "author": "Jason Baker", "author_id": 2147, "auth...
2008/09/30
[ "https://Stackoverflow.com/questions/154443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476/" ]
154,446
<p>I am trying to save data to a database on a button push, but the variables seem to be private by the nature of where they are defined. I have tried to move where they are defined, but this seems to produce other errors.</p> <p>Given a fix, why was it fixed that way?</p> <p>The code follows.</p> <pre><code>namespace enable { public partial class Form1 : Form { public Form1() { InitializeComponent(); OleDbConnection favouriteConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\192.168.123.5\\Share\\Matt\\BugTypes.mdb"); string strSQL = "SELECT CategoryName, Show " + "FROM [Categories] WHERE Show = 'Yes' " + "ORDER BY CategoryName"; OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL, favouriteConnection); OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(adapter); DataTable dTable = new DataTable(); adapter.Fill(dTable); BindingSource bSource = new BindingSource(); bSource.DataSource = dTable; dataGridView1.DataSource = bSource; adapter.Update(dTable); } private void button1_Click(object sender, EventArgs e) { adapter.Update(dTable);//this is the button that needs to do the save, but can't see the variables. } } } </code></pre>
[ { "answer_id": 154458, "author": "Franci Penov", "author_id": 17028, "author_profile": "https://Stackoverflow.com/users/17028", "pm_score": 0, "selected": false, "text": "namespace enable\n{ \n public partial class Form1 : Form\n {\n public Form1()\n {\n ...
2008/09/30
[ "https://Stackoverflow.com/questions/154446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19802/" ]
154,463
<p>I'm using SharpZipLib version 0.85.5 to unzip files. My code has been working nicely for a couple of months until I found a ZIP file that it doesn't like.</p> <pre><code>ICSharpCode.SharpZipLib.Zip.ZipException: End of extra data at ICSharpCode.SharpZipLib.Zip.ZipExtraData.ReadCheck(Int32 length) in C:\C#\SharpZLib\Zip\ZipExtraData.cs:line 933 at ICSharpCode.SharpZipLib.Zip.ZipExtraData.Skip(Int32 amount) in C:\C#\SharpZLib\Zip\ZipExtraData.cs:line 921 at ICSharpCode.SharpZipLib.Zip.ZipEntry.ProcessExtraData(Boolean localHeader) in C:\C#\SharpZLib\Zip\ZipEntry.cs:line 925 at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry() in C:\C#\SharpZLib\Zip\ZipInputStream.cs:line 269 at Constellation.Utils.Tools.UnzipFile(String sourcePath, String targetDirectory) in C:\C#\Constellation2\Utils\Tools.cs:line 90 --- End of inner exception stack trace --- </code></pre> <p>Here is my unzip method:</p> <pre><code> public static void UnzipFile(string sourcePath, string targetDirectory) { try { using (ZipInputStream s = new ZipInputStream(File.OpenRead(sourcePath))) { ZipEntry theEntry; while ((theEntry = s.GetNextEntry()) != null) { //string directoryName = Path.GetDirectoryName(theEntry.Name); string fileName = Path.GetFileName(theEntry.Name); if (targetDirectory.Length &gt; 0) { Directory.CreateDirectory(targetDirectory); } if (fileName != String.Empty) { using (FileStream streamWriter = File.Create(targetDirectory + fileName)) { int size = 2048; byte[] data = new byte[2048]; while (true) { size = s.Read(data, 0, data.Length); if (size &gt; 0) { streamWriter.Write(data, 0, size); } else { break; } } } } } } } catch (Exception ex) { throw new Exception("Error unzipping file \"" + sourcePath + "\"", ex); } } </code></pre> <p>The file unzips fine using XP's built-in ZIP support, WinZIP, and 7-Zip. The exception is being thrown at <code>s.GetNextEntry()</code>. </p>
[ { "answer_id": 155204, "author": "Vivek", "author_id": 7418, "author_profile": "https://Stackoverflow.com/users/7418", "pm_score": 0, "selected": false, "text": "public static void UnzipFile(string sourcePath, string targetDirectory)\n{\n try\n {\n FastZip fastZip = new Fast...
2008/09/30
[ "https://Stackoverflow.com/questions/154463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/357/" ]