qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
361,304
<p>How do I get the sequence number of the row just inserted?</p>
[ { "answer_id": 361309, "author": "Mark Harrison", "author_id": 116, "author_profile": "https://Stackoverflow.com/users/116", "pm_score": 6, "selected": true, "text": "declare\n s2 number;\n begin\n insert into seqtest2(x) values ('aaa') returning seq into s2;\n dbms_output.put_line...
2008/12/11
[ "https://Stackoverflow.com/questions/361304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/116/" ]
361,307
<p>When using the 'as' keyword in C# to make a cast which fails, null gets returned. What's going on in the background? Is it simply suppressing an exception so I don't have to write handling code for a failure?</p> <p>I'm interested in the performance characteristics of it compared to a typical cast wrapped in a try-catch.</p>
[ { "answer_id": 361318, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 7, "selected": true, "text": "isinst" }, { "answer_id": 361463, "author": "Charles Bretana", "author_id": 32632, "author_profile":...
2008/12/11
[ "https://Stackoverflow.com/questions/361307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10756/" ]
361,312
<p>I do have to say I'm fairly inexperienced when it comes to C++, don't be too harsh on me.</p> <p>Recently stumbled unto the wonders of the win32 API and have chosen to practice using it (I'd rather not use MFC/wxWidgets/etc at this point, just for educational purposes).</p> <p>Well, my real question is: How do you properly code your win32 GUI stuff into classes. I mean, sure, you can make a class that saves individual window handles, allows for easier modification of window properties, has a more simplified version of CreateWindow(). But as I understand it you will need a messagepump and several callback functions for your created windows. How does that work when combining them with classes?</p> <p>Could anyone point me in the right direction here? I don't mind reading (a lot of) example code as long as it is commented.</p> <p>PS: I'm also having trouble finding good (read: easy) documentation on using 'resource files' for my window decorations. Bonuspoints for that! :)</p>
[ { "answer_id": 361576, "author": "Ferruccio", "author_id": 4086, "author_profile": "https://Stackoverflow.com/users/4086", "pm_score": 1, "selected": false, "text": "#include <windowsx.h>" } ]
2008/12/11
[ "https://Stackoverflow.com/questions/361312", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,329
<p>Let's say I have some code like this </p> <pre><code>if(isset($_GET['foo'])) //do something if(isset($_GET['bar'])) //do something else </code></pre> <p>If a user is at example.com/?foo=abc and clicks on a link to set bar=xyz, I want to easily take them to example.com/?foo=abc&amp;bar=xyz, rather than example.com/?bar=xyz. </p> <p>I can think of a few very messy ways to do this, but I'm sure there's something cleaner that I don't know about and haven't been able to track down via Google.</p>
[ { "answer_id": 361354, "author": "Logan Serman", "author_id": 29595, "author_profile": "https://Stackoverflow.com/users/29595", "pm_score": 0, "selected": false, "text": "$link = ($_GET['foo'] == 'abc') ? 'foo=abc&bar=xyz' : 'bar=xyz';\n?>\n<a href=\"whatever.php?<?= $link ?>\">Click Me<...
2008/12/11
[ "https://Stackoverflow.com/questions/361329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30098/" ]
361,330
<p>I need to use the popcnt instruction in a project that is compiled using Visual Stdio 2005<br> The intrinsic <code>__popcnt()</code> only works with VS2008 and the compiler doesn't seem to recognize the instruction even when I write in a <code>__asm {}</code> block.</p> <p>Is there any way to do this?</p>
[ { "answer_id": 361665, "author": "bugmagnet", "author_id": 426, "author_profile": "https://Stackoverflow.com/users/426", "pm_score": 2, "selected": false, "text": ";SSE2 macros for MASM 6.14 by daydreamer aka Magnus Svensson\n\nADDPD MACRO M1,M2\n db 066h\n ADDPS M1,M2\nENDM\n\nADD...
2008/12/11
[ "https://Stackoverflow.com/questions/361330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9611/" ]
361,336
<p>I'm trying to build my first generic list and have run into some problems. I understand the declaration looks like " <code>List&lt;T&gt;</code> ", and I have <code>using System.Collections.Generic;</code> at the top of my page. However, Visual Studio doesn't recognize the <code>T</code> variable. </p> <p>What am I missing?</p>
[ { "answer_id": 361352, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 3, "selected": false, "text": "int" }, { "answer_id": 361353, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https:/...
2008/12/11
[ "https://Stackoverflow.com/questions/361336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42987/" ]
361,350
<p>Our app allows multiple files to be selected in a file selection dialog which is shown via the GetOpenFileName function (this question also applies to folks using CFileDialog, etc...)</p> <p>There appears to be a limit to the number of characters that can be typed into the filename field (259 seems to be the magic number - not sure why).</p> <p>We have tried changing the following members of the <a href="http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx" rel="nofollow noreferrer">OPENFILENAME</a> structure:</p> <p>lpstrFile - point to our own buffer, sized at 4K bytes nMaxFile - set to the size of lpstrFile (we are compiling ANSI, so this is effectively 4000</p> <p>But these values appear to not increase the input width of the filename field in the dialog.</p> <p>I am going to experiment with sending a EM_SETLIMITTEXT message to the control, but wanted to know if anyone else has a solution.</p> <p>EDIT - solved this myself: <a href="https://stackoverflow.com/questions/361350/increase-number-of-characters-in-filename-field-of-getopenfilename-file-selecti#394443">solution</a> I can't accept out my own answer, but here it is for posterity. If anyone else has a better solution, please post it - or feel free to mod up my solution so future searchers will find it at the top.</p>
[ { "answer_id": 361360, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 2, "selected": false, "text": "MAX_PATH" }, { "answer_id": 394443, "author": "Kevin Day", "author_id": 10973, "author_profile": "ht...
2008/12/11
[ "https://Stackoverflow.com/questions/361350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10973/" ]
361,359
<p>I have three DIVs, something like this:</p> <pre><code>&lt;div id="header"&gt; ... &lt;/div&gt; &lt;div id="content"&gt; &lt;div id="popup"&gt; ... &lt;/div&gt; &lt;/div&gt; </code></pre> <p>DIV#header is "position: fixed" and used as a non-scrolling header at the top of the screen. DIV#content has some content in it and is "position: relative". DIV#popup is "position: absolute" and starts out hidden and is displayed on hover. </p> <p>I want the popup to be at the highest level on the page, so that it is above even DIV#header if they overlap. This works fine in Firefox but in IE the popups are behind the header. I can fix this by setting the z-index of DIV#content to be higher than the header, but then of course DIV#content will also be displayed above DIV#header when they overlap, which I don't want.</p> <p>It sounds like I might be affected by what is described on <a href="http://annevankesteren.nl/2005/06/z-index" rel="nofollow noreferrer">this page</a>. However, as I understand it, doing something like setting a default z-index on all elements, like so:</p> <pre><code>* { z-index: 1 } </code></pre> <p>should fix this (as now every element would have a z-index of 1 explicitly set), however rather than fixing this in IE it breaks it in Firefox (such that Firefox now behaves like IE).</p> <p>What's the real deal with z-indexes in IE?</p>
[ { "answer_id": 361360, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 2, "selected": false, "text": "MAX_PATH" }, { "answer_id": 394443, "author": "Kevin Day", "author_id": 10973, "author_profile": "ht...
2008/12/11
[ "https://Stackoverflow.com/questions/361359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168/" ]
361,363
<p>Using only ANSI C, is there any way to measure time with milliseconds precision or more? I was browsing time.h but I only found second precision functions.</p>
[ { "answer_id": 361492, "author": "Robert Gamble", "author_id": 25222, "author_profile": "https://Stackoverflow.com/users/25222", "pm_score": 8, "selected": true, "text": "gettimeofday" }, { "answer_id": 368843, "author": "Nick Van Brunt", "author_id": 30470, "author_p...
2008/12/11
[ "https://Stackoverflow.com/questions/361363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44808/" ]
361,371
<p>This is quite a controversial topic, and before you say "no", is it really, really needed? </p> <p>I have been programming for about 10 years, and I can't honestly say that I can recall a time where inheritance solved a problem that couldn't be solved another way. On the other hand I can recall many times when I used inheritance, because I felt like I had to or because I though I was clever and ended up paying for it.</p> <p>I can't really see any circumstances where, from an implementation stand point, aggregation or another technique could not be used instead of inheritance. </p> <p>My only caveat to this is that we would still allow inheritance of interfaces.</p> <p>(Update)</p> <p>Let's give an example of why it's needed instead of saying, "sometimes it's just needed." That really isn't helpful at all. Where is your proof?</p> <p>(Update 2 Code Example)</p> <p>Here's the classic shape example, more powerful, and more explicit IMO, without inheritance. It is almost never the case in the real world that something really "Is a" of something else. Almost always "Is Implemented in Terms of" is more accurate.</p> <pre><code>public interface IShape { void Draw(); } public class BasicShape : IShape { public void Draw() { // All shapes in this system have a dot in the middle except squares. DrawDotInMiddle(); } } public class Circle : IShape { private BasicShape _basicShape; public void Draw() { // Draw the circle part DrawCircle(); _basicShape.Draw(); } } public class Square : IShape { private BasicShape _basicShape; public void Draw() { // Draw the circle part DrawSquare(); } } </code></pre>
[ { "answer_id": 361411, "author": "Greg Beech", "author_id": 13552, "author_profile": "https://Stackoverflow.com/users/13552", "pm_score": 4, "selected": false, "text": "Stream" }, { "answer_id": 361464, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile":...
2008/12/11
[ "https://Stackoverflow.com/questions/361371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45365/" ]
361,391
<p>In a client-server system, is it considered good architecture for a server method to "ask the client" for more information? If so, what's the best way to design such a scenario? Is there a "pattern" for this?</p> <p>For example, suppose the end user selects a set of records they want to delete in the client UI, then the client makes a "delete records" call to the server with the set of records as a parameter. Then the server finds a subset of those records which are "special" in some way and thus need to be confirmed by the user. Is it appropriate for the server to somehow "call back" to the client to a method called "confirm records" while still continuing the original call from the client to the server?</p> <p>And what about more complex server calls that could require a long "dialog" between server and client?</p>
[ { "answer_id": 361419, "author": "BCS", "author_id": 1343, "author_profile": "https://Stackoverflow.com/users/1343", "pm_score": 1, "selected": false, "text": "I_RELLY_WANT_TO" }, { "answer_id": 361657, "author": "rik.the.vik", "author_id": 45570, "author_profile": "h...
2008/12/11
[ "https://Stackoverflow.com/questions/361391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
361,443
<p>I am trying to learn more about regular expressions I have one below that I believe finds cases where there is a missing close paren on a number up to 999 billion. The one below it I thought should do the same but I do not get similar results</p> <pre><code> missingParenReg=re.compile(r"^\([$]*[0-9]{1,3}[,]?[0-9]{0,3}[,]?[0-9]{0,3}[,]?[0-9]{0,3}[.]*[0-9]*[^)]$") missingParenReg2=re.compile(r"^\([$]?([0-9]{1,3}[,]?)+[.]*[0-9]*[^)]$") </code></pre> <p>I think the second one says: There must be an open paren to start<br> There may or may not be as many as one dollar sign<br> The next group must exist at least once but can exist an unlimited number of times<br> The group should have at least one digit but may have as many as three<br> The group may have as few as 0 and as many as 1 commas<br> Following this group there may or may not be a decimal point<br> If there is a decimal point it will be followed by as many as 0 but as many as uncounted occurences of digits<br> At the end there should not be a closing paren.</p> <p>I am trying to understand this magic stuff so I would appreciate a correction to my regex (if it can be corrected) in addition to a more elegant solution if you have it.</p>
[ { "answer_id": 361475, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 2, "selected": false, "text": "whether_paren_is_missing = (astring[0] == '(' and not astring[-1] == ')')\n" }, { "answer_id": 361485, "author": "Jo...
2008/12/11
[ "https://Stackoverflow.com/questions/361443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30105/" ]
361,455
<p>I have a MySQL query structured as follows:</p> <pre><code>SELECT time(c.start_time), time(c.end_time), time(c.end_time) - time(c.start_time) as 'opening_hours' FROM my_shop c; </code></pre> <p>The data in start and end time is 1970-01-01 07:00:00 and 1970-01-01 19:00:00 respectively.</p> <p>On my local machine this this query returns:</p> <pre><code>| 07:00:00 | 19:00:00 | 12 | </code></pre> <p>However on a remote machine (production) it is returning</p> <pre><code>| 07:00:00 | 19:00:00 | 120000 | </code></pre> <p>Any ideas as to why this might be happening and how to fix it? </p> <p>Both sets of data are identical and too the best of my knowledge both MySQL installations are identical.</p> <p>Any help is much appreciated.</p> <p>Update: </p> <p>It would seem that the versions of MySQL are slightly different: 5.0.27-community-nt versus 5.0.51b-community-nt. This is most probably the reason why.</p> <p>djt has raised a good point in that Bill's solution does not take into account minutes. As well as this djt's solution is not quite what i need. </p> <p>So i guess the question has morphed into how to subtract two times including minutes such that:</p> <pre><code>1970-01-01 19:00:00 - 1970-01-01 07:00:00 = 12 1970-01-01 19:00:00 - 1970-01-01 07:30:00 = 11.5 1970-01-01 19:00:00 - 1970-01-01 07:45:00 = 11.25 </code></pre> <p>etc.</p>
[ { "answer_id": 361582, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 2, "selected": true, "text": "SELECT TIME(c.start_time),\n TIME(c.end_time),\n EXTRACT(HOUR FROM TIMEDIFF(TIME(c.end_time), TIME(c.start_...
2008/12/11
[ "https://Stackoverflow.com/questions/361455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24390/" ]
361,467
<p>I am using jQuert .ajax function to call a page method. The site is using FormsAuthentication. So when an authentication ticket expires a call to the page method will obviously cause a redirect to the login page. </p> <p>Now, the geniuses that wrote the System.Web.Handlers.ScriptModule decided that if for some reason a REST style call to a page method or a web service method, from JavaScript causes a 302 Redirect, they're going to just simply turn the response into a 401 Unauthorized. This causes a browser to popup a login UI that is totally misleading, as the user tries to type in their username and password, which means nothing, because FormsAuthentication is used. Finally, when the user clicks Cancel, the 401 comes through to the error handler. </p> <p>So, the question is, how can one disable the browser's login UI prompt in any way? Some people on the web suggest to use a username and password in the XHR request, but it does not seem to work.</p>
[ { "answer_id": 361564, "author": "Strelok", "author_id": 2788, "author_profile": "https://Stackoverflow.com/users/2788", "pm_score": 4, "selected": true, "text": " $.ajax({\n type: \"POST\",\n url: postUrl + \"/SomePageMethod\",\n data: \"{searchString...
2008/12/11
[ "https://Stackoverflow.com/questions/361467", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2788/" ]
361,468
<p>I'm looking for a way in .NET (2.0, C# in particular) for source code to trigger a debugging break as if a breakpoint was set at that point, without having to remember to set a specific breakpoint there in the debugger, and without interfering with production runtime.</p> <p>Our code needs to swallow exceptions in production so we don't disrupt a client application that links to us, but I'm trying to set it up so that such errors will pop up to be analyzed if it happens to be running in a debugger, and otherwise will be safely ignored.</p> <p>My attempt to use <code>Debug.Assert(false)</code> has been less than ideal, and I assume that <code>Debug.Fail()</code> would behave the same way. It should theoretically have no effect in production, and it does successfully stop when debugging, but by design there is (as far as I can tell) no way to continue execution if you want to ignore that error, like you could with an actual breakpoint, and like it would do in production where we swallow the error. It also apparently breaks evaluation of variable state because the debugger actually stops down in native system code and not in ours, so it's debugging help is limited. (Maybe I'm missing some way of getting back into things to look at the variables and so on where it happened. ???)</p> <p>I was hoping for something like <code>Debug.Break()</code>, but it doesn't seem to exist (unless maybe in a later version of .NET?), and no other <code>Debug</code> methods seem applicable, either.</p> <p><strong>Update:</strong> While ctacke's answer is the best match for what I was looking for, I have since also discovered a trick with Debug.Assert()--when running in the debugger--Pause the debugger, go to the code for the Debug.Assert call pending (highlighted in green because it is down in the framework code) and hit Step-Out (shift-F11), then hit Ignore in the assert dialog box. This will leave the debugger paused upon the return of the assert (and able to continue execution as if it hadn't occurred, because it was ignored). There may be other ways to do much the same thing (does hitting Retry do this more directly?), but this way was intuitive.</p>
[ { "answer_id": 361473, "author": "shahkalpesh", "author_id": 23574, "author_profile": "https://Stackoverflow.com/users/23574", "pm_score": 4, "selected": false, "text": "System.Diagnostics.Debugger.Break" }, { "answer_id": 361479, "author": "CheGueVerra", "author_id": 177...
2008/12/11
[ "https://Stackoverflow.com/questions/361468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181460/" ]
361,471
<p>I have a web application with multiple web services. This web application has business and persistency layer. Is it possible to use separate log appender (log file) per web service?</p> <p>This applies to web pages too. Essentially I want to separate my logs NOT based on the class or layer/namespace, but from point of entry, which can be web service or web page.</p>
[ { "answer_id": 361622, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 1, "selected": false, "text": "namespace log4net\n{\n public class LogManager\n {\n public static ILog GetLogger(string name);\n ...
2008/12/11
[ "https://Stackoverflow.com/questions/361471", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16073/" ]
361,477
<p>Note: Using MySQL 4.0, which means no subqueries (at present).</p> <p>I have 2 tables:</p> <ul> <li>A "user_details" table</li> <li>A "skills" table, which has the user_id and a "skill_id", which maps to a predefined set of skills defined elsewhere.</li> </ul> <p>The current query allows an admin to search for users by selecting skills, and the query works in an OR fashion, eg:</p> <pre><code>LEFT JOIN skills ON (ud.user_id = skills.user_id) WHERE skills.skill_id in (51, 52, 53, 54, 55) GROUP BY ud.user_id </code></pre> <p>This returns too many records and thus I want this search field to work in an AND fashion, where a user must have ALL the selected skills to be returned in the search.</p> <p>It may be possible to get MySQL upgraded if subqueries are the best option.</p> <p>edit: Something to do with group by, count, having etc. Can you restrict a group by command with a requirement on how many matched rows you return? (eg 5 in this example).</p> <p>edit2: Testing out:</p> <pre><code>HAVING COUNT( * ) &gt; 5 </code></pre>
[ { "answer_id": 361551, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": true, "text": "SELECT user_id\nFROM skills\nWHERE skill_id IN (51, 52, 53, 54, 55)\nGROUP BY user_id\nHAVING COUNT(*) = 5;\n" }, {...
2008/12/11
[ "https://Stackoverflow.com/questions/361477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29854/" ]
361,481
<p>Modal dialogs are evil, but I keep reading "You should remove modal dialogs <i>when possible</i>"</p> <p>When isn't it possible to remove modal dialogs? I mean, what are some truly modal tasks that force us to use evil modal dialogs?</p> <p>The most common given example is the "Do you want to Save?" I think this is the problem of the concept of having the user hit Save instead of remembering that <b>user input is sacred</b>. If you just saved automatically with the ability to "undo" or have revisions, then you don't ever need ask the user if they want to save.</p> <ul> <li>"Are you sure you want to delete?" Undelete</li> <li>"Are you sure you want to quit?" Why would you ask that? Are you that vain?</li> </ul> <p>Why do we ever need modal dialogs?</p> <p><strong>EDIT</strong></p> <p>Webs app don't count in my books, unless they write their own UI windowing system within the browser. Web apps don't have the same tools set as desktop apps.</p> <p><strong>EDIT 2</strong></p> <p>My question is slightly different than the one labeled as duplicate. I feel that there is no case that modal dialogs are the best solution. The referred question assumes there is such a case.</p> <h3>Duplicate of: <a href="https://stackoverflow.com/questions/152938/when-is-modal-ui-acceptable">When Is Modal UI acceptable</a>?</h3>
[ { "answer_id": 361488, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 3, "selected": false, "text": "onbeforeunload" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21838/" ]
361,487
<p>What is the exact pixel size of one column when I used the columns attribute to determine a width of an ASP.NET textbox control?</p> <pre><code>&lt;asp:TextBox id="MyTextBox" runat="server" columns="10" /&gt; </code></pre>
[ { "answer_id": 361521, "author": "Ryan Smith", "author_id": 10420, "author_profile": "https://Stackoverflow.com/users/10420", "pm_score": 2, "selected": true, "text": "style=\"width: 250px;\"\n" }, { "answer_id": 361542, "author": "Michael Kniskern", "author_id": 26327, ...
2008/12/12
[ "https://Stackoverflow.com/questions/361487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26327/" ]
361,490
<p>I have a silverlight 2 app that has an ObservableCollection of a class from a separate assem/lib. When I set my ListBox.ItemsSource on that collection, and run it, I get the error code:</p> <blockquote> <p>4004 &quot;System.ArgumentException: Value does not fall within the expected range.&quot;</p> </blockquote> <p>Here is part of the code:</p> <pre><code>public partial class Page : UserControl { ObservableCollection&lt;Some.Lib.Owner&gt; ooc; public Page() { ooc = new ObservableCollection&lt;Some.Lib.Owner&gt;(); Some.Lib.Owner o1 = new Some.Lib.Owner() { FirstName = &quot;test1&quot; }; Some.Lib.Owner o2 = new Some.Lib.Owner() { FirstName = &quot;test2&quot; }; Some.Lib.Owner o3 = new Some.Lib.Owner() { FirstName = &quot;test3&quot; }; ooc.Add(o1); ooc.Add(o2); ooc.Add(o3); InitializeComponent(); lb1.ItemsSource = ooc; } } </code></pre> <p>But when I create the Owner class within this same project, everything works fine. Is there some security things going on behind the scenes? Also, I'm using the generate a html page option and not the aspx option, when I created this Silverlight 2 app.</p>
[ { "answer_id": 65333400, "author": "ΩmegaMan", "author_id": 285795, "author_profile": "https://Stackoverflow.com/users/285795", "pm_score": 0, "selected": false, "text": "entity" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33324/" ]
361,500
<p>I have a situation where I need to process large (many GB's) amounts of data as such:</p> <ol> <li>build a large string by appending many smaller (C char*) strings</li> <li>trim the string</li> <li>convert the string into a C++ const std::string for processing (read only)</li> <li>repeat</li> </ol> <p>The data in each iteration are independent.</p> <p>My question is, I'd like to minimise (if possible eliminate) heap allocated memory usage, as it at the moment is my largest performance problem.</p> <p>Is there a way to convert a C string (char*) into a stl C++ string (std::string) without requiring std::string to internally alloc/copy the data?</p> <p>Alternatively, could I use stringstreams or something similar to re-use a large buffer?</p> <p><strong>Edit:</strong> Thanks for the answers, for clarity, I think a revised question would be:</p> <p><em>How can I build (via multiple appends) a stl C++ string efficiently. And if performing this action in a loop, where each loop is totally independant, how can I re-use thisallocated space.</em></p>
[ { "answer_id": 361597, "author": "e.James", "author_id": 33686, "author_profile": "https://Stackoverflow.com/users/33686", "pm_score": 5, "selected": true, "text": "string::reserve(size_t)" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40175/" ]
361,529
<p>I'm using Spring, but this question applies to all JSP-controller type designs.</p> <p>The JSP page references data (using tags) which is populated by the corresponding controller. My question is, where is the appropriate place to perform formatting, in JSP or the controller?</p> <p>So far I've been preparing the data by formatting it in my controller.</p> <pre><code>public class ViewPersonController extends org.springframework.web.servlet.mvc.AbstractController { private static final Format MY_DATE_FORMAT = new SimpleDateFormat(...); protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) { Person person = get person from backing service layer or database Map properties = new HashMap(); // No formatting required, name is a String properties.put("name", person.getName()); // getBirthDate() returns Date and is formatted by a Format properties.put("birthDate", MY_DATE_FORMAT.format(person.getBirthDate())); // latitude and longitude are separate fields in Person, but in the UI it's one field properties.put("location", person.getLatitude() + ", " + person.getLongitude()); return new ModelAndView("viewPerson", "person", properties); } } </code></pre> <p>The JSP file would look something like:</p> <pre><code>Name = &lt;c:out value="${person. name}" /&gt;&lt;br&gt; Birth Date = &lt;c:out value="${person. birthDate}" /&gt;&lt;br&gt; Location = &lt;c:out value="${person. location}" /&gt;&lt;br&gt; </code></pre> <p>I know that JSP does have some provisions for formatting,</p> <pre><code>&lt;%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %&gt; &lt;fmt:formatDate type="date" value="${person. birthDate}" /&gt; </code></pre> <p>But this only works with Java's <code>java.util.Format</code>. What if I need more complex or computed values. In such a case putting the code in the JSP would be cumbersome (and ugly).</p> <p>I'm curious if this is following the spirit Spring/JSP/MVC. In other words, is the controller part of the view? Where is the preferred place to perform view related formatting? Should my controller just be returning the object (Person) instead of a Map of formatted values?</p>
[ { "answer_id": 361831, "author": "bpapa", "author_id": 543, "author_profile": "https://Stackoverflow.com/users/543", "pm_score": 0, "selected": false, "text": "public class Person {\n public String getLocation() {\n return this.latitude.concat(\", \").concat(this.longitude);\n ...
2008/12/12
[ "https://Stackoverflow.com/questions/361529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24396/" ]
361,583
<p><b>Duplicate of: <a href="https://stackoverflow.com/questions/255214/when-should-i-use-the-visitor-design-pattern">When Should I Use The Visitor Design Pattern</a></b></p> <p>Why would someone want to use the visitor pattern? I've read a couple of articles, but I'm not getting something.</p> <p>If I need a function to bill a custom, I could use</p> <pre><code>Custom.Accept(BillVisitor) </code></pre> <p>or something like</p> <pre><code>Bill(Customer) </code></pre> <p>The second is less complex, and the Bill function is still separated from the Customer class. So why would I want to use the visitor pattern?</p>
[ { "answer_id": 362186, "author": "ididak", "author_id": 28888, "author_profile": "https://Stackoverflow.com/users/28888", "pm_score": 4, "selected": false, "text": "void accept(BillVisitor visitor) { visitor.bill(this); } // java syntax\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,592
<p>Imagine I use the .NET graphic classes to draw a rectangle.</p> <p>How could I then assign an event so that if the user clicks a certain point, or a certain point range, something happens (a click event handler)?</p> <p>I was reading CLR via C# and the event section, and I thought of this scenario from what I had read.</p> <p>A code example of this would really improve my understanding of events in C#/.NET.</p> <p>Thanks</p>
[ { "answer_id": 361607, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 3, "selected": false, "text": "public partial class Form1 : Form\n{\n private Rectangle rect;\n private Pen pen = Pens.Black;\n\n public Form1()\n ...
2008/12/12
[ "https://Stackoverflow.com/questions/361592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
361,633
<p>VStudio ASP.NET gives the following message: </p> <pre><code>Attribute 'bgcolor' is considered outdated. A newer construct is recommended. </code></pre> <p>What is the recommended construct?</p> <p><code>bgcolor</code> is within a <code>&lt;td&gt;</code> element.<br> Another related message is : </p> <pre><code>Attribute 'bordercolor' is not a valid attribute of element 'table'. </code></pre> <p>Does anyone know where I might find the newer replacements?</p>
[ { "answer_id": 361642, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 2, "selected": false, "text": "background-color" }, { "answer_id": 361643, "author": "George Stocker", "author_id": 16587, ...
2008/12/12
[ "https://Stackoverflow.com/questions/361633", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1682/" ]
361,635
<p>I need to debug JavaScript in Internet Explorer 7.</p> <p>Unfortunately, its default debugger doesn't provide me with much information. It tells me the page that the error showed up on (not the specific script) and gives me a line number. I don't know if that is related to my problem.</p> <p>It'd be nice if it could narrow down the error to a line number on a specific script (like Firebug can).</p> <p>Is there an addon to debug JavaScript in IE7 like Firebug does in Firefox?</p> <p>Thank you!</p> <h3>See also:</h3> <p><a href="https://stackoverflow.com/questions/56615/does-ie7-have-a-developer-mode-or-plugin-like-firefoxchromesafari">Does IE7 have a “developer mode” or plugin like Firefox/Chrome/Safari?</a></p>
[ { "answer_id": 2139008, "author": "Marc", "author_id": 259168, "author_profile": "https://Stackoverflow.com/users/259168", "pm_score": 5, "selected": false, "text": "javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1....
2008/12/12
[ "https://Stackoverflow.com/questions/361635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
361,648
<p>My main experience is with C &amp;&amp; C++, so I'd prefer to remain with them. I don't want to use anything like QT, GTK, or wxWidgets or any tool kits. I'd like to learn native programming and this sort of defeats the purpose. With that in mind I'd also like to avoid Java.</p> <p>I understand gnome and xfce and KDE and such are all Desktop Environments for Linux, and the base installed typically is X (Xorg). When coding for Linux, do you code for X, or for the desktop environment? Is there a standard Linux header for this (like win32 has windows.h) for Linux? or is it different coding methods for every desktop environment?</p> <p>any help is greatly appreciated.</p>
[ { "answer_id": 6971261, "author": "luser droog", "author_id": 733077, "author_profile": "https://Stackoverflow.com/users/733077", "pm_score": 2, "selected": false, "text": "XFlush()" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361648", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36457/" ]
361,661
<p>I have a database table (named Topics) which includes these fields :</p> <ol> <li>topicId </li> <li>name</li> <li>parentId</li> </ol> <p>and by using them I wanna populate a TreeView in c#. How can I do that ?</p> <p>Thanks in advance...</p>
[ { "answer_id": 361678, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 5, "selected": true, "text": "//In Page load\nforeach (DataRow row in topics.Rows)\n{\n TreeNode node = new TreeNode(dr[\"name\"], dr[\"topicId\"])\n node.Po...
2008/12/12
[ "https://Stackoverflow.com/questions/361661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44852/" ]
361,675
<p>I'm trying to get started with unit testing in Python and I was wondering if someone could explain the advantages and disadvantages of doctest and unittest. </p> <p>What conditions would you use each for?</p>
[ { "answer_id": 361683, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 4, "selected": false, "text": "doctest" }, { "answer_id": 361788, "author": "davidavr", "author_id": 8247, "author_profile": "https:...
2008/12/12
[ "https://Stackoverflow.com/questions/361675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44133/" ]
361,681
<p>I need a reasonably smart algorithm to come up with "nice" grid lines for a graph (chart).</p> <p>For example, assume a bar chart with values of 10, 30, 72 and 60. You know:</p> <p>Min value: 10 Max value: 72 Range: 62</p> <p>The first question is: what do you start from? In this case, 0 would be the intuitive value but this won't hold up on other data sets so I'm guessing:</p> <p>Grid min value should be either 0 or a "nice" value lower than the min value of the data in range. Alternatively, it can be specified.</p> <p>Grid max value should be a "nice" value above the max value in the range. Alternatively, it can be specified (eg you might want 0 to 100 if you're showing percentages, irrespective of the actual values).</p> <p>The number of grid lines (ticks) in the range should be either specified or a number within a given range (eg 3-8) such that the values are "nice" (ie round numbers) and you maximise use of the chart area. In our example, 80 would be a sensible max as that would use 90% of the chart height (72/80) whereas 100 would create more wasted space.</p> <p>Anyone know of a good algorithm for this? Language is irrelevant as I'll implement it in what I need to.</p>
[ { "answer_id": 361687, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 5, "selected": false, "text": "import math\n\ndef BestTick(largest, mostticks):\n minimum = largest / mostticks\n magnitude = 10 ** math.floor(ma...
2008/12/12
[ "https://Stackoverflow.com/questions/361681", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18393/" ]
361,686
<p>Not a programming question per se, but interesting for people who do commercial web development.</p> <p>How do you track all of your clients' hosting, domain registration, and SSL certificate expiry dates?</p> <p>Do you just keep a spreadsheet or is there some useful piece of software for this?</p> <p>I've searched extensively and can't find a usable piece of software and am tempted to write something. With 100+ customers to manage, and with hosting and domain names spread across several hosting companies and registrars, my ad hoc means are failing.</p>
[ { "answer_id": 361739, "author": "joshperry", "author_id": 30587, "author_profile": "https://Stackoverflow.com/users/30587", "pm_score": 2, "selected": false, "text": "using System.Net;\nusing System.Diagnostics;\nusing System.Net.Mail;\nusing System.Threading;\n\nstatic void Main(string...
2008/12/12
[ "https://Stackoverflow.com/questions/361686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15531/" ]
361,717
<p>I have HTML code like this :</p> <pre><code>&lt;div&gt; &lt;a&gt;Link A1&lt;/a&gt; &lt;a&gt;Link A2&lt;/a&gt; &lt;a&gt;Link A3&lt;/a&gt; &lt;/div&gt; &lt;div&gt; &lt;a&gt;Link B1&lt;/a&gt; &lt;a&gt;Link B2&lt;/a&gt; &lt;a&gt;Link B3&lt;/a&gt; &lt;/div&gt; </code></pre> <p>When user clicks a link from above HTML, I want to get the jQuery object of the corresponding <code>&lt;a&gt;</code> element, and then manipulate its sibling. I can't think of any way other than creating an ID for each <code>&lt;a&gt;</code> element, and passing that ID to an onclick event handler. I really don't want to use IDs. </p> <p>Any suggestions?</p>
[ { "answer_id": 361724, "author": "Shog9", "author_id": 811, "author_profile": "https://Stackoverflow.com/users/811", "pm_score": 7, "selected": true, "text": "$(\"div a\").click( function(event)\n{\n var clicked = $(this); // jQuery wrapper for clicked element\n // ... click-specific...
2008/12/12
[ "https://Stackoverflow.com/questions/361717", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10629/" ]
361,723
<p>I am having difficulty with the following method. I can't figure out if my problem is, but I have narrowed it down to not populating the array list from the file. Any help is greatly appreciated.</p> <pre><code>private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) { //create arraylists ArrayList&lt;String&gt; model = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; length = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; width = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; radius = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; depth = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; volume = new ArrayList&lt;String&gt;(); ArrayList&lt;String&gt; shape = new ArrayList&lt;String&gt;(); //fill arraylists from file try { String outputline = ""; BufferedReader fin = new BufferedReader(new FileReader("stock.dat")); while((outputline = fin.readLine()) != null) { // for(int i = 0; i &lt; outputline.length(); i++) { int i = 0; //model boolean flag = false; String pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; i++; } model.add(pass); //length flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } length.add(pass); //width flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } width.add(pass); //radius flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } radius.add(pass); //depth flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } depth.add(pass); //volume flag = false; pass = ""; while(flag = false) { if(outputline.charAt(i) != ',') pass.concat(Character.toString(outputline.charAt(i))); else flag = true; } volume.add(pass); //shape pass = ""; for(int j = i; j &lt; outputline.length(); j++) pass.concat(Character.toString(outputline.charAt(i))); shape.add(pass); } fin.close(); } catch(IOException e) { System.err.print("Unable to read from file"); System.exit(-1); } int at = -1; for(int i = 0; i &lt; model.size(); i++) { if(model.get(i).equals(searchIn.getText())) { at = i; i = model.size(); } } Component frame = null; if(at != -1) { searchDepthOut.setText(depth.get(at)); searchLengthOut.setText(length.get(at)); searchRadiusOut.setText(radius.get(at)); searchVolumeOut.setText(volume.get(at)); searchWidthOut.setText(width.get(at)); } else JOptionPane.showMessageDialog(null, "Your search did not return any results", "ERORR", JOptionPane.ERROR_MESSAGE); </code></pre> <p>}</p>
[ { "answer_id": 361755, "author": "jmucchiello", "author_id": 44065, "author_profile": "https://Stackoverflow.com/users/44065", "pm_score": 2, "selected": false, "text": "String pass = \"\";\nwhile(flag = false) {\nif(outputline.charAt(i) != ',')\n pass.concat(Character.toString(outputl...
2008/12/12
[ "https://Stackoverflow.com/questions/361723", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,742
<p>Sorry if this is a really basic question but I struggling with how I should attack this. I am trying to wrap up some commands for a OLE object, the basic spec looks like this:</p> <pre><code>Set Window window_id //Units is part of the position setter. [ Position ( x, y ) [ Units paper_units ] ] [ Width win_width [ Units paper_units ] ] [ Height win_height [ Units paper_units ] ] ..... this goes on for about 20+ commands, all optional. </code></pre> <p>Where anyhting in between [] is optional.</p> <p>So I need to create a class lets call it "<strong>CommandBuilder</strong>" that can will have set methods for all these optional setters, thats fine I can handle that, the main problem I'm having is the ToCommandString method that needs to ouput a string which would look somthing like:</p> <pre><code>Set Window 1 Position (x,y) Units "m" Height 100 Units "m" + what ever else the user added </code></pre> <p>Just doing a few if's based on variables that get set and joining the string works fine when there is nothing complicated about the variables being set or there are only a few variables but when there are heaps of variables and/or nested values that are also optional, it can make the ToString method very long and complicated + hard to maintain if anything changes.</p> <p>I was wondering if I could solve this by using polymorphism by doing something like this.</p> <pre><code>interface ICommand { string ToCommandString(); } class PositionCommand : ICommand { double X; double Y; string Units; public PositionCommand(double x, double y) { this.X = x; this.Y = y; } public PositionCommand(double x,double y, string units) { this.X = x; this.Y = y; this.Units = units; } public string ToCommandString() { //Add more stuff here to handle empty units. return String.Format(" Postion ({0},{1})", X.ToString(), Y.ToString()); } } ....more command classes. </code></pre> <p>Then all my set methods in "<strong>CommandBuilder</strong>" can just create the right command type add it to a list, then the main ToString in "<strong>CommandBuilder</strong>" method can loop through all the ones that have been set and call ToCommandString and no have to worry about doing any if statments or null checks. </p> <p>Would this be the correct way to go about this? </p> <p>P.S. If you need more info I would be glad to add, just didn't want to make it to long first go.</p>
[ { "answer_id": 361759, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 2, "selected": false, "text": "class CommandBuilder\n{\n private List<ICommand> _commands = new List<ICommand>();\n\n public CommandBuilder Posit...
2008/12/12
[ "https://Stackoverflow.com/questions/361742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6335/" ]
361,747
<p>I was browsing through the questions and noticed this:</p> <pre><code>SELECT prodid, issue FROM Sales WHERE custid = @custid AND datesold = SELECT MAX(datesold) FROM Sales s WHERE s.prodid = Sales.prodid AND s.issue = Sales.issue AND s.custid = @custid </code></pre> <p>I was wondering what the "@" does in front of custID? Is it just a way of referencing the custID from the table being selected?</p>
[ { "answer_id": 361758, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 2, "selected": false, "text": "@" }, { "answer_id": 361962, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverf...
2008/12/12
[ "https://Stackoverflow.com/questions/361747", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27620/" ]
361,752
<p>I'm working on a Perl script. How can I pass command line parameters to it?</p> <p>Example:</p> <pre><code>script.pl "string1" "string2" </code></pre>
[ { "answer_id": 361757, "author": "George Stocker", "author_id": 16587, "author_profile": "https://Stackoverflow.com/users/16587", "pm_score": 6, "selected": false, "text": "@ARGV" }, { "answer_id": 361769, "author": "nrich", "author_id": 44153, "author_profile": "http...
2008/12/12
[ "https://Stackoverflow.com/questions/361752", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15884/" ]
361,756
<p>Is tight looping in a program bad?</p> <p>I have an application that has two threads for a game-physics simulator. An updateGame thread and a render thread. The render thread is throttled by causing the thread to sleep for some milliseconds (to achieve the frame-rate I want) and the updateGame thread (that updates my in game objects positions based off some physics equations) was previously throttled by a 10 millisecond sleep.</p> <p>However, I recently unthrottled the updateGame thread and the simulation of my objects movement seems to be significantly more realistic now that I have taken out that 10ms sleep. Is it bad to hot loop or have a tight loop?</p> <pre><code>private class UpdateTask implements Runnable { private long previousTime = System.currentTimeMillis(); private long currentTime = previousTime; private long elapsedTime; public void run() { while(true) { currentTime = System.currentTimeMillis(); elapsedTime = (currentTime - previousTime); // elapsed time in seconds updateGame(elapsedTime / 1000f); try { Thread.currentThread().sleep(1); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } previousTime = currentTime; } } } </code></pre> <p>In this example I'm just sleeping for 1ms (and from my understanding with how millisecond accuracy and the sleep function works this is probably more like 5-10ms. If I sleep for any more than this it starts to have impacts on the accuracy of my collision detection and physics model.</p> <p>Is it a bad practice to have tight loops or loops with 1ms sleeps in them? Is there something else I should do instead?</p>
[ { "answer_id": 361785, "author": "coobird", "author_id": 17172, "author_profile": "https://Stackoverflow.com/users/17172", "pm_score": 2, "selected": false, "text": "Thread.sleep" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2635/" ]
361,775
<p>I have a div tag styled through CSS. I set the padding to 10px (padding:10px), it works just as I wanted in Firefox and IE7, but in IE6 it adds additional padding at the bottom (about 2-3px I think). Anyone has idea about what's happening here?</p> <p>[update]</p> <p>I just noticed this, the div tag I'm talking about has a background-image. When I removed the background-image, the extra padding on the bottom disappears. Any ideas?</p> <p>[another update, code sample]</p> <p>Here's the CSS applied to my div tag:</p> <pre><code>.user-info{ margin-top: 20px; margin-right: 20px; padding: 10px; background-image: url("../img/user_panel_bg.png"); float:right; border: 1px #AAAAAA solid; font-size:12px; } </code></pre>
[ { "answer_id": 361820, "author": "Philip Arthur Moore", "author_id": 37702, "author_profile": "https://Stackoverflow.com/users/37702", "pm_score": 2, "selected": false, "text": "DIV" }, { "answer_id": 361825, "author": "Kibbee", "author_id": 1862, "author_profile": "h...
2008/12/12
[ "https://Stackoverflow.com/questions/361775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40538/" ]
361,799
<p>I have been working for a while to create an iPhone app. Today when my battery was low, I was working and constantly saving my source files then the power went out...</p> <p>Now when I plugged my computer back in and it is getting good power I try to open my project file and I get an error:</p> <blockquote> <p>Unable to Open Project</p> <p>Project ... cannot be opened because the project file cannot be parsed.</p> </blockquote> <p>Is there a way that people know of that I can recover from this? I tried using an older project file and re inserting it and then compiling. It gives me a funky error which is probably because it isn't finding all the files it wants...</p> <p>I really don't want to rebuild my project from scratch if possible.</p> <hr /> <h3>EDIT</h3> <p>Ok, I did a diff between this and a slightly older project file that worked and saw that there was some corruption in the file. After merging them (the good and newest parts) it is now working.</p> <p>Great points about the SVN. I have one, but there has been some funkiness trying to sync XCode with it. I'll definitely spend more time with it now... ;-)</p> <p><img src="https://i.stack.imgur.com/Up53v.png" alt="enter image description here" /></p>
[ { "answer_id": 11992949, "author": "Usuf", "author_id": 3199983, "author_profile": "https://Stackoverflow.com/users/3199983", "pm_score": 8, "selected": false, "text": "projectname.xcodeproj" }, { "answer_id": 21628450, "author": "Oleksiy Ivanov", "author_id": 2546685, ...
2008/12/12
[ "https://Stackoverflow.com/questions/361799", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,801
<p>I'm a newbie with Subversion, so I don't now if this is a dumb question:</p> <p>I've inherited a subversion repository with a flat structure with no /trunk /tags /branches top level).</p> <p>I'd like re-structure it so that it follows the </p> <pre><code>/trunk /tags /branches </code></pre> <p>layout.</p> <p>Is this possible?</p>
[ { "answer_id": 363168, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 4, "selected": false, "text": "move" }, { "answer_id": 9244069, "author": "msangel", "author_id": 449553, "author_profile": "https:/...
2008/12/12
[ "https://Stackoverflow.com/questions/361801", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,832
<p>I have a base class in which I want to specify the methods a child class must have, but not implement them itself. However, the methods in a child class may have a different number of paramaters to the definition in the base class.</p> <p>Having tried this with an abstract method, php doesn't allow this. Is it possible?</p>
[ { "answer_id": 362046, "author": "danieltalsky", "author_id": 22452, "author_profile": "https://Stackoverflow.com/users/22452", "pm_score": 1, "selected": false, "text": "func_get_args()\n" }, { "answer_id": 362368, "author": "Tom Haigh", "author_id": 22224, "author_p...
2008/12/12
[ "https://Stackoverflow.com/questions/361832", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40017/" ]
361,839
<p>Sorry for asking an implement my feature question type question last time. I am new to Stackoverflow.com and also to php that's why.</p> <p>What I was trying to ask is:</p> <p>I have made a admin account. Members have registration page so a member will register. When user registers in the database table I will have a field for which 0 value will be initialised which means he is not approved. In admin account I have code to get the list of members. The code is given below:</p> <pre><code>&lt;h2&gt;&lt;?php echo "User list"; ?&gt;&lt;/h2&gt; &lt;table border="0" cellpadding="0" cellspacing="0"&gt; &lt;tr bgcolor="#f87820"&gt; &lt;td&gt;&lt;img src="img/blank.gif" alt="" width="10" height="25"&gt;&lt;/td&gt; &lt;td class="tabhead"&gt;&lt;img src="img/blank.gif" alt="" width="150" height="6"&gt;&lt;br&gt;&lt;b&gt;&lt;?php echo "first name"; ?&gt;&lt;/b&gt;&lt;/td&gt; &lt;td class="tabhead"&gt;&lt;img src="img/blank.gif" alt="" width="150" height="6"&gt;&lt;br&gt;&lt;b&gt;&lt;?php echo "lastname name"; ?&gt;&lt;/b&gt;&lt;/td&gt; &lt;td class="tabhead"&gt;&lt;img src="img/blank.gif" alt="" width="150" height="6"&gt;&lt;br&gt;&lt;b&gt;&lt;?php echo "member id"; ?&gt;&lt;/b&gt;&lt;/td&gt; &lt;td class="tabhead"&gt;&lt;img src="img/blank.gif" alt="" width="50" height="6"&gt;&lt;br&gt;&lt;b&gt;&lt;?php echo "delete"; ?&gt;&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;img src="img/blank.gif" alt="" width="10" height="25"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } $result=mysql_query("SELECT member_id,firstname,lastname,login FROM members ORDER BY firstname"); $i = 0; while($row = mysql_fetch_array($result)) { if ($i &gt; 0) { echo "&lt;tr valign='bottom'&gt;"; echo "&lt;td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='6'&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;tr valign='middle'&gt;"; echo "&lt;td class='tabval'&gt;&lt;img src='img/blank.gif' alt='' width='10' height='20'&gt;&lt;/td&gt;"; echo "&lt;td class='tabval'&gt;&lt;b&gt;".$row['lastname']."&lt;/b&gt;&lt;/td&gt;"; echo "&lt;td class='tabval'&gt;".$row['firstname']." &lt;/td&gt;"; echo "&lt;td class='tabval'&gt;".$row['member_id']." &lt;/td&gt;"; echo "&lt;td class='tabval'&gt;&lt;a onclick=\"return &lt;/span&gt;&lt;/a&gt;&lt;/td&gt;"; echo "&lt;td class='tabval'&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; $i++; } ?&gt; &lt;/table&gt; in this i wanna add tho more things in the table 1 to delete a member and 2 to have approved or denied option for that i made two functiom below code is to delete if($_REQUEST['action']=="del") { $memberId = mysql_real_Escape_string($_REQUEST['member_id']); mysql_query("DELETE FROM members WHERE member_id=$memberId"); } </code></pre> <p>below one for approving members</p> <p>But my problem is I don't know how to include a button or radio button in the table which can pass value delete or approve to these functions.</p> <p>Please tell me how the syntax is to add this button so that for approving I can change the value 0 that I gave in the database to 1 so that member get approved.</p>
[ { "answer_id": 361858, "author": "Levi", "author_id": 27620, "author_profile": "https://Stackoverflow.com/users/27620", "pm_score": 0, "selected": false, "text": "?> <form name=\"deleteUser\" id=\"deleteUser\" method=\"post\" action=\"\">\n<input type=\"hidden\" name=\"member_id\" id=\"m...
2008/12/12
[ "https://Stackoverflow.com/questions/361839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40975/" ]
361,840
<p>This afternoon, upon noticing a broken build and the fact that some files looked like very old versions (about 2 weeks old), I checked the svn log. Apparently just this afternoon, 1 of the developers did an "svn copy" of a directory from an older revision to the same directory. Thus it appears that the latest version "i.e. head" of all the files in that directory are really old, and all the history "i.e. log" is even older.</p> <p>However, I think I can recover by using another "svn copy" (i.e. the disease is the cure). What I am considering doing is finding the revision where the bad "svn copy" was done (say rev 1234) , subtracting 1 (1233) and doing:</p> <pre><code>svn copy -r 1233 file://path/to/messed/up/dir file://path/to/messed/up/dir </code></pre> <p>That <em>should</em> restore the latest version, as well as get back all my history. Am I right about this?</p>
[ { "answer_id": 361961, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 1, "selected": false, "text": "svn rm file:///path/to/messed/up/dir\n" }, { "answer_id": 362209, "author": "Palmin", "author_id":...
2008/12/12
[ "https://Stackoverflow.com/questions/361840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16012/" ]
361,852
<p>Sorry - this may be an easy question, I'm new to iPhone development and still wrapping my head around Views vs ViewControllers.</p> <p>I have a NavigationViewController and I can push Views using the following method in the RootViewController which is connected to a Bar Button Item:</p> <pre><code>- (IBAction)switch:(id)sender { NSLog(@"Swith..."); LibraryViewController *varLibraryViewController = [[LibraryViewController alloc] initWithNibName:@"LibraryViewController" bundle:nil]; [[self navigationController] pushViewController:varLibraryViewController animated:YES]; } </code></pre> <p>I want to call this same method from a button on the same view that is currently loaded. Basically I want to have the Bar Button at the top call the same method as a button on the view. I was wondering how to call a method in the ViewController from the view loaded from that viewController. Hopefully that makes sense.</p> <p>Do I need to create an instance of the RootViewController? I would think that would already be instantiated. Thank you.</p>
[ { "answer_id": 361914, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 1, "selected": false, "text": "" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361852", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29941/" ]
361,854
<p>I'm trying to get udp multicast data using sockets and c++ (c). I have a server with 2 network cards so I need to bind socket to specific interface. Currently I'm testing on another server that has only one network card.</p> <p>When I use INADDR_ANY I can see the udp data, when I bind to specific interface I don't see any data. Function inet_addr is not failing (I removed checking for return value for now).</p> <p>Code is below. On a server with one network card, my IP address is 10.81.128.44. I receive data when I run as: ./client 225.0.0.37 12346</p> <p>This gives me no data: ./client 225.0.0.37 12346 10.81.128.44</p> <p>Any suggestions? (Hope the code compiles, I removed comments ...)</p> <pre><code> #include &lt;stdlib.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/socket.h&gt; #include &lt;netinet/in.h&gt; #include &lt;arpa/inet.h&gt; #include &lt;time.h&gt; #include &lt;string.h&gt; #include &lt;stdio.h&gt; #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; #define HELLO_PORT 12345 #define HELLO_GROUP "225.0.0.37" #define MSGBUFSIZE 256 int main(int argc, char *argv[]) { string source_iface; string group(HELLO_GROUP); int port(HELLO_PORT); if (!(argc &lt; 2)) group = argv[1]; if (!(argc &lt; 3)) port = atoi(argv[2]); if (!(argc &lt; 4)) source_iface = argv[3]; cout &lt;&lt; "group: " &lt;&lt; group &lt;&lt; " port: " &lt;&lt; port &lt;&lt; " source_iface: " &lt;&lt; source_iface &lt;&lt; endl; int fd; if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) &lt; 0) { perror("socket"); exit(1); } u_int yes = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &amp;yes, sizeof(yes)) &lt; 0) { perror("Reusing ADDR failed"); exit(1); } struct sockaddr_in addr; memset(&amp;addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = (source_iface.empty() ? htonl(INADDR_ANY) : inet_addr(source_iface.c_str())); if (bind(fd,(struct sockaddr *)&amp;addr, sizeof(addr)) &lt; 0) { perror("bind"); exit(1); } struct ip_mreq mreq; mreq.imr_multiaddr.s_addr = inet_addr(group.c_str()); mreq.imr_interface.s_addr = (source_iface.empty() ? htonl(INADDR_ANY) : inet_addr(source_iface.c_str())); if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &amp;mreq, sizeof(mreq)) &lt; 0) { perror("setsockopt"); exit(1); } socklen_t addrlen; int nbytes; char msgbuf[MSGBUFSIZE]; while (1) { memset(&amp;msgbuf, 0, MSGBUFSIZE); addrlen = sizeof(addr); if ((nbytes = recvfrom(fd, msgbuf, MSGBUFSIZE, 0, (struct sockaddr *)&amp;addr, &amp;addrlen)) &lt; 0) { perror("recvfrom"); exit(1); } cout.write(msgbuf, nbytes); cout.flush(); } return 0; } </code></pre> <p>Thanks in advance ...</p>
[ { "answer_id": 362485, "author": "David Allan Finch", "author_id": 27417, "author_profile": "https://Stackoverflow.com/users/27417", "pm_score": 2, "selected": false, "text": " struct ip_mreq multi;\n\n multi.imr_multiaddr.s_addr = inet_addr(group.c_str());\n multi.imr_in...
2008/12/12
[ "https://Stackoverflow.com/questions/361854", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,855
<p>I'm running a django instance behind nginx connected using fcgi (by using the manage.py runfcgi command). Since the code is loaded into memory I can't reload new code without killing and restarting the django fcgi processes, thus interrupting the live website. The restarting itself is very fast. But by killing the fcgi processes first some users' actions will get interrupted which is not good. I'm wondering how can I reload new code without ever causing any interruption. Advices will be highly appreciated!</p>
[ { "answer_id": 957050, "author": "sheats", "author_id": 4915, "author_profile": "https://Stackoverflow.com/users/4915", "pm_score": 4, "selected": false, "text": "pid_file=/path/to/pidfile\nport_file=/path/to/port_file\nold_pid=`cat $pid_file`\n\nif [[ -f $port_file ]]; then\n last_po...
2008/12/12
[ "https://Stackoverflow.com/questions/361855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31604/" ]
361,856
<p>I need some help with jQuery script again :-) Just trying to play with jQuery..I use script below for coloring options of select element. It works in pure html, but in my asp.net 2.0 (Master + Content pages) does not. Script is placed in Head section.</p> <pre><code>function pageLoad(){ var allOddSelectOption = "select option:odd"; var evenStyle = "background-color:'#f4f4f4';color:'#555'"; $(allOddSelectOption).attr('style',evenStyle); } </code></pre> <p>I tried also use <code>$(document).ready(function(){</code> but it didn't work too.</p> <p>Any ideas, tips most welcome?</p>
[ { "answer_id": 361861, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 3, "selected": true, "text": "$(document).ready(function(){\n $(\"select option:odd\").css({'background-color' : 'yellow', 'font-weight' : 'b...
2008/12/12
[ "https://Stackoverflow.com/questions/361856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24507/" ]
361,869
<p>I have read a lot of popular standards manuals for open source PHP projects.</p> <p>A lot enforce underscores for variables spaces, and a lot enforce camelCase.</p> <p>Should global functions and variables be named differently to class methods/properties?</p> <p>I know the most important thing is consistency, but I'd like to hear some thoughts on this.</p> <p>What would you recommend?</p>
[ { "answer_id": 361899, "author": "too much php", "author_id": 28835, "author_profile": "https://Stackoverflow.com/users/28835", "pm_score": 0, "selected": false, "text": "grep" }, { "answer_id": 361901, "author": "ieure", "author_id": 45224, "author_profile": "https:/...
2008/12/12
[ "https://Stackoverflow.com/questions/361869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
361,904
<pre><code>function holiday_hitlist($tablename, $hit_user){ global $host, $user, $pass, $dbname; $link = mysql_connect($host, $user, $pass, $dbname); print "&lt;div class=\"hit_list\"&gt; &lt;h3&gt;My Holiday Hitlist&lt;/h3&gt; &lt;p&gt;Five things I want the most, based on my desirability ratings.&lt;br/&gt;You can't go wrong with this stuff!&lt;/p&gt; &lt;ol&gt;"; $sql = "SELECT title, URL, price FROM $dbname.$tablename WHERE user='$hit_user' AND rank &gt;= 3 ORDER BY date DESC LIMIT 5"; $result = mysql_query($sql) or die ("Couldn't retrieve holiday hit list for this user. " . mysql_error()); while($row = mysql_fetch_array($result)) { $title = $row['title']; $url = $row['URL']; $price = "$" . $row['price']; $output = print "&lt;li&gt;&lt;a href=\"$url\" target=\"_blank\"&gt;$title&lt;/a&gt; $price&lt;/li&gt;"; } print "&lt;/ol&gt;&lt;/div&gt;"; return $output; } </code></pre> <p>On an HTML page, it puts the "1" immediately following the closing <code>div</code> tag. Why? </p>
[ { "answer_id": 361915, "author": "Zoredache", "author_id": 20267, "author_profile": "https://Stackoverflow.com/users/20267", "pm_score": 4, "selected": true, "text": "$output = print \"<li><a href=\\\"$url\\\" target=\\\"_blank\\\">$title</a> $price</li>\";\n" }, { "answer_id": 3...
2008/12/12
[ "https://Stackoverflow.com/questions/361904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7853/" ]
361,910
<p>Say you have something like an ASP.NET ASP:DetailsView to show and edit a single record in a database.</p> <p>It's simple to record the error cases... you add validation and a validation summary. When your update form fails validation it naturally makes noise: it shows the validation message and/or the validation summary. Not a single code behind is required.</p> <p>But then, you pass validation, and it makes your update completely silently. There's no sense that anything happened, and there doesn't seem to be any default settings to make a success message without code-behinds.</p> <p>But, even code-behinds are confusing. What event should show the success message? onItemUpdate, right? Fine, but then let's say you make another change and get a validation error? Your success message stays. I wasn't able to find an event that would reliably turn off an existing success message if there were a validation error. </p> <p>This should be web development 101! Why is it so hard?</p> <p><strong>EDIT:</strong></p> <p>Someone suggested using the ItemCommand event... I tried this and many other events, but that success message just won't disappear. Here's some code.</p> <p>My message in ASP.NET</p> <pre><code>&lt;label id="successMessage" class="successMessage" runat="server"&gt;&lt;/label&gt; </code></pre> <p>And my DataView tag (simplified):</p> <pre><code> &lt;asp:DetailsView Id="EditClient" DataKeyNames="LicenseID" DataSourceID="MySource" runat="server" OnItemUpdated="SuccessfulClientUpdate" OnItemCommand="ClearMessages"&gt; </code></pre> <p>And, my code-behind:</p> <pre><code>protected void SuccessfulClientUpdate(object sender, DetailsViewUpdatedEventArgs e) { successMessage.InnerText = string.Format("Your changes were saved."); successMessage.Visible = true; } protected void ClearMessages(object sender, DetailsViewCommandEventArgs e) { successMessage.InnerText = string.Empty; successMessage.Visible = false; } </code></pre> <p>Once I do a successful update, however, nothing seems to make that message disappear, not even failed validation.</p> <p><strong>2nd EDIT:</strong></p> <p>Just want to be clear that I did try putting the ClearMessages code in Page_Load. However, nothing seems to make that successMessage label disappear when I hit update a 2nd time WITH a validation error. Can anyone suggest any other troubleshooting tips?</p>
[ { "answer_id": 361952, "author": "JoshBerke", "author_id": 26160, "author_profile": "https://Stackoverflow.com/users/26160", "pm_score": 0, "selected": false, "text": "protected void ClearMessages(object sender, DetailsViewCommandEventArgs e)\n{\n successMessage.InnerText = string.Emp...
2008/12/12
[ "https://Stackoverflow.com/questions/361910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22452/" ]
361,921
<pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; namespace ConsoleApplication1 { public class Class1 { static void Main(string[] args) { List&lt;Car&gt; mylist = new List&lt;Car&gt;(); Car car1; Car car2; Car car3; car1 = new Car() { make = "Honda", id = 1 }; car2 = new Car() { make = "toyota", id = 2 }; car3 = new Car() { make = "Honda", id = 3, color = "red" }; mylist.Add(car1); mylist.Add(car2); **////mylist.Where(p =&gt; p.id == 1).SingleOrDefault() = car3;** } } public class Car { public int id { get; set; } public string make { get; set; } public string color { get; set; } } } </code></pre> <p>How can I update the list by replacing the honda car of Id 1 with honda car with Id 3 in the best way.</p>
[ { "answer_id": 361936, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "int index = mylist.FindIndex(p => p.id == 1);\nif(index<0) {\n mylist.Add(car3);\n} else {\n mylist[index] = car...
2008/12/12
[ "https://Stackoverflow.com/questions/361921", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42564/" ]
361,922
<p>I am trying to create 1 Parent Drop Down, that has 2 dependent child drop down lists using JAVASCRIPT.</p> <p>My html page is at - <a href="http://www.larkgrove.com/entryform/entryform.html" rel="nofollow noreferrer">http://www.larkgrove.com/entryform/entryform.html</a></p> <p>I am using the Dynamic Options Lists / Dependent Selects: <a href="http://www.javascripttoolbox.com/lib/dynamicoptionlist/examples.php" rel="nofollow noreferrer">http://www.javascripttoolbox.com/lib/dynamicoptionlist/examples.php</a></p> <p>If you check out my site, you can see that I can get the Child lists to change between nothing there and "NULL", but thats about all I can do.</p> <p>THANKS!</p>
[ { "answer_id": 361987, "author": "danieltalsky", "author_id": 22452, "author_profile": "https://Stackoverflow.com/users/22452", "pm_score": 0, "selected": false, "text": "<script type=\"text/javascript\">\nvar TESTLIST = new DynamicOptionList(\"PARENT1\",\"CHILD1\",\"CHILD2\");\nTESTLIST...
2008/12/12
[ "https://Stackoverflow.com/questions/361922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
361,930
<p>Are all these types of sites just illegally scraping Google or another search engine?<br> As far as I can tell ther is no 'legal' way to get this data for a commercial site.. The Yahoo! api ( <a href="http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html" rel="nofollow noreferrer">http://developer.yahoo.com/search/siteexplorer/V1/inlinkData.html</a> ) is only for noncommercial use, Yahoo! Boss does not allow automated queries etc.<br> Any ideas?</p>
[ { "answer_id": 754901, "author": "Shalom Craimer", "author_id": 54491, "author_profile": "https://Stackoverflow.com/users/54491", "pm_score": 2, "selected": false, "text": "link:http://www.google.com\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361930", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45598/" ]
361,943
<p>I wanted to know why UDP is used in RTP rather than TCP ?. Major VoIP Tools used only UDP as i hacked some of the VoIP OSS.</p>
[ { "answer_id": 1910859, "author": "rdegges", "author_id": 194175, "author_profile": "https://Stackoverflow.com/users/194175", "pm_score": 0, "selected": false, "text": "rtpchecksums=yes ; or no if you prefer\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361943", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38038/" ]
361,955
<p>I'm trying to build about 600 projects some are .net 2.0, some are 3.5. I'm using Windows 2003 Enterprise Edition 32 bit with all the latest windows updates.</p> <p>Builds fine when maxcpucount is 1. If I bump it up to try and improve performance it get reference errors. When I look at the project references from where the error occurred it appears they should have been built in order.</p> <p>Below I've provided an example of the errors that are causing the build to be broken. Don't get hung up on the project names or the relative paths because I've changed this so I don't get in trouble with my employer.</p> <p>It's like the relative project references can't be properly resolved when more then one core is building the solution.</p> <pre><code>"C:\SVN\MyLibrary\MyLibrary.csproj" (default target) (15) -&gt; "C:\SVN\FileProcessor\FileProcessor.csproj" (default target) (17) -&gt; (ResolveProjectReferences target) -&gt; C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning : The referenced project '..\..\Manager\Manager.csproj' does not exist. "C:\SVN\MyLibrary\MyLibrary.csproj" (default target) (15) -&gt; "C:\SVN\FileProcessor\FileProcessor.csproj" (default target) (17) -&gt; (CoreCompile target) -&gt; FileProcessor.cs(18,39): error CS0234: The type or namespace name 'Manager' does not exist in the namespace 'TheNamespace' (are you missing an assembly reference?) </code></pre> <p>I'm not using msbuild on a solution file. I'm using wildcards to select all csproj files then feeding them to msbuild. For development we have multiple solutions we use for different components of the system. 95% are project reference, the only binary references are for core utility libs</p>
[ { "answer_id": 378668, "author": "Gregg", "author_id": 18266, "author_profile": "https://Stackoverflow.com/users/18266", "pm_score": 3, "selected": false, "text": "\n<ProjectReference Include=\"..\\..\\Manager\\Manager.csproj\">\n <Project>{C0F60D74-3EF9-4B49-9563-66E70D0DDF43}</Pro...
2008/12/12
[ "https://Stackoverflow.com/questions/361955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45005/" ]
361,966
<p>I need to create a 3D model of a cube with a circular hole punched at the center of one face passing completely through the cube to the opposite side. I am able to generate the vertices for the faces and for the holes.</p> <p>Four of the faces (untouched by the hole) can be modeled as a single triangle strip. The inside of the hole can also be modeled as a single triangle strip.</p> <p>How do I generate the index buffer for the faces with the holes? Is there a standard algorithm(s) to do this?</p> <p>I am using Direct3D but ideas from elsewhere are welcome.</p>
[ { "answer_id": 362130, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 3, "selected": false, "text": "(x/M,y/M)" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/361966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45603/" ]
361,973
<p>I have written my program in c# .net. I want to convert it in to a powershell cmdlet. I was instructed to use pssnapin and getproc programs. Can anyone plz help me out..</p> <p>Regards Arun</p>
[ { "answer_id": 362191, "author": "Oliver Friedrich", "author_id": 44532, "author_profile": "https://Stackoverflow.com/users/44532", "pm_score": 2, "selected": false, "text": "namespace System.Management.Automation\n{\n public abstract class PSCmdlet : Cmdlet\n {\n protected ...
2008/12/12
[ "https://Stackoverflow.com/questions/361973", "https://Stackoverflow.com", "https://Stackoverflow.com/users/201406/" ]
361,975
<p>How do I properly set the default character encoding used by the JVM (1.5.x) programmatically?</p> <p>I have read that <code>-Dfile.encoding=whatever</code> used to be the way to go for older JVMs. I don't have that luxury for reasons I wont get into.</p> <p>I have tried:</p> <pre><code>System.setProperty("file.encoding", "UTF-8"); </code></pre> <p>And the property gets set, but it doesn't seem to cause the final <code>getBytes</code> call below to use UTF8:</p> <pre><code>System.setProperty("file.encoding", "UTF-8"); byte inbytes[] = new byte[1024]; FileInputStream fis = new FileInputStream("response.txt"); fis.read(inbytes); FileOutputStream fos = new FileOutputStream("response-2.txt"); String in = new String(inbytes, "UTF8"); fos.write(in.getBytes()); </code></pre>
[ { "answer_id": 361984, "author": "Dov Wasserman", "author_id": 26010, "author_profile": "https://Stackoverflow.com/users/26010", "pm_score": 5, "selected": false, "text": "String.getBytes(\"charsetName\")" }, { "answer_id": 362006, "author": "erickson", "author_id": 3474,...
2008/12/12
[ "https://Stackoverflow.com/questions/361975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
362,000
<p>I have this input text:</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;&lt;/head&gt;&lt;body&gt;&lt;table cellspacing="0" cellpadding="0" border="0" align="center" width="603"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td&gt;&lt;table cellspacing="0" cellpadding="0" border="0" width="603"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td width="314"&gt;&lt;img height="61" width="330" src="/Elearning_Platform/dp_templates/dp-template-images/awards-title.jpg" alt="" /&gt;&lt;/td&gt; &lt;td width="273"&gt;&lt;img height="61" width="273" src="/Elearning_Platform/dp_templates/dp-template-images/awards.jpg" alt="" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;table cellspacing="0" cellpadding="0" border="0" align="center" width="603"&gt; &lt;tbody&gt;&lt;tr&gt; &lt;td colspan="3"&gt;&lt;img height="45" width="603" src="/Elearning_Platform/dp_templates/dp-template-images/top-bar.gif" alt="" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td background="/Elearning_Platform/dp_templates/dp-template-images/left-bar-bg.gif" width="12"&gt;&lt;img height="1" width="12" src="/Elearning_Platform/dp_templates/dp-template-images/left-bar-bg.gif" alt="" /&gt;&lt;/td&gt; &lt;td width="580"&gt;&lt;p&gt;&amp;nbsp;what y all heard?&lt;/p&gt;&lt;p&gt;i'm shark oysters.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt; &lt;td background="/Elearning_Platform/dp_templates/dp-template-images/right-bar-bg.gif" width="11"&gt;&lt;img height="1" width="11" src="/Elearning_Platform/dp_templates/dp-template-images/right-bar-bg.gif" alt="" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3"&gt;&lt;img height="31" width="603" src="/Elearning_Platform/dp_templates/dp-template-images/bottom-bar.gif" alt="" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt; </code></pre> <p>As you can see, there's no newline in this chunk of HTML text, and I need to look for all image links inside, copy them out to a directory, and change the line inside the text to something like <code>./images/file_name</code>. </p> <p>Currently, the Perl code that I'm using looks like this:</p> <pre><code>my ($old_src,$new_src,$folder_name); foreach my $record (@readfile) { ## so the if else case for the url replacement block below will be correct $old_src = ""; $new_src = ""; if ($record =~ /\&lt;img(.+)/){ if($1=~/src=\"((\w|_|\\|-|\/|\.|:)+)\"/){ $old_src = $1; my @tmp = split(/\/Elearning/,$old_src); $new_src = "/media/www/vprimary/Elearning".$tmp[-1]; push (@images, $new_src); $folder_name = "images"; }## end if } elsif($record =~ /background=\"(.+\.jpg)/){ $old_src = $1; my @tmp = split(/\/Elearning/,$old_src); $new_src = "/media/www/vprimary/Elearning".$tmp[-1]; push (@images, $new_src); $folder_name = "images"; } elsif($record=~/\&lt;iframe(.+)/){ if($1=~/src=\"((\w|_|\\|\?|=|-|\/|\.|:)+)\"/){ $old_src = $1; my @tmp = split(/\/Elearning/,$old_src); $new_src = "/media/www/vprimary/Elearning".$tmp[-1]; ## remove the ?rand behind the html file name if($new_src=~/\?rand/){ my ($fname,$rand) = split(/\?/,$new_src); $new_src = $fname; my ($fname,$rand) = split(/\?/,$old_src); $old_src = $fname."\\?".$rand; } print "old_src::$old_src\n"; ##s7test print "new_src::$new_src\n\n"; ##s7test push (@iframes, $new_src); $folder_name = "iframes"; }## end if }## end if my $new_record = $record; if($old_src &amp;&amp; $new_src){ $new_record =~ s/$old_src/$new_src/ ; print "new_record:$new_record\n"; ##s7test my @tmp = split(/\//,$new_src); $new_record =~ s/$new_src/\.\\$folder_name\\$tmp[-1]/; ## print "new_record2:$new_record\n\n"; ##s7test }## end if print WRITEFILE $new_record; } # foreach </code></pre> <p>This is only sufficient to handle HTML text with newlines in them. I thought only looping the regex statement, but then i would have to change the matching line to some other text.</p> <p>Do you have any idea if there an elegant Perl way to do this? Or maybe I'm just too dumb to see the obvious way of doing it, plus I know putting global option doesn't work.</p> <p>thanks. ~steve</p>
[ { "answer_id": 362090, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 3, "selected": true, "text": "while ($string =~ m/(?:\\<\\s*(?:img|iframe)[^\\>]+src\\s*=\\s*\\\"((?:\\w|_|\\\\|-|\\/|\\.|:)+)\\\"|background\\s*=\\s*\\\"([^\...
2008/12/12
[ "https://Stackoverflow.com/questions/362000", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38124/" ]
362,032
<p>I want the Perl script to extract a data from a text file and save it as another text file. Each line of the text file contains an URL to a jpg like "<a href="http://pics1.riyaj.com/thumbs/000/082/104//small.jpg" rel="nofollow noreferrer">http://pics1.riyaj.com/thumbs/000/082/104//small.jpg</a>". I want the script to extract the last 6 numbers of each jpg URL, (i.e 082104) to a variable. I want the variable to be added to a different location on each line of the new text.</p> <p>Input text:</p> <pre><code>text http://pics1.riyaj.com/thumbs/000/082/104/small.jpg text text http://pics1.riyaj.com/thumbs/000/569/315/small.jpg text </code></pre> <p>Output text:</p> <pre><code>text php?id=82104 text text php?id=569315 text </code></pre> <p>Thanks</p>
[ { "answer_id": 362128, "author": "brian d foy", "author_id": 2766176, "author_profile": "https://Stackoverflow.com/users/2766176", "pm_score": 2, "selected": false, "text": "-p" }, { "answer_id": 362139, "author": "Axeman", "author_id": 11289, "author_profile": "https...
2008/12/12
[ "https://Stackoverflow.com/questions/362032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45614/" ]
362,038
<p>I need to build a div with curved corner border, with out using any images in the corner. Is it possible?</p> <p>I dont want to insert curved images in the corner, Please help me regarding this.</p>
[ { "answer_id": 362047, "author": "alex", "author_id": 31671, "author_profile": "https://Stackoverflow.com/users/31671", "pm_score": 3, "selected": false, "text": "border-radius: 10px;\n" }, { "answer_id": 362056, "author": "jimg", "author_id": 2621, "author_profile": ...
2008/12/12
[ "https://Stackoverflow.com/questions/362038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38172/" ]
362,042
<p>We have a client application that has reference to a webservice. We had set the timeout property on the webclientprotocol object to 50 (ms) and wanted to observe what goes on. We tied up a long running webmethod that returns a huge DataSet to the client. When the default value was there, the DataSet was returned properly to the client. When we changed this to 50(ms), we did not observe anything. Our assumption was that there would be some kind of exception that occurs on the client side since the timeout has occurred. Can anyone please explain what is going on here</p> <p>Thanks Raj</p>
[ { "answer_id": 5386072, "author": "P Daddy", "author_id": 36388, "author_profile": "https://Stackoverflow.com/users/36388", "pm_score": 0, "selected": false, "text": "WebException" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
362,044
<p><strong>My requirement</strong></p> <p>A table needs to maintain a <em>status</em> column.</p> <p>This column represents one of 5 states.</p> <p><br> <strong>initial design</strong></p> <p>I figured I can just make it an integer column and represent the states using a numeric value.</p> <ul> <li>0 = start</li> <li>1 = running</li> <li>2 = crashed</li> <li>3 = paused</li> <li>4 = stopped</li> </ul> <p>Since I don't want my app to maintain the mapping from the integers to their string description, I plan to place those in a separate state description table (relying on a FK relation).</p> <p>Then I discovered that MySQL has an ENUM type which matches my requirement exactly. Other than a direct dependency on MySQL, are there any pitfalls with using the ENUM type?</p>
[ { "answer_id": 362058, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 8, "selected": true, "text": "ALTER TABLE" }, { "answer_id": 362888, "author": "MatthieuP", "author_id": 41469, "author_profile":...
2008/12/12
[ "https://Stackoverflow.com/questions/362044", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
362,055
<p>Is it possible to host a Maven repository that serves the artifacts (at least the jar files) from SourceForge's file release system (since they are already there and SF provides download statistics and such)? </p> <p>All the repositories I have seen use the same directory layout, but is that a must? Download URLs would have to look more like <em><a href="http://sf.net/something.cgi?file-id=1234567" rel="nofollow noreferrer">http://sf.net/something.cgi?file-id=1234567</a></em></p> <p>There would only be a small number of files in the project, so that maintaining the download URL in some kind of repository metadata XML file semi-manually is still an option.</p> <p><strong>Note:</strong> This is kind of the opposite question to <a href="https://stackoverflow.com/questions/16487/how-can-i-deploy-artifacts-from-a-maven-build-to-the-sourceforge-file-release-s">How can I deploy artifacts from a Maven build to the SourceForge File Release System?</a></p> <p><strong>Clarification:</strong> I want to put the files in the File Release System (Project Downloads), not the project web space or the subversion repository.</p>
[ { "answer_id": 1896946, "author": "Huluvu424242", "author_id": 373498, "author_profile": "https://Stackoverflow.com/users/373498", "pm_score": 0, "selected": false, "text": "<plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-install-plugin</artifactId>\n ...
2008/12/12
[ "https://Stackoverflow.com/questions/362055", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14955/" ]
362,059
<p>What is the Big-O time complexity of the following nested loops:</p> <pre class="lang-cpp prettyprint-override"><code>for (int i = 0; i &lt; N; i++) { for (int j = i + 1; j &lt; N; j++) { System.out.println(&quot;i = &quot; + i + &quot; j = &quot; + j); } } </code></pre> <p>Would it be <em>O(N^2)</em> still?</p>
[ { "answer_id": 59340933, "author": "Ashwin", "author_id": 6662058, "author_profile": "https://Stackoverflow.com/users/6662058", "pm_score": 2, "selected": false, "text": "for (int i = 0; i < n; i++)\n for (int j = i; j < n; j++)\n println(...);\n" }, { "answer_id": 7153...
2008/12/12
[ "https://Stackoverflow.com/questions/362059", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2635/" ]
362,104
<p>I have a Template Column under which I have Placed a Dropdownlist. Now I would Like to get the selectedRow of the datagrid on selectedIndeChanged event of the dropdownlist that's inside the template Column</p>
[ { "answer_id": 362177, "author": "Tom Jelen", "author_id": 28399, "author_profile": "https://Stackoverflow.com/users/28399", "pm_score": 2, "selected": true, "text": " protected void DropDown_SelectedIndexChanged(object sender, object eventdata)\n {\n int gridRowIndex = ((Da...
2008/12/12
[ "https://Stackoverflow.com/questions/362104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
362,105
<p>I have a Hash like this</p> <pre><code>{ 55 =&gt; {:value=&gt;61, :rating=&gt;-147}, 89 =&gt; {:value=&gt;72, :rating=&gt;-175}, 78 =&gt; {:value=&gt;64, :rating=&gt;-155}, 84 =&gt; {:value=&gt;90, :rating=&gt;-220}, 95 =&gt; {:value=&gt;39, :rating=&gt;-92}, 46 =&gt; {:value=&gt;97, :rating=&gt;-237}, 52 =&gt; {:value=&gt;73, :rating=&gt;-177}, 64 =&gt; {:value=&gt;69, :rating=&gt;-167}, 86 =&gt; {:value=&gt;68, :rating=&gt;-165}, 53 =&gt; {:value=&gt;20, :rating=&gt;-45} } </code></pre> <p>How can i sort it by <strong><em>:rating</em></strong>? Or maybe i should use some different structure?</p>
[ { "answer_id": 362133, "author": "Gareth", "author_id": 31582, "author_profile": "https://Stackoverflow.com/users/31582", "pm_score": 3, "selected": false, "text": ">> { :a => 4, :b => 12, :c => 3, :d => 8 }.sort_by { |key, value| value }\n=> [[:c, 3], [:a, 4], [:d, 8], [:b, 12]]\n" },...
2008/12/12
[ "https://Stackoverflow.com/questions/362105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45622/" ]
362,112
<p>Consider a simple table with an auto-increment column like this:</p> <pre><code>CREATE TABLE foo ( `fooid` bigint unsigned NOT NULL auto_increment, ....snipped.... other columns PRIMARY KEY (`fooid`) ) ENGINE=InnoDB AUTO_INCREMENT=10 </code></pre> <p>How does one redesign this so that we don't hit the max of the bigint datatype ? The unsigned range is 0 to 18446744073709551615. I don't know how long it will take to reach 18446744073709551615, but like the Y2K problem, I want to be ready for it.</p>
[ { "answer_id": 362471, "author": "flamingLogos", "author_id": 8161, "author_profile": "https://Stackoverflow.com/users/8161", "pm_score": 4, "selected": false, "text": "AUTO_INCREMENT" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362112", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
362,120
<p>Why the FontFamily param of the Font object is a string and not an enum?</p>
[ { "answer_id": 362145, "author": "Jonathan C Dickinson", "author_id": 24064, "author_profile": "https://Stackoverflow.com/users/24064", "pm_score": 3, "selected": true, "text": "public enum MyEnum\n{\n A = 1,\n B = 2\n}\n\npublic enum FooEnum\n{\n A,\n B\n}\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45624/" ]
362,121
<p>I have the following table</p> <pre> custid ordid qty datesold 1 A2 12 2008-01-05 2 A5 5 2008-01-02 1 A1 5 2008-01-01 2 A7 3 2007-02-05 </pre> <p>What't the best way of getting the previous order for every customer?</p> <p>Thanks</p>
[ { "answer_id": 362143, "author": "Robert Wagner", "author_id": 10784, "author_profile": "https://Stackoverflow.com/users/10784", "pm_score": 1, "selected": false, "text": "SELECT custid, ordid, qty, datesold\nFROM (\n SELECT *, \n Row_Number() OVER (PARTITION BY custid ORDER BY...
2008/12/12
[ "https://Stackoverflow.com/questions/362121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23667/" ]
362,124
<p>any generic way to trace/log values of all local variables when an exception occurs in a method? (in C# 3)</p>
[ { "answer_id": 373934, "author": "usman shaheen", "author_id": 7722, "author_profile": "https://Stackoverflow.com/users/7722", "pm_score": 4, "selected": true, "text": "private static void TraceMethodArguments(MethodExecutionEventArgs eventArgs)\n{\n object[] parameters = eventArgs.Ge...
2008/12/12
[ "https://Stackoverflow.com/questions/362124", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7722/" ]
362,154
<p>I'm just reading Code Complete by Steve McConell and I'm thinking of an Example he gives in a section about loose coupling. It's about the interface of a method that calculates the number of holidays for an employee, which is calculated from the entry date of the employee and her sales. The author suggests a to have entry date and sales as the parameters of the method instead of an instance of the employee:</p> <pre><code>int holidays(Date entryDate, Number sales) </code></pre> <p>instead of </p> <pre><code>int holidays(Employee emp) </code></pre> <p>The argument is that this decouples the client of the method because it does not need to know anything about the Employee class.</p> <p>Two things came to my mind:</p> <ol> <li><p>Providing all the parameters that are needed for the calculation breaks encapsulation. It shows the internals of the method on how it computes the result.</p></li> <li><p>It's harder to change, e.g. when someone decides that also the age of the employee should be included in the calculation. One would have to change the signature.</p></li> </ol> <p>What's your opinion?</p>
[ { "answer_id": 362180, "author": "Brian Rasmussen", "author_id": 38206, "author_profile": "https://Stackoverflow.com/users/38206", "pm_score": 0, "selected": false, "text": "Sum(int a, int b)" }, { "answer_id": 362181, "author": "Chuck Conway", "author_id": 17360, "au...
2008/12/12
[ "https://Stackoverflow.com/questions/362154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18722/" ]
362,202
<p>I am looking for a reference database that can be used to test for possible name typos in a contact database. This is for a batch process, so performance isn't a real issue. Ideally I'd like a comprehensive database, but even something like "top 5000" would go a long way. </p> <p>Thanks!</p>
[ { "answer_id": 362303, "author": "Mapad", "author_id": 28165, "author_profile": "https://Stackoverflow.com/users/28165", "pm_score": 4, "selected": false, "text": "Phil, Phile, Philip, Philipp, Phillip, Felipe, Philippe" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
362,215
<p>I want to build a threaded forum for an elearning site (opensource asp.net mvc ofcourse, though this doesn't matter for this question). </p> <p>What should be the DB structure which will help retrieve the forum postings with optimum performance? I am not putting a no. to it as it may vary with the amount of rows being retrieved.</p> <p>Besides I should be able to link a particular thread with another threads. For eg. show "Related Forum Links".</p> <p>I am using SQL Server 2005.</p> <p>The following is the structure that I have in mind (shamelessly took it from ) <a href="http://weblogs.asp.net/stephenwalther/archive/2008/09/05/asp-net-mvc-application-building-forums-3-post-messages.aspx" rel="nofollow noreferrer">Stephen Walther Excellent blog post</a></p> <p>Table : Forum</p> <pre><code>· Id · ParentId (null if this is the first message) · ParentThreadId (Identify message in the same thread) · Author · Subject · Body · PostedDate </code></pre> <p>Table: RelatedForum</p> <pre><code>· ForumId · RelatedForumId </code></pre> <p>Ideas/suggestions welcome.</p> <p>Thanks in advance.</p>
[ { "answer_id": 362230, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 3, "selected": true, "text": "WHERE ParentId = @SomeId" }, { "answer_id": 362246, "author": "Supernovah", "author_id": 36076, "author...
2008/12/12
[ "https://Stackoverflow.com/questions/362215", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34644/" ]
362,222
<p>I am actually rendering an excel file in the browser. I use the Response.Writefile(filePath) to dod this. It is working perfectly fine in few of the machines. I am getting a pop up with "Open","Save" and "Cancel" option. </p> <p>But incase of few machines after i do a save click on the popup a plain empty page remains open. This happens only in few of the machines. This window just flickers in the other machine and closes by itself. Please let me know of what can be done to avoid this plain empty page to be closed by itself after the file is opened or saved.</p>
[ { "answer_id": 362712, "author": "HectorMac", "author_id": 1400, "author_profile": "https://Stackoverflow.com/users/1400", "pm_score": 3, "selected": true, "text": "Response.ContentType = \"application/x-excel\";\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20951/" ]
362,231
<p>I'm interested in implementing autocomplete in Python. For example, as the user types in a string, I'd like to show the subset of files on disk whose names start with that string. </p> <p>What's an efficient algorithm for finding strings that match some condition in a large corpus (say a few hundred thousand strings)? Something like:</p> <pre><code>matches = [s for s in allfiles if s.startswith(input)] </code></pre> <p>I'd like to have the condition be flexible; eg. instead of a strict startswith, it'd be a match so long as all letters in input appears in s in the same order. What's better than the brute-force method I'm showing here?</p>
[ { "answer_id": 362285, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "set_completer()" }, { "answer_id": 362433, "author": "Brian", "author_id": 9493, "author_profile": "https:...
2008/12/12
[ "https://Stackoverflow.com/questions/362231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13055/" ]
362,260
<p>How does <code>const</code> (pointers, references and member functions) help with thread safety in C++?</p>
[ { "answer_id": 362362, "author": "Evgeny Lazin", "author_id": 42371, "author_profile": "https://Stackoverflow.com/users/42371", "pm_score": 3, "selected": false, "text": "class Foo\n{\n size_t size_;\npublic:\n ...\n size_t get_size() const\n {\n return size_\n }\n}...
2008/12/12
[ "https://Stackoverflow.com/questions/362260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11828/" ]
362,269
<p>I am having a very strange problem. I have a very large regular expression searching for certain words in some text (RegEx looks something like this: <code>(?i)\b(a|b|c|d...)\b;</code> and so on where a, b, c, d, represent words). Anyway, I put it in a pre compiled assembly to speed things up a bit, however the problem is that pre compiled regex does not work the same way as a non compiled version of the same regex... o_0</p> <p>For example if the regex is: <code>(?i)\b(he|desk)\b</code> and I pass "helpdesk" through it the pre compiled version returns "lp" so the words he and desk gets striped out as if the boundary condition is not working at all, however if I do use exactly the same regular expression a non pre compiled version it works just fine... Does anyone know if I may be missing anything?</p> <p>Thanks</p> <p>(Sorry using VB.Net and C#)</p>
[ { "answer_id": 362370, "author": "Markus Jarderot", "author_id": 22364, "author_profile": "https://Stackoverflow.com/users/22364", "pm_score": 1, "selected": false, "text": "\\w+" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45645/" ]
362,278
<p>I'm begginer in java I'm reading data from serial port and I have stored the data in string array data is 24 byte length.</p> <p>Data I'm getting as output: 12120814330006050.0 </p> <p>data also contains hexadecimal character in the string I want to read first character of the string. I have done:</p> <pre><code>String str=dispArray[i].substring(1,2); int i= Integer.parseInt(str,16); System.out.println("Decimal:="+ i); </code></pre> <p>But I'm getting NumberFormatException.plz help me to read hexadecimal character.</p> <p>Thanks for reply</p>
[ { "answer_id": 362289, "author": "Markus Lausberg", "author_id": 39062, "author_profile": "https://Stackoverflow.com/users/39062", "pm_score": 2, "selected": false, "text": "str.getChar(0);\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
362,300
<p>I plan to use a distributed cache in my load-balanced webapp. So I'm going to try to abstract out the common functions between apache ehcache and memcached.</p> <p>My goal is to be able to make a simple configuration switch to select the caching solution to use. Should I go the SPI route e.g. like how XML parsers are wired in ?</p>
[ { "answer_id": 362289, "author": "Markus Lausberg", "author_id": 39062, "author_profile": "https://Stackoverflow.com/users/39062", "pm_score": 2, "selected": false, "text": "str.getChar(0);\n" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24457/" ]
362,326
<p>I have 6 classes, which are all document types. All the document types have the same 8 fields. There is one class which consists of only these 8 fields. The rest of the classes have more fields. Some of these classes have the same fields (beside the 8 fields).</p> <p>Example:</p> <p>class Document: fields 1 to 8</p> <p>class Form: fields 1 to 8 and field 9 and 10</p> <p>class WorkInstruction: fields 1 to 8 and field 9 and 10</p> <p>class Procedure: fields 1 to 10 and field 11</p> <p>Hopefully this will make clear my point.</p> <p>My question is, what is the best way to implement this? Should i make one or more interfaces, or should i use abstract classes?</p> <p>Thnx</p>
[ { "answer_id": 362332, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 3, "selected": true, "text": "class Form : Document { ... }\n\n// Later on\nControls.Add(new DocumentDisplay(form));\n" }, { "answer_id": 36248...
2008/12/12
[ "https://Stackoverflow.com/questions/362326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40676/" ]
362,328
<p>I'm trying to run PHPDocumentor on my WAMPServer setup. It runs fine, but I'd like to exclude certain directories, such as \sqlbuddy\ which don't contain my own code. Ironically, PHPDocumentor appears to be ignoring my --ignore switch. I've tried several ways of expressing the same thing, but with the same result. Below is the command I'm running it with:</p> <pre><code>php.exe "C:\Users\username\Documents\PhpDocumentor\phpdoc" -t "C:\Program Files\wamp\www\docs" -o HTML:default:default -d "C:\Program Files\wamp\www" --ignore sqlbuddy\ --ignore docs\ </code></pre> <p>Many thanks.</p>
[ { "answer_id": 4105306, "author": "Sonata", "author_id": 498238, "author_profile": "https://Stackoverflow.com/users/498238", "pm_score": 3, "selected": false, "text": "--ignore sqlbuddy/,docs/" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4742/" ]
362,360
<p>I am developing a Web Album using Grails and for image processing, I am using grails-image-tools plugin. I need a functionality to resize the images if the uploaded images size is too big (for eg: more than 600 * 840 ) . In this case I need to resize this image to 600 * 840). What is the most efficient way to do this? Thanks a lot.</p>
[ { "answer_id": 362411, "author": "Warrior", "author_id": 40933, "author_profile": "https://Stackoverflow.com/users/40933", "pm_score": 4, "selected": true, "text": "import java.awt.Image as AWTImage \nimport java.awt.image.BufferedImage \nimport javax.swing.ImageIcon \nimport javax....
2008/12/12
[ "https://Stackoverflow.com/questions/362360", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11193/" ]
362,367
<p>So in C#, I can treat a <code>string[]</code> as an <code>IEnumerable&lt;string&gt;</code>.</p> <p>Is there a Java equivalent?</p>
[ { "answer_id": 362387, "author": "Learning", "author_id": 18275, "author_profile": "https://Stackoverflow.com/users/18275", "pm_score": 3, "selected": false, "text": "Iterable <T>" }, { "answer_id": 362396, "author": "bruno conde", "author_id": 31136, "author_profile"...
2008/12/12
[ "https://Stackoverflow.com/questions/362367", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35086/" ]
362,384
<p>I ask because I am sending a byte stream from a C process to Java. On the C side the 32 bit integer has the LSB is the first byte and MSB is the 4th byte.</p> <p>So my question is: On the Java side when we read the byte as it was sent from the C process, what is <a href="https://en.wikipedia.org/wiki/Endianness" rel="noreferrer">endian</a> on the Java side?</p> <p>A follow-up question: If the endian on the Java side is not the same as the one sent, how can I convert between them?</p>
[ { "answer_id": 362390, "author": "Jonas Elfström", "author_id": 44620, "author_profile": "https://Stackoverflow.com/users/44620", "pm_score": 4, "selected": false, "text": "int i = (int) b & 0xFF;\n" }, { "answer_id": 8432010, "author": "WB Greene", "author_id": 1087865, ...
2008/12/12
[ "https://Stackoverflow.com/questions/362384", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42303/" ]
362,386
<pre><code>dev%40bionic%2Dcomms%2Eco%2Euk </code></pre> <p>I want to turn the above back in to readable text. Can anyone tell me how? Thanks</p> <p>EDIT Forgive my oversight, PHP is the language of choice!</p>
[ { "answer_id": 362403, "author": "Piskvor left the building", "author_id": 19746, "author_profile": "https://Stackoverflow.com/users/19746", "pm_score": 2, "selected": false, "text": "decodeURIComponent(\"dev%40bionic%2Dcomms%2Eco%2Euk\")" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31677/" ]
362,402
<p>I have found <a href="http://www.jamesholmes.com/struts/console/help.html" rel="nofollow noreferrer">Struts Console Tool</a> but its development stopped in 2004, so it works with Netbeans 3.2.</p> <p>Is there a way to install it under Netbeans 6.5?</p> <p>Are there any options to edit struts-config.xml above the XML level?</p>
[ { "answer_id": 365162, "author": "asalamon74", "author_id": 21348, "author_profile": "https://Stackoverflow.com/users/21348", "pm_score": 2, "selected": true, "text": "struts-config.xml" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21047/" ]
362,419
<p>I'd like to periodically run an arbitrary .NET exe under a specified user account from a Windows Service. </p> <p>So far I've got my windows service running with logic to decide what the target process is, and when to run it. The target process is started in the following manner:</p> <ol> <li>The Windows Service is started using "administrator" credentials.</li> <li>When the time comes, an intermediate .NET process is executed with arguments detailing which process should be started (filename, username, domain, password).</li> <li>This process creates a new System.Diagnostics.Process, associates a ProcessStartInfo object filled with the arguments passed to it, and then calls Start() on the process object.</li> </ol> <p>The <strong>first time</strong> this happens, <strong>the target process executes fine and then closes normally</strong>. Every subsequent time however, as soon as the target process is started it throws the error "Application failed to initalize properly (0xc0000142)". Restarting the Windows Service will allow the process to run successfully once again (for the first execution).</p> <p>Naturally, the goal is to have target process execute successfully every time.</p> <p>Regarding step 2 above: To run a process as a different user .NET calls the win32 function CreateProcessWithLogonW. This function requires a window handle to log the specified user in. Since the Windows Service isn't running in Interactive Mode it has no window handle. This intermediate process solves the issue, as it has a window handle which can be passed to the target process.</p> <p>Please, no suggestions of using psexec or the windows task planner. I've accepted my lot in life, and that includes solving the problem in the manner stated above.</p>
[ { "answer_id": 564429, "author": "Matt Jacobsen", "author_id": 15608, "author_profile": "https://Stackoverflow.com/users/15608", "pm_score": 6, "selected": true, "text": "Process proc = null;\nSystem.Diagnostics.ProcessStartInfo info;\nstring domain = string.IsNullOrEmpty(row.Domain) ? \...
2008/12/12
[ "https://Stackoverflow.com/questions/362419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15608/" ]
362,424
<p>Lets say I have a concrete class Class1 and I am creating an anonymous class out of it.</p> <pre><code>Object a = new Class1(){ void someNewMethod(){ } }; </code></pre> <p>Now is there any way I could overload the constructor of this anonymous class. Like shown below</p> <pre><code>Object a = new Class1(){ void someNewMethod(){ } public XXXXXXXX(int a){ super(); System.out.println(a); } }; </code></pre> <p>With something at xxxxxxxx to name the constructor?</p>
[ { "answer_id": 362443, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "public class Test {\n public static void main(String[] args) throws Exception {\n final int fakeConstructorArg ...
2008/12/12
[ "https://Stackoverflow.com/questions/362424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27784/" ]
362,426
<p>What is the "cleanest" way to implement an command-line UI, similar to git's, for example:</p> <pre><code>git push origin/master git remote add origin git://example.com master </code></pre> <p>Ideally also allowing the more flexible parsing, for example,</p> <pre><code>jump_to_folder app theappname v2 jump_to_folder app theappname source jump_to_folder app theappname source v2 jump_to_folder app theappname build v1 jump_to_folder app theappname build 1 jump_to_folder app theappname v2 build </code></pre> <p><code>jump_to_folder</code> is the scripts name, <code>app</code> is the command, <code>theappname</code> is a "fixed-location" parameter, "build" and "v2" etc are arguments (For example, possible arguments would be any number/any number prefixed with a v, or build/source/tmp/config)</p> <p>I could just manually parse the arguments with a series of <code>if</code>/<code>else</code>/<code>elifs</code>, but there must be a more elegant way to do this?</p> <p>As an entirely theoretically example, I could describe the UI schema..</p> <pre><code>app: fixed: application_name optional params: arg subsection: "build" "source" "tmp" "config" arg version: integer "v" + integer </code></pre> <p>Then parse the supplied arguments though the above schema, and get a dictionary:</p> <pre><code>&gt;&gt;&gt; print schema.parse(["app", "theappname", "v1", "source"]) { "application_name": "theappname", "params":{ "subsection": "source", "version":"v1" } } </code></pre> <p>Does such a system exist? If not, how would I go about implementing something along these lines?</p>
[ { "answer_id": 362475, "author": "klozovin", "author_id": 33841, "author_profile": "https://Stackoverflow.com/users/33841", "pm_score": 2, "selected": false, "text": "import sys\n\ndef prog1_func1_act1(): print \"pfa1\"\ndef prog2_func2_act2(): print \"pfa2\"\n\ncommands = {\n \"prog1...
2008/12/12
[ "https://Stackoverflow.com/questions/362426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
362,428
<p>This is a two part question. A dumb technical query and a broader query about my possibly faulty approach to learning to do some things in a language I'm new to.</p> <p>I'm just playing around with a few Python GUI libraries (mostly wxPython and IronPython) for some work I'm thinking of doing on an open source app, just to improve my skills and so forth.</p> <p>By day I am a pretty standard c# bod working with a pretty normal set of MS based tools and I am looking at Python to give me a new perspective. Thus using Ironpython Studio is probably cheating a bit (alright, a lot). This seems not to matter because however much it attempts to look like a Visual Studio project etc. There's one simple behaviour I'm probably being too dumb to implement.</p> <p>I.E. How do I keep my forms in nice separate code files, like the c# monkey I have always been ,and yet invoke them from one another? I've tried importing the form to be invoked to the main form but I just can't seem to get the form to be recognized as anything other than an object. The new form appears to be a form object in its own code file, I am importing the clr. I am trying to invoke a form's 'Show' method. Is this not right?</p> <p>I've tried a few (to my mind more unlikely) ways around this but the problem seems intractable. Is this something I'm just not seeing or would it in fact be more appropriate for me to change the way I think about my GUI scripting to fit round Python (in which case I may switch back to wxPython which seemed more approachable from a Pythonic point of view) rather than try to look at Python from the security of the Visual Studio shell?</p>
[ { "answer_id": 362868, "author": "babbageclunk", "author_id": 38851, "author_profile": "https://Stackoverflow.com/users/38851", "pm_score": 1, "selected": false, "text": "System.Windows.Forms.Form" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
362,429
<p>I've created a utf8 encoded RSS feed which presents news data drawn from a database. I've set all aspects of my database to utf8 and also saved the text which i have put into the database as utf8 by pasting it into notepad and saving as utf8. So everything should be encoded in utf8 when the RSS feed is presented to the browser, however I am still getting the weird question mark characters for pound signs :( </p> <p>Here is my RSS feed code (CFML):</p> <pre><code>&lt;cfsilent&gt; &lt;!--- Get News ---&gt; &lt;cfinvoke component="com.news" method="getAll" dsn="#Request.App.dsn#" returnvariable="news" /&gt; &lt;/cfsilent&gt; &lt;!--- If we have news items ---&gt; cfif news.RecordCount GT 0&gt; &lt;!--- Serve RSS content-type ---&gt; &lt;cfcontent type="application/rss+xml"&gt; &lt;!--- Output feed ---&gt; &lt;cfcontent reset="true"&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;cfoutput&gt; &lt;rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"&gt; &lt;channel&gt; &lt;title&gt;News RSS Feed&lt;/title&gt; &lt;link&gt;#Application.siteRoot#&lt;/link&gt; &lt;description&gt;Welcome to the News RSS Feed&lt;/description&gt; &lt;lastBuildDate&gt;Wed, 19 Nov 2008 09:05:00 GMT&lt;/lastBuildDate&gt; &lt;language&gt;en-uk&lt;/language&gt; &lt;atom:link href="#Application.siteRoot#news/rss/index.cfm" rel="self" type="application/rss+xml" /&gt; &lt;cfloop query="news"&gt; &lt;!--- Make data xml compliant ---&gt; &lt;cfscript&gt; news.headline = replace(news.headline, "&lt;", "&amp;lt;", "ALL"); news.body = replace(news.body, "&lt;", "&amp;lt;", "ALL"); news.date = dateformat(news.date, "ddd, dd mmm yyyy"); news.time = timeformat(news.time, "HH:mm:ss") &amp; " GMT"; &lt;/cfscript&gt; &lt;item&gt; &lt;title&gt;#news.headline#&lt;/title&gt; &lt;link&gt;#Application.siteRoot#news/index.cfm?id=#news.id#&lt;/link&gt; &lt;guid&gt;#Application.siteRoot#news/index.cfm?id=#news.id#&lt;/guid&gt; &lt;pubDate&gt;#news.date# #news.time#&lt;/pubDate&gt; &lt;description&gt;#news.body#&lt;/description&gt; &lt;/item&gt; &lt;/cfloop&gt; &lt;/channel&gt; &lt;/rss&gt; &lt;/cfoutput&gt; &lt;cfelse&gt; &lt;!--- If we have no news items, relocate to news page ---&gt; &lt;cflocation url="../news/index.cfm" addtoken="no"&gt; &lt;/cfif&gt; </code></pre> <p>Has anyone any suggestions? I've done loads of research but can't find any answers :(</p> <p>Thanks in advance,</p> <p>Chromis</p>
[ { "answer_id": 362649, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 0, "selected": false, "text": "&" }, { "answer_id": 363788, "author": "rip747", "author_id": 31278, "author_profile": "https://Stackov...
2008/12/12
[ "https://Stackoverflow.com/questions/362429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45427/" ]
362,434
<p>I dropped a database from SQL Server, however it turns out that <strong>my login</strong> was set to use the dropped database as its default. I can connect to SQL Server Management Studio by using the 'options' button in the connection dialog and selecting 'master' as the database to connect to. However, whenever I try to do anything in object explorer, it tries to connect using my default database and fails.</p> <p>Does anyone know how to set my default database <strong>without using object explorer</strong>?</p>
[ { "answer_id": 362435, "author": "Martin Brown", "author_id": 20553, "author_profile": "https://Stackoverflow.com/users/20553", "pm_score": 8, "selected": false, "text": "Exec sp_defaultdb @loginame='login', @defdb='master' \n" }, { "answer_id": 363496, "author": "Greg B", ...
2008/12/12
[ "https://Stackoverflow.com/questions/362434", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20553/" ]
362,441
<p>I am sure this is a very simple problem, but I am new to VB.NET, so I am having an issue with it.</p> <p>I have a <code>Decimal</code> variable, and I need to split it into two separate variables, one containing the integer part, and one containing the fractional part. </p> <p>For example, for x = 12.34 you would end up with a y = 12 and a z = 0.34.</p> <p>Is there a nice built-in functions to do this or do I have to try and work it out manually?</p>
[ { "answer_id": 362453, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "Sub SplitDecimal(ByVal number As Decimal, ByRef wholePart As Decimal, _\n ByRef fractionalPart As Decimal...
2008/12/12
[ "https://Stackoverflow.com/questions/362441", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30297/" ]
362,444
<p>I would like to write a macro for Notepad++ which should replace char1, char2, char3 with char4, char5, char6, respectively.</p>
[ { "answer_id": 362869, "author": "PhiLho", "author_id": 15459, "author_profile": "https://Stackoverflow.com/users/15459", "pm_score": 7, "selected": true, "text": "<Macro name=\"Trim Trailing and save\" Ctrl=\"no\" Alt=\"yes\" Shift=\"yes\" Key=\"83\">\n <Action type=\"1\" message=\"2...
2008/12/12
[ "https://Stackoverflow.com/questions/362444", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4235/" ]
362,445
<p>I'm assuming this is an easy question, but I'll be darned if I can find the answer.</p> <p>I have a website in Visual Studio 2008. The paths to the stylesheets (and images) are in the following format /css/stylesheetname.css</p> <p>At the root of the web project in Visual studio the folder exists as does the stylesheet. These paths work fine when running it in IIS.</p> <p>If I use the inbuilt webserver in Visual Studio the paths fail because it puts the projectname in the path i.e. <a href="http://localhost:2020/projectname/default.aspx" rel="noreferrer">http://localhost:2020/projectname/default.aspx</a></p> <p>In this case the / takes the path right back to <a href="http://localhost:2020" rel="noreferrer">http://localhost:2020</a></p> <p>This is further compounded by the fact that if you click "design" the styles that import background images all fail although the stylesheet is imported correctly (becuase all other aspects of the stylesheet work i.e. <code>.class{font-family:arial;}</code> works but <code>.class{background: url(/images/image.jpg)}</code> does not).</p> <p>I guess it's all to do with how Visual studio calculates its root path for the website, however I can't find a setting to change this.</p> <p>Any ideas?? <strong>Update:</strong> as per Egil Hansen's answer I converted the paths in the CSS file to relative paths. However the background images still do not display in Design mode. I'll take a look at using Themes to get round this in due course.</p>
[ { "answer_id": 362502, "author": "Egil Hansen", "author_id": 32809, "author_profile": "https://Stackoverflow.com/users/32809", "pm_score": 3, "selected": false, "text": "/App_Themes/YourTheme/Images/" } ]
2008/12/12
[ "https://Stackoverflow.com/questions/362445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1970/" ]
362,446
<p>Are there some practical programming situations for someone to declare a class abstract when all the methods in it are concrete?</p>
[ { "answer_id": 362469, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 0, "selected": false, "text": "abstract" }, { "answer_id": 363748, "author": "Markus", "author_id": 45064, "author_profile": "htt...
2008/12/12
[ "https://Stackoverflow.com/questions/362446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27784/" ]
362,461
<p>I am trying to build a working encrypted signature for the Amazon S3 web service, writing a connection library using Objective C. </p> <p>I have run into HMAC SHA-1 digest problems with the ObjC code, so I'm putting that to the side and looking at existing, working Perl code, to try to troubleshoot digest creation.</p> <p>I am testing HMAC SHA-1 digest output from the <code>s3ls</code> command of the <code>Net::Amazon::S3</code> package and comparing that against the <code>_encode</code> subroutine that I pulled out and put into its own perl script:</p> <pre><code>#!/usr/bin/perl -w use MIME::Base64 qw(encode_base64); use Digest::HMAC_SHA1; use String::Escape qw( printable unprintable ); sub _ascii_to_hex { (my $str = shift) =~ s/(.|\n)/sprintf("%02lx", ord $1)/eg; return $str; } sub _encode { my ( $aws_secret_access_key, $str ) = @_; print "secret key hex: "._ascii_to_hex($aws_secret_access_key)."\n"; my $hmac = Digest::HMAC_SHA1-&gt;new($aws_secret_access_key); $hmac-&gt;add($str); my $digest = $hmac-&gt;digest; print "cleartext hex: "._ascii_to_hex($str)."\n"; print "digest hex: "._ascii_to_hex($digest)."\n"; my $b64 = encode_base64( $digest, '' ); print "encoded: ".$b64."\n"; } my $secret = "abcd1234"; my $cleartext = "GET\n\n\nFri, 12 Dec 2008 10:08:51 GMT+00:00\n/"; _encode($secret, $cleartext); </code></pre> <p>Here is sample output from this script:</p> <pre><code>$ ./testhmac.pl secret key hex: 6162636431323334 cleartext hex: 4745540a0a0a4672692c2031322044656320323030382031303a30383a353120474d542b30303a30300a2f digest hex: 63308f9b8a198440d6d8685a3f3f70d0aab02f68 encoded: YzCPm4oZhEDW2GhaPz9w0KqwL2g= </code></pre> <p>What I am testing is that, if I input the same secret key and cleartext into the same <code>_encode</code> function of the <code>Net::Amazon::S3</code> package, I should see the very same secret key, cleartext, and digest bytes.</p> <p>Indeed, I get the same bytes for the secret key and cleartext.</p> <p>But I get something different for the digest (and of course the base64 encoding), e.g.:</p> <pre><code>$ s3ls --access-key=foobar --secret-key=abcd1234 ... secret key hex: 6162636431323334 cleartext hex: 4745540a0a0a4672692c2031322044656320323030382031303a30383a353120474d542b30303a30300a2f digest hex: c0da50050c451847de7ed055c5286de584527a22 encoded: wNpQBQxFGEfeftBVxSht5YRSeiI= </code></pre> <p>I have verified that the secret key and clear text are the same input to both scripts. The encoding subroutine is virtually identical in both scripts (except for an unused argument passed to the subroutine, which I remove from my custom version).</p> <p>What would cause the HMAC SHA-1 digest to be computed differently in both cases, if the input bytes and <code>_encode</code> subroutine are the same?</p> <p>(I have also verified the two scripts against the test cases at <a href="http://www.faqs.org/rfcs/rfc2202.html" rel="nofollow noreferrer">RFC 2201</a>.)</p>
[ { "answer_id": 362501, "author": "innaM", "author_id": 7498, "author_profile": "https://Stackoverflow.com/users/7498", "pm_score": 1, "selected": false, "text": "secret key hex: abcd...1234\n" }, { "answer_id": 362594, "author": "brofield", "author_id": 31423, "author...
2008/12/12
[ "https://Stackoverflow.com/questions/362461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19410/" ]
362,468
<p>I'm new to log4net, so hopefully this is a really easy question for someone?!</p> <p>I've got log4net working with the RollingLogFileAppender for my web application. I'm using logging to try and find where some performance issues are coming from. In order to do this, it'd be useful to include the ASP.NET SessionID in the log output so that I can make sure I'm looking at log entries for a specific user.</p> <p>Is there any way I can do this through the <code>conversionPattern</code> setting for the appender? Is there a <code>%property{??}</code> setting I can use?</p> <p><strong>UPDATE: This question still hasn't been answered - does anybody have any ideas?</strong></p>
[ { "answer_id": 362526, "author": "Richard Ev", "author_id": 39709, "author_profile": "https://Stackoverflow.com/users/39709", "pm_score": 1, "selected": false, "text": "<conversionPattern\n value=\"%date %-5level %logger ${COMPUTERNAME} [%property{SessionID}] - %message%newline\" />\n...
2008/12/12
[ "https://Stackoverflow.com/questions/362468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/475/" ]
362,483
<p>Is is possible to put a constant where clause to a Linq to SQl mapping.</p> <p>I really don't want to do this at the query level or in my Data Access Object as these are currently completely generic and would like to keep it that way to make life for the other developers and save me repeating myself constantly.</p> <p>Colin G</p>
[ { "answer_id": 362534, "author": "Paul Nearney", "author_id": 24071, "author_profile": "https://Stackoverflow.com/users/24071", "pm_score": 3, "selected": true, "text": "public static IQueryable<Horse> GetHorses(this DataContext db)\n{\n return from h in db.Horses\n where !h...
2008/12/12
[ "https://Stackoverflow.com/questions/362483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1213936/" ]