instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have a helper class that is just a bunch of static methods and would like to subclass the helper class. Some behavior is unique depending on the subclass so I would like to call a virtual method from the base class, but since all the methods are static I can't create a plain virtual method (need object reference ...
<p>Virtual static methods don't make sense. If I call <code>HelperClass.HelperMethod();</code>, why would I expect some random subclass' method to be called? The solution really breaks down when you have 2 subclasses of <code>HelperClass</code> - which one would you use?</p> <p>If you want to have overrideable stati...
<p>You will be able to soon, in C# 11!</p> <p>From <a href="https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/static-virtual-interface-members" rel="nofollow noreferrer">Tutorial: Explore C# 11 feature - static virtual members in interfaces</a>:</p> <blockquote> <p>C# 11 and .NET 7 include <em>static ...
30,847
<p><em>Before I start, I know using iisreset is considered bad practice, but this shouldn't happen anyway..</em></p> <p><strong>What we have:</strong></p> <ul> <li><p>Several machines with IIS6 on Windows Server 2003 R2 (both 64 and 32 bits)</p></li> <li><p>Several WCF webservices (.NET runtime 2.0) deployed in sever...
<p>The application pools should restart on an iisreset, but they do run outside of iis (in COM+) for reliability. This mean they may may not come back if the application is misbehaving, but IIS and the other apps will(should) come back. So yes, This is "normal". </p> <p>P.S. I would also like to "OUT" myself as a <st...
<p>Re-setting the identity (auth credentials) via advanced settings of the Application pool worked for me.</p> <p>Earlier I changed my active directory password and as the app pool was already running, it worked fine until I performed IISRESET.</p>
30,610
<p>Does anyone know where a log of who connected to my subversion server and what they did with it is? </p> <p>I'm looking to find out what time and which files were checked out.</p> <p>I'm assuming that it has something like a webserver log somewhere and I just can't find it.</p> <p>EDIT: From the response below,...
<p>You don't say what your SVN server actually is. If it's svnserve, then it doesn't keep logs by default, and I wasn't aware that it could be configured to do so, though I might be out of date on this.</p> <p>If you're using Apache/mod_svn, then you need to look into Apache logging. </p>
<p>This program doesn't do exactly what you've asked for but I think it will give you the insight you're actually looking for: CommitMonitor watches Subversion repositories for new commits and shows a notification to the user when that happens. Essentially it sits in your tray notification area and pops up an alert (l...
46,918
<p>I have many jobs that have a step to send 1 specific email out to a list of people. That list of reciepients is hardcoded in the step command and I need to remove one person from that list, in all jobs.</p> <p>How do I loop through ALL the jobs in the Sql Server Agent and modify the command text to find+replace a ...
<p>You could try to update the System tables that hold the information on jobs of the SQL server directly. The relevant ones for you would be:</p> <pre><code>msdb.dbo.SysJobs msdb.dbo.SysJobSteps </code></pre> <p>If you have a specific email address to remove, you could update the <strong>Command</strong> field in th...
<p>If anybody still looking for this then below should do. Not the finest code but gets the job done.</p> <pre><code>/* Replace the below statement with the actual keyword to be replaced: INSERT INTO SP_Keyword VALUES ('sys.databases3', 'sys.databases5') ,('sysjobs3', 'sysjobs5') Here we are replacing sys.databases3 ...
38,211
<p>I need the current user and the domain. I am using a VB 6 application. </p> <p>Thanks</p>
<p>One way would be to ask the environment:</p> <pre><code>Dim UserName As String Dim UserDomain As String UserName = Environ("USERNAME") UserDomain = Environ("USERDOMAIN") </code></pre> <p>(Works on Windows NT and up only, obviously.)</p>
<p>What about this?</p> <pre><code>Private Function IsAdmin() As Boolean Dim groups As Object Dim user As Object Set groups = GetObject("WinNT://./administrators") For Each user In groups.members If UCase(Environ("USERNAME")) = UCase(user.Name) Then IsAdmin = True End If Next user End Function </code></pre>
43,756
<p>Joomla has a built-in function on its login screen "I've forgotten my user name", so that you can type in your email address and the username is sent to you via email.</p> <p>I was thinking of changing it so that the username was displayed on screen immediately, without any form of authentication. This would greatl...
<p>I would say it is a <em>slight</em> security risk for your less savvy users. For a user with a weak password, particularly if it is related to their username or e-mail address, exposing their user name leaves them open to having their account hijacked. Other than that, I can't think of a reason it would be a probl...
<p>At first glance, it seems like a "bad idea" because you are allowing anyone to: </p> <ol> <li>verify an account exists</li> <li>confirm the association between a username and an email address</li> </ol> <p>If usernames and mail addresses are treated as "private" information on your site and not already shared, the...
38,587
<p>Got a class that serializes into xml with XMLEncoder nicely with all the variables there. Except for the one that holds <em>java.util.Locale</em>. What could be the trick?</p>
<p>The problem is that java.util.Locale is not a <a href="http://java.sun.com/javase/technologies/desktop/javabeans/docs/spec.html" rel="noreferrer">bean</a>. From the <a href="http://java.sun.com/javase/6/docs/api/index.html?java/beans/XMLEncoder.html" rel="noreferrer">XMLEncoder</a> doc:</p> <blockquote> <p>The XM...
<p>Sorry, don't you mean <em>java.util.Locale</em>? The javadocs say that <em>java.util.Locale</em> implements <em>Serializable</em>, so you should have no problem using the <em>Locale</em> class from the <em>lang</em> package.</p>
23,762
<p>I don't even know where to go with this. Google wasn't very helpful. As with my previous question. I'm using TextMate's Command+R to compile the project.</p> <blockquote> <p>game.h:16:error: declaration of ‘Player* HalfSet::Player() const’</p> <p>players.h:11:error: changes meaning of ‘Player’ from ‘class Player’</p...
<p>In C++ you cannot name a function the same name as a class/struct/typedef. You have a class named "Player" and so the HalfSet class has a function named "Player" ("Player *Player()"). You need to rename one of these (probably changing HalfSet's Player() to getPlayer() or somesuch).</p>
<p>I had this error on my code I can't comprehend this</p> <blockquote> <p>A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule.</p> </blockquote> <p>But this what I did so it fixed my erro...
35,825
<p>I'm using <a href="http://en.wikipedia.org/wiki/Windows_Script_Host#Usage" rel="noreferrer">WScript</a> to automate some tasks, by using WScript.Shell to call external programs.</p> <p>However, right now it does not wait for the external program to finish, and instead moves on. This causes issues because I have som...
<p>Turns out, that while loop is severe CPU hog :P</p> <p>I found a better way:</p> <pre><code>ZipCommand = "7za.exe a -r -y " &amp; ZipDest &amp; BuildLabel &amp; ".zip " &amp; buildSourceDir Set wshShell = WScript.CreateObject("Wscript.Shell") wshShell.Run ZipCommand,1,1 </code></pre> <p>The last two arguments a...
<p>If you use the "Exec" method, it returns a reference, so you can poll the "Status" property to determine when it is complete. Here is a sample from <a href="http://msdn.microsoft.com/en-us/library/ateytk4a(VS.85).aspx" rel="noreferrer">msdn</a>:</p> <pre><code>Dim WshShell, oExec Set WshShell = CreateObject("WScri...
7,315
<p>I have a table where I'm recording if a user has viewed an object at least once, hence:</p> <pre><code> HasViewed ObjectID number (FK to Object table) UserId number (FK to Users table) </code></pre> <p>Both fields are NOT NULL and together form the Primary Key.</p> <p>My question is, since I don't c...
<p>I would normally just insert and trap the DUP_VAL_ON_INDEX exception, as this is the simplest to code. This is more efficient than checking for existence before inserting. I don't consider doing this a "bad smell" (horrible phrase!) because the exception we handle is raised by Oracle - it's not like raising your o...
<p>Usually, exception handling is slower; however if it would happen only seldom, then you would avoid the overhead of the query.<br> I think it mainly depends on the frequency of the exception, but if performance is important, I would suggest some benchmarking with both approaches.</p> <p>Generally speaking, treating...
45,672
<p>I'm doing some tests with nhibernate and I'm modifying batch_size to get bulk inserts.</p> <p>I'm using mssql2005 and using the northwind db. I created 1000 object and insert them to the database. I've changed the values of batch_size from 5 to 100 but found no change in the performance. I'm getting value of around...
<p>The following is a great post on batch processing in Hibernate, which is what NHibernate is based upon and closely follows:</p> <p><a href="http://relation.to/Bloggers/BatchProcessingInHibernate" rel="nofollow noreferrer">http://relation.to/Bloggers/BatchProcessingInHibernate</a></p> <p>As you can see, the suggest...
<p>A call to ITransaction.Commit will Flush your Session, effectively writing your changes to the database. You are calling Commit after every Save, so there will be an INSERT for each Supplier.</p> <p>I'd try to call Commit after every 10 Suppliers or so, or maybe even at the end of your 1000 Suppliers!</p>
36,451
<p>Ok, what I'm trying to do is build a web app that allows students to visually organize their class calendar using drag and drop. but They have to be able to drag and drop to specific locations (when those classes are available), not just anywhere.</p> <p>This would be a 'fixed week' calendar. I was considering usin...
<p>How about using <a href="http://dojotoolkit.org/" rel="nofollow noreferrer">Dojo toolkit</a> to implement the heavy lifting? They have a <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/drag-and-drop" rel="nofollow noreferrer">class</a> for it.</p> <p>From this <a href="http://d...
<p>jQuery has draggable <a href="http://docs.jquery.com/UI/Droppable/droppable#options" rel="nofollow noreferrer">droppable</a> classes to do what you need, haven't used them tho. </p> <p>However i've built a javascript system to categorize mobile phone content using drag and drop quite successfully using <a href="htt...
45,371
<p>I need to check all of my asp code to prevent SQL injection.</p> <p>Should I check the session object, too?</p> <p>How might a session be hijacked?</p> <p>Thank you!!</p>
<p>Session can be hijacked. If I remember correctly, Classic ASP only support cookie-based session identifier. If someone were able to steal that cookie (wire-tap) then they can gain the same session as legitimate user.</p> <p>Should you check Session Object too? that depends. If you can make sure that all the object ...
<p>Well, you only really need to secure user inputs. So the question you have to ask yourself is: "Did this data came from user input?" If so you must use sql parameters.</p> <p>On a bigger scale, and considering that you have individual methods &amp; classes to perform the data access, you should you sql parameters f...
45,856
<p>How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column?</p>
<p>Yes, as MySQL doesn't support function-based indexes (like <code>ADD INDEX myIndex(LENGTH(text)))</code>, you'll need a new int column and define a <a href="http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html" rel="nofollow noreferrer">trigger</a> to auto-update it after inserts and updates.</p>
<p>Sounds like a good approach to me (sorry don't know mysql, but in oracle you could set a trigger so that when your main column is updated the "length" column gets automatically updated)</p>
10,997
<p>What JavaScript keywords (function names, variables, etc) are reserved?</p>
<p>Here is my poem, which includes all of the reserved keywords in JavaScript, and is dedicated to those who remain honest in the moment, and not just try to score:</p> <pre class="lang-none prettyprint-override"><code>Let this long package float, Goto private class if short. While protected with debugger case, Con...
<p>benc's answer is excellent, but for my two cents, I like the w3schools' page on this:</p> <p><a href="http://www.w3schools.com/js/js_reserved.asp" rel="nofollow">http://www.w3schools.com/js/js_reserved.asp</a></p> <p>In addition to listing the keywords reserved by the standard, it also has a long list of keywords ...
4,585
<p>We have a 3D application that retrieves keyboard presses via the IDirectInputDevice8. Is there any way, when we retrive keyboard events via the win32 API winproc loop back that we can send these commands to the DirectInputDevice?</p>
<p>Windows polls the keyboard hardware behind the scenes. When key events happen, it adds the respective WM_* messages to your Windows message queue (with associated information on keyboard state). The <a href="http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows" rel="nofollow noreferrer">windows message pum...
<p>The wndproc will is sent a combination of these messages on keyboard events:</p> <pre><code>WM_SYSKEYDOWN WM_SYSKEYUP WM_KEYDOWN WM_KEYUP WM_CHAR </code></pre>
29,536
<p>I have a table in lua with some data.</p> <pre><code>sometable = { {name = "bob", something = "foo"}, {name = "greg", something = "bar"} } </code></pre> <p>I then want to loop through the table and assign a number to each name as a variable. New to lua and tried it like this.</p> <pre><code>for i,t in ip...
<pre class="lang-lua prettyprint-override"><code>&gt; sometable = {{name = &quot;bob&quot;, something = &quot;foo&quot;},{name = &quot;greg&quot;, something = &quot;bar&quot;}} &gt; for i,t in ipairs(sometable) do t[t.name] = i end &gt; for i,t in ipairs(sometable) do for j,u in pairs (t) do print (j,u) end end n...
<p>The <a href="http://www.lua.org/manual/5.1/manual.html#5.1" rel="nofollow noreferrer">ipairs</a> function will iterate only through numerically indexed tables in ascending order.</p> <p>What you want to use is the pairs function. It will iterate over every key in the table, no matter what type it is.</p>
34,132
<p>I have an application that tracks high scores in a game. </p> <p>I have a <strong>user_scores</strong> table that maps a user_id to a score.</p> <p>I need to return the 5 highest scores, but only 1 high score for any <em>specific</em> user.</p> <p>So if user X has the 5 highest scores on a purely numerical basis,...
<p>This should work:</p> <pre><code>SELECT user_id, MAX(score) FROM user_scores GROUP BY user_id ORDER BY MAX(score) DESC LIMIT 5 </code></pre>
<p>You can't group by without a summary-function (SUM, COUNT, etc.)</p> <p>The GROUP BY clause says how to group the SUMs or COUNTs.</p> <p>If you simply want to break the long list into bunches with a common value, that's not SQL. That's what your application has to do.</p>
14,416
<p>I'm interested in grabbing the EPG data from DVB-T streams. Does anyone know of any C libraries or an alternative means of getting the data?</p>
<p>tv_grab_dvb can do this. See the <a href="http://www.darkskiez.co.uk/svn/tv_grab_dvb/trunk/" rel="nofollow noreferrer">subversion repository</a> for sources.</p> <p>tv_grab_dvb is made to work with the stream grabbed from the DVB-T card using <a href="http://sourceforge.net/projects/dvbtools/" rel="nofollow norefer...
<p>...a new answer to an old question:</p> <p>I wrote a utility called <code>dvbtee</code> that can be used as a c++ library, a cross-platform command line utility, or a node.js module.</p> <p>(despite it being a c++ library, one could still link to it from c code)</p> <p>The command line utility will parse your str...
8,146
<p>When calling php via cli, the current directory is NOT changed to the one of the script. All the scripts i have running in crontab run via the CLI, so this is an issue.</p> <p>I'm currently <em>fixing</em> the problem by doing a chdir() with the absolute path where the script is, but i REALLY dont like hardcoding p...
<pre><code>chdir(dirname(__FILE__)); </code></pre>
<p>You can use <code>__FILE__</code> to get the full absolute path to the executing file itself:</p> <pre><code>&lt;?php echo "I'm here: ".__FILE__."\n"; ?&gt; </code></pre> <p>See <a href="http://fi.php.net/language.constants.predefined" rel="nofollow noreferrer">the documentation</a> for more info.</p>
23,343
<p>I'm interested in finding out what people would consider the most useful data structures to know in programming. What data structure do you find yourself using all the time? </p> <p>Answers to this post should help new programmers interested in finding a useful data structure for their problem. Answers should proba...
<p>One of the data structures I use the most (beyond vectors, of course) is the Hashtable. Its about the only choise if you need to be able to search large quantities of data in O(1) time, that means the time to search does not grow as the size of the collection grows.</p> <p>The catch is that the insertion and deleti...
<p>This post is way too vague. There are countless data structures: arrays, dictionaries, etc. Each data structure can be used to solve different problems.</p> <p>It would be much more productive to ask for DS for a specific problem.</p>
17,581
<p>Is there anything out there that for .NET that can generate UML diagrams from code. Preferably an addin for Visual Studio. Starting work on a mature project that has little architectural documentation can be painful at first. Eventually you get the ins and outs of the code but helping to see how the code all fits to...
<p>Visual Studio 2010 Ultimate supports UML class, sequence, component, use case, and activity diagrams. It also supports creating sequence, dependency graphs, and layer diagrams from code. Regarding your question about generating UML diagrams from code, there's a response here in the VS Architecture &amp; Modeling too...
<p>Class diagram doesn't always work. I often find it wont display the classes for some reason. Pen &amp; pencil or talking with people who work on the project is what I have to rely on.</p>
11,752
<p>I have looked over the Repository pattern and I recognized some ideas that I was using in the past which made me feel well.</p> <p>However now I would like to write an application that would use this pattern <strong>BUT I WOULD LIKE TO HAVE THE ENTITY CLASSES DECOUPLED</strong> from the repository provider.</p> <p...
<p>I don't know if this is exactly what you want, but you may want to take a look at Rob Conery's MVC Storefront code. He uses a variant of the repository pattern with a linq provider. He maps the LINQ to Sql objects to domain objects and then returns the domain objects from the repository provider to a service layer w...
<p>Not exactly the same scenario, but I'm working to create a custom tool that based on a XML file will generate an OO model. My approach is to use LINQ to SQL behind the scene and since I'm generating the code automatically it would be easy to use another mechanism for let's say MySQL data source. Since it's not suppo...
28,425
<p>In Team Foundation Server is there a way to have work items in one project linked to other projects so they show up in the reports in both. We are thinking about keeping release engineering items in their own project and want them linked to the project they are actaully for as well. Is this possible? So for instance...
<p>This is possible in TFS 2010 at least: <a href="https://stackoverflow.com/questions/4410083/link-tfs-work-item-to-different-project">link tfs work item to different project</a></p> <p>Not sure on the effects on reporting though.</p>
<p>Not out of the box as projects are discrete. However there is nothing to stop you from writing against the API to fulfill this need, although this would take some considerable work. </p> <p>Now for the good news. If you keep your eyes <a href="http://blogs.msdn.com/bharry/" rel="nofollow noreferrer">here</a>, yo...
29,867
<p>I've found how to sort query results by a given field in a Lucene.Net index instead of by score; all it takes is a field that is indexed but not tokenized. However, what I haven't been able to figure out is how to sort that field while ignoring stop words such as "a" and "the", so that the following book titles, for...
<p>I wrap the results returned by Lucene into my own collection of custom objects. Then I can populate it with extra info/context information (and use things like the highlighter class to pull out a snippet of the matches), plus add paging. If you took a similar route you could create a "result" class/object, add somet...
<p>When you create your index, create a field that only contains the words you wish to sort on, then when retrieving, sort on that field but display the full title.</p>
9,173
<p>Here's my first question at SO.</p> <p>I have a internal application for my company which I've been recently ask to maintain. The applications is built in PHP and its fairly well coded (OO, DB Abstraction, Smarty) nothing WTF-ish. </p> <p>The problem is the applications is <strong>very slow</strong>.</p> <p>How d...
<p>I've used <a href="http://www.xdebug.org/docs/profiler" rel="noreferrer">XDebug profiling</a> recently in a similiar situation. It outputs a full profile report that can be read with many common profiling apps ( Can't give you a list though, I just used the one that came with slackware ). </p>
<p>We use Zend Development Environment (windows). We resolved a memory usage spike yesterday by stepping through the debugger while running Process Explorer to watch the memory/cpu/disk activity as each line was executed. </p> <p>Process Explorer: <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx"...
7,955
<p>To save network traffic I'd like to compress my data. The only trick is that I the client is a c application and the server is php. I'm looking for an open source compression library that's available for both c and php.</p> <p>I guess I could write an external c application to decompress my data, but I'm trying to ...
<p><A HREF="http://www.zlib.net/" rel="nofollow noreferrer">Zlib</A> provides C APIs, and is part of the PHP functional API as well.</p>
<p><a href="http://www.zlib.net/" rel="nofollow noreferrer">ZLIB</a></p> <p><a href="http://www.php.net/zlib" rel="nofollow noreferrer">Here's the page</a> on accessing zlib from PHP.</p>
15,155
<p>I know how to do a regular php mysql search and display the results. However, because of the nature of what I'm trying to accomplish I need to be able to sort by relevancy. Let me explain this better:</p> <p>Normal Query "apple iphone applications" will search the database using %apple iphone application%, but if t...
<p>take a look at the <a href="http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html" rel="noreferrer">MySQL FULLTEXT search functions</a>, These should automatically return results by relevancy, and give you much more control over your searches</p> <p>The only potential issue with using fulltext indexes is tha...
<p>I Don't What exactly you want but the following code definitely work for you.</p> <pre><code>SELECT ("some text here" or `column_name`) RLIKE "Apple|Iphone|Application" AS Result ORDER BY Result DESC; </code></pre> <p>Separate all words with Bar(|) but results will be 1 or 0 founded or not resp. If you want to get...
44,768
<p>I have an existing standalone application which is going to be extended by a 3rd-party, using a network protocol. The capabilities are already implemented, all I need is to expose them to the outside.</p> <p>Assuming the transport protocol is already chosen (UDP), are there any resources that will help me to design...
<p>See <a href="http://xmpp.org/extensions/xep-0134.html#guidelines" rel="nofollow noreferrer">Jabber protocols design guidelines</a> and <a href="https://www.rfc-editor.org/rfc/rfc4101" rel="nofollow noreferrer">RFC 4101</a>. Although it is aimed at making RFCs more easy to understand to reviewers, this RFC provides s...
<p>If you do not want to build your protocol from ground up, you should take a look at <a href="http://en.wikipedia.org/wiki/SOAP_(protocol)" rel="nofollow noreferrer">SOAP</a>. Support varies for different programming languages, but cross language communication is explicitly encouraged.</p> <p>Unfortunately UDP and S...
35,003
<p>Do I need to register new extension types with Apple before I release an application that would create them on OS X?</p>
<p>No, there's no need to register extensions.</p>
<p>As a follow up, there is a little more information in the FAQs at the Apple Developer Connection (ADC) website:</p> <p><a href="http://developer.apple.com/faq/datatype.html" rel="nofollow noreferrer">http://developer.apple.com/faq/datatype.html</a></p>
6,197
<p>What is iPhone's browser tag and how iPhone optimized web site is different from a usual mobile web site?</p> <p>Thanks!</p>
<p>Nettuts has a great introduction to web-developement for iPhone. You find it <a href="http://nettuts.com/misc/learn-how-to-develop-for-the-iphone/" rel="nofollow noreferrer">here</a></p> <p>This is the specific code you asked for (taken from that article):</p> <pre><code>&lt;!--#if expr="(${HTTP_USER_AGENT} = /iPh...
<p>Better Solution:</p> <pre><code>* (NSString *)flattenHTML:(NSString *)html { NSScanner *theScanner; NSString *text = nil; theScanner = [NSScanner scannerWithString:html]; while ([theScanner isAtEnd] == NO) { // find start of tag [theScanner scanUpToString:@"&lt;" intoString:NULL] ; // find end...
7,579
<p>I'm looking at maybe moving from an older AMD64 to a new Intel dual-core which is 32 bit. Installation isn't a problem but can I transfer all the installed apps? I haven't been able to find anything so far on Google except where the migration is to a similar platform and file-system. I won't change the filesystem bu...
<p>You can save your list of packages easily: see "man dpkg" and search for --set-selections and --get-selections.</p> <p>The basic of it, though is that to save the list of packages:</p> <p><code>dpkg --get-selections > package_list</code></p> <p>To restore that list on another system:</p> <p><code>cat package_lis...
<p>The best way I can think of to go about this is to back up the list of installed packages on your current system and then use that list to set what packages to install on the new system. General instructions on how to backup and restore your package selections:</p> <h3>Install tools</h3> <pre><code>sudo apt-get inst...
22,735
<p>I'm working on a school project and I'm getting some weird errors from Xcode. I'm using TextMate's Command+R function to compile the project. Compilation seems to work okay but linking fails with an error message I don't understand. </p> <p>ld output:</p> <blockquote> <p>ld: duplicate symbol text_field(std::basi...
<p>My first thought was that you're including it twice on the linker command but it appears to be complaining about having the same function in <code>main.o</code> and <code>generics.o</code>.</p> <p>So it looks like you're including the <code>io_functions.cpp</code> file into the <code>main.cpp</code> and <code>gener...
<p>Use "inline" keyword decorate duplicate method </p> <pre><code>inline string text_field(istream &amp;in) </code></pre> <p>Inline functions are actual functions whose copy of the function body are injected directly into each place the function is called.</p> <p>For details, please see the <a href="https://chunminc...
35,812
<p>Once I've created a variable in the immediate window in C# (VS2008), is there any way to delete it so I can create a new variable with the same name but a different type? Apart from restarting the program that is.</p> <p>The reason would be to keep the immediate window's namespace clean, since it's difficult to kee...
<p>I don't think it is possible to do what you are asking.</p>
<p>You can do something similar to the following:</p> <pre><code>public void LolFunction() { { int main = 0; Console.Writeline(main); } { string main = "Roflstring"; Console.Writeline(main); } } </code></pre>
14,633
<p>Is there a way to add an attribute to an xml node (which I have the xpath of) using nant? Tried xmlpoke but it looks like it can only update existing attributes.</p> <p>thanks.</p>
<p>XmlPoke will definitely not work because the xpath must match something in the first place to be able to replace it.</p> <p>The only way I know of doing this is to create your own task that would allow you to add data to an xml file. These new tasks can either be build separately and added to NAnt by copying dlls ...
<p>XmlPoke will definitely not work because the xpath must match something in the first place to be able to replace it.</p> <p>The only way I know of doing this is to create your own task that would allow you to add data to an xml file. These new tasks can either be build separately and added to NAnt by copying dlls ...
46,814
<p>In an interview for a SQL DBA position a while back, I mentioned I prefer the SQL 2005 Management Studio app vs. the old 2000 versions of Enterprise Manager / Query Analyzer. The DBA who was interviewing me said that they had experienced some sort of database corruption in their 2000 databases when making changes fr...
<p>It sounds like he was just was using that as an excuse for lack of experience with SQL 2005 Management Studio. DBAs hate change.</p>
<p>I have never encountered this, in almost three years of using SQL Management Studio 2005 to manage SQL 2000 databases. There are a few tasks I still bounce back into EntMan for, but I've never had a database encounter even the minutest bit of corruption. (And background: As a consultant, I'm managing about 45 differ...
32,444
<p>I used a new Date() object to fill a field in a MySQL DB, but the actual value stored in that field is in my local timezone.</p> <p>How can I configure MySQL to store it in the UTC/GMT timezone?</p> <p>I think, configuring the connection string will help but I don't know how. There are many properties in the conne...
<p>The short answer is:</p> <ul> <li>add "default-time-zone=utc" to my.cnf</li> <li>in your code, always "think" in UTC, except when displaying dates for your users</li> <li><p>when getting/setting dates or timestamps with JDBC, always use the Calendar parameter, set to UTC:</p> <p>resultset.getTimestamp("my_date", C...
<p>Well, if we're talking about using <code>PreparedStatement</code>s, there's a <a href="http://java.sun.com/javase/6/docs/api/java/sql/PreparedStatement.html#setDate(int,%20java.sql.Date,%20java.util.Calendar)" rel="nofollow noreferrer">form of setDate</a> where you can pass in a Calendar set to a particular time zon...
39,839
<p>As a follow-up to <a href="https://stackoverflow.com/questions/199518/how-to-programatically-add-mapped-network-passwords-winxp">this</a> question I am hoping someone can help with the <a href="http://msdn.microsoft.com/en-us/library/aa374794(VS.85).aspx" rel="nofollow noreferrer">CredEnumerate</a> API. </p> <p>As...
<p>You need to dereference the pointer to the array to get the array, then for each item in the array you will need to dereference the item to get the <code>PCREDENTIALS</code> instance.</p> <p>I found <a href="http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic33651.aspx" rel="nofollow no...
<p>You also need to calculate 'IntPtr p' correctly the code above is missing that and it will only fetch the 1st structure.</p> <p>Th following code will get all structures in 'IntPtr pCredentials'</p> <pre><code>int count; IntPtr pCredentials; if (CredEnumerate(filter, 0, out count, out pCredentials) != 0) { m_...
31,813
<p>I have a <strong>MS Access</strong> form with a <strong>Datasheet</strong> subform.<br> Using code, I change the <strong>ColumnHidden</strong> property of various of its columns. But, when I close the form, I'm asked whether to save the table layout of the Datasheet's table.</p> <ul> <li>How can I stop the form fro...
<p>If you are always hiding the same columns - create a query that only has the columns you want displayed and use that as the source of your subform.</p> <p>If you still need some hidden fields (child keys, etc.) you will have to create a regular form. It's not too bad:</p> <ul> <li>just base it on your table, </li>...
<p>I'm not sure there's an easy way to do this because Access saves a lot of properties with forms. If you were not using Datasheet view, you could hide the CLOSE button on the form and replace it with a command button to close the form with this code:</p> <pre><code> DoCmd.Close acForm, Me.Name, acSaveNo </code></pr...
33,394
<p>I have a database field that contains a raw date field (stored as character data), such as </p> <blockquote> <p>Friday, September 26, 2008 8:30 PM Eastern Daylight Time</p> </blockquote> <p>I can parse this as a Date easily, with SimpleDateFormat</p> <pre><code>DateFormat dbFormatter = new SimpleDateFormat("EEE...
<p>I found that the following:</p> <pre><code> DateFormat dbFormatter = new SimpleDateFormat("EEEE, MMMM dd, yyyy hh:mm aa zzzz"); dbFormatter.setTimeZone(TimeZone.getTimeZone("America/Chicago")); Date scheduledDate = dbFormatter.parse("Friday, September 26, 2008 8:30 PM Eastern Daylight Time");...
<p>Well as a partial solution you could use a RegEx match to get the timezone since you will always have the same text before it. AM or PM.</p> <p>I don't know enough about Java timezones to get you the last part of it.</p>
11,123
<pre><code>std::vector&lt;int&gt; ints; // ... fill ints with random values for(std::vector&lt;int&gt;::iterator it = ints.begin(); it != ints.end(); ) { if(*it &lt; 10) { *it = ints.back(); ints.pop_back(); continue; } it++; } </code></pre> <p>This code is not working because...
<p>The call to <a href="http://en.cppreference.com/w/cpp/container/vector/pop_back" rel="noreferrer"><code>pop_back()</code></a> removes the last element in the vector and so the iterator to that element is invalidated. The <code>pop_back()</code> call does <em>not</em> invalidate iterators to items before the last el...
<p>Check out the information <a href="http://www.cplusplus.com/reference/stl/vector/pop_back.html" rel="nofollow noreferrer">here (cplusplus.com)</a>:</p> <blockquote> <p><strong>Delete last element</strong></p> <p>Removes the last element in the vector, effectively reducing the vector size by one and invalidat...
8,773
<p>I've been using NUnit for a few years. I've tried MBUnit for a short while as well as Zenebug and XUnit but I keep coming back to NUnit.</p> <p>What is your favorite/most used Unit test Framework? Can you explain why you're using it?</p>
<p>Nunit for the win!! It is simple and easy to implement. No mess, no fuss.</p>
<p>I used to use NUnit, but now I prefer the framework that comes with Visual Studio 2008, simply because it has tighter integration and is easier to set up to test private methods.</p> <p>We also had problems with keeping the versions of NUnit synchronized with the rest of the team. It was a minor annoyance (go and u...
15,540
<p>I am planning to move my vmWare's Virtual Machines from a Windows host to a Linux host (Ubuntu). It is possible to run vmWare Server in a Linux host that does not have the graphical environment (does not have X)?</p> <p>I just wonder how the graphical setup of Windows/Linux guest work in this case.</p> <p>Thanks i...
<p>Just install it on Ubuntu Server and install it via apt-get. Here's a good walkthrough</p> <p><a href="http://users.piuha.net/martti/comp/ubuntu/en/server.html" rel="nofollow noreferrer">http://users.piuha.net/martti/comp/ubuntu/en/server.html</a></p> <p>I did this on my development server and connect to it using...
<p>the X libraries are required during the compilation and installation of VMware Server on Linux.</p>
24,327
<p>It's been ratling in my brain for a while.</p> <p>I've had some investigation on Compilers/Flex/Byson and stuff but I never found a good reference that talked in detail about the "parsing stack", or how to go about implementing one.</p> <p>Does anyone know of good references where I could catch up?</p> <p><strong...
<p>The <a href="https://rads.stackoverflow.com/amzn/click/com/0321486811" rel="noreferrer" rel="nofollow noreferrer">Dragon book</a>! I used it quite recently to write a compiler (in PHP!) for a processing language for template files written in RTF...</p>
<p>try <a href="http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Dstripbooks&amp;field-keywords=compiler+construction&amp;x=20&amp;y=16" rel="nofollow noreferrer">amazon</a></p> <p><em>Compiler Construction</em> is just one good example</p>
18,198
<p>We're writing an asp.net web app on IIS 6 and are planning on storing our user login variables in a session. Will this be removed when the worker process recycles?</p>
<p>If session is stored in-proc then YES worker process recycle will remove it. Use Out-of-proc model or sql server to store session value if you want to keep it stored.</p>
<p>yes, unless you are using out of process session state.</p>
10,981
<p>We've been asked by a client to give us a time estimate on each and every bug we have.</p> <p>Though we do have a set schedule for bug fixing and have allocated time for it, we don't have a time allocation on each of the bugs we have. Simply, we have prioritized our bugs and have ensured that Highest priority bugs ...
<p>The only answer I can give is to be extremely conservative. Guess how long it will take, and multiple your guess by four. Use that as your estimate. As you said, it's very difficult to figure out how long things will take to fix, and it's better to say it will take longer than it actually does than to be caught "...
<p>It should be the same as estimating any other task you have. Split it up into the smallest tasks possible and estimate those as accurately as you can with padding for the unexpected. Then give them a range so you're not pinned down to a specific date on tasks that are not well-defined. There is no difference between...
16,325
<p>I went to school for programming years ago and when I got out I found a job in system administration and that is the direction my career took. I'd like to get back into development of some sort and have been 'playing' with C# and ASP.NET, but I've been hearing lots of buzz for other 'new' languages (by new I mean th...
<p>You should learn at least 1 compiled language (like C# or Java) and 1 Script Language (Python, Ruby, etc). This is usually enough to help most developers succeed at what they do, regardless of the age of the language.</p> <p>As for new vs old, I'd stick with C# for now as it's pretty popular. Learning a new languag...
<p>This is a bit of a loaded question, but you'll find that folks here are passionate about their tool choice while believing in flexibility that a choice provides.</p> <p>That said, if you don't mind "vendor lockin," the Microsoft stack is an excellent way to get into programming and find gainful employment for years...
18,497
<p>If I have a large number of SQLite databases, all with the same schema, what is the best way to merge them together in order to perform a query on all databases? </p> <p>I know it is possible to use <a href="http://www.sqlite.org/lang_attach.html" rel="noreferrer">ATTACH</a> to do this but it has <a href="http://ww...
<p>To summarize from the <a href="https://web.archive.org/web/20120615034014/http://sqlite.1065341.n5.nabble.com/Attempting-to-merge-large-databases-td39548.html" rel="noreferrer">Nabble post</a> in DavidM's answer:</p> <pre><code>attach 'c:\test\b.db3' as toMerge; BEGIN; insert into AuditRecords select * f...
<p>With no offense, just as one developer to another, I'm afraid that your idea seems terribly inefficient. It seems to me that instead of uniting SQLite databases you should probably be storing several tables within the same Database file.</p> <p>However if I'm mistaken I guess you could ATTACH the databases and then...
10,635
<p>The following are two methods of building a link that has the sole purpose of running JavaScript code. Which is better, in terms of functionality, page load speed, validation purposes, etc.?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-co...
<p>I use <code>javascript:void(0)</code>.</p> <p>Three reasons. Encouraging the use of <code>#</code> amongst a team of developers inevitably leads to some using the return value of the function called like this:</p> <pre><code>function doSomething() { //Some code return false; } </code></pre> <p>But then th...
<p>Bootstrap modals from before 4.0 have a basically undocumented behavior that they will load <code>href</code>s from <code>a</code> elements using AJAX unless they are exactly <code>#</code>. If you are using Bootstrap 3, <code>javascript:void(0);</code> hrefs will cause javascript errors:</p> <p><code>AJAX Error: e...
16,329
<p>I'm programming a file transfer handler with speed limit feature, the rate based on user level. How do I control/calculate transfer rate in HttpHandler?.</p> <p>Some asp.net resource tell me that use Thread.Sleep will block asp.net thread pool.</p>
<p>It is generally a bad idea to Sleep any thread from ASP .NET, because those threads could be used otherwise to service requests from the pool. If there were say, 10 threads in the pool, sleeping 10 threads that were processing downloads would cause all other requests to pile up in the queue until a download had fini...
<p>You might want to try using timers and a timer callback to do this. The idea would be to have a timer (or maybe two) that triggers when your handler can run and for how long. Every time the "go" timer expires, it starts a thread which writes your data to the response until the "stop" timer expires (or the same t...
44,995
<p>VS 2008 crashes whilst opening a solution file when it reaches the stage of "Loading project files 'Solution Items'". </p> <p>Is there any way of either stopping the virtual folder of solution items from opening or a workaround for this? The solution is coming from TFS 2005 and source control.</p> <p>Thanks</p>
<p>Another thing you could try is removing the .suo file of your solution. This files contains your personal settings and can get corrupted sometimes. It also contains which documents where open when you exited, so removing this file also clears that list.</p>
<p>.sln (and .csproj) files are just text files. So you could open the solution fle in a text editor and remove the entry for the offending project or item.</p>
40,980
<p>What is the differences and similarities between Domain Specific Languages (DSL) and Domain Driven Design (DDD)?</p>
<p>Domain Driven Design (DDD) is a way of thinking and communicating about the problems and its solutions. </p> <p>Domain Specific Language (DSL) is a way of writing code.</p> <p>They're similar because they both start with the word "domain". That's it, I guess. :-)</p>
<p>Wikipedia has a pretty clear definition for <a href="http://en.wikipedia.org/wiki/Domain_Specific_Language" rel="nofollow noreferrer">DSL</a>:</p> <blockquote> <p>The term domain-specific language (DSL) has become popular in recent years in software development to indicate a programming language or specif...
21,401
<p>When have you ever personally come upon the <strong><a href="https://en.wikipedia.org/wiki/Halting_problem" rel="nofollow noreferrer">halting problem</a></strong> in the field? This can be when a co-worker / boss suggested a solution which would violate the fundamental limits of computation, or when you realized you...
<p>I <em>literally</em> got assigned the halting problem, as in "write a monitor plugin to determine whether a host is permanently down". Seriously? OK, so I'll just give it a threshold. "No, because it might come back up afterward."</p> <p>Much theoretical exposition ensued.</p>
<p>"How can you assure me your code is 100% free of bugs?"</p>
29,204
<p>Of the two methods below, which do you prefer to read?<br> Is there another (better?) way to check if a flag is set?</p> <pre><code> bool CheckFlag(FooFlag fooFlag) { return fooFlag == (this.Foo &amp; fooFlag); } </code></pre> <p>And</p> <pre><code> bool CheckFlag(FooFlag fooFlag) { return (this.Fo...
<p>The two expressions do different things (if fooFlag has more than one bit set), so which one is better really depends on the behavior you want:</p> <pre><code>fooFlag == (this.Foo &amp; fooFlag) // result is true iff all bits in fooFlag are set (this.Foo &amp; fooFlag) != 0 // result is true if any bits in ...
<p>I'm a positive thinker:</p> <pre><code>bool CheckFlag(FooFlag fooFlag) { return this.Foo &amp; fooFlag == 1; } </code></pre>
25,065
<p>If a user types in a long line without any spaces or white space, it will break formating by going wider than the current element. Something like:</p> <blockquote> <p>HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA.............................................................................................................
<p>in CSS3: </p> <pre><code>word-wrap:break-word </code></pre>
<p>I have posted a solution which uses JavaScript and a simple Regular Expression to break long word so that it can be wrapped without breaking your website layout.</p> <p><a href="http://www.hemanshubhojak.com/Home/Post?postId=8" rel="nofollow noreferrer">Wrap long lines using CSS and JavaScript</a></p>
47,453
<p>I'm trying to get this:</p> <pre><code>//C.h #ifndef C_H #define C_H #include "c.h" class C { public: C(); int function(int, int); }; #endif </code></pre> <p>which is defined in this:</p> <pre><code>//c.cpp #include "c.h" C::C() { } int C::function(int a, int b) { return a * b; } </code><...
<p>It looks like your link phase is trying to create an executable from just crp.obj, <strong>NOT</strong> crp.obj and c.obj.</p> <p>How are you compling it? It should be something like (in the case of Borland, as mentioned in edit):</p> <pre><code>bcc32 -ecrp.exe crp.cpp c.cpp </code></pre> <p>You also don't need ...
<p>Which compiler / development environment are you using? Is this from the command line or an IDE?</p> <p>You need to make sure you compile c.cpp and tell the linker to include c.obj together with crp.obj to create your executable.</p>
39,555
<p>I've got a number of WebService methods that all include some very boilerplate code of wrapping the actual work in a try/catch/finally and performing the same tasks in the catch/finally. So as a way to encapsulate all of the shared catch/finally stuff I wrote a simple generic.</p> <p>This works and really eliminate...
<p>I would change</p> <pre><code>public static T2 ExceptionHandler&lt;T1, T2&gt;(RestfulServiceRequest&lt;T1, T2&gt; serviceCall, T1 req) </code></pre> <p>to</p> <pre><code>public static T2 Invoke&lt;T1, T2&gt;( this T1 req, RestfulServiceRequest&lt;T1, T2&gt; serviceCall) </code></pre> <p>This will change the call...
<p>I would agree that this feels a bit clunky to accomplish, however, I am not right away seeing the "pefect" way to re-work this to minimize duplication.</p> <p>THe only thing I'm thinking is that if you can somehow use interfaces or break it up a bit, I'm not sure exactly how I'd do it, but I can say that for on goi...
44,555
<p>I have some code for starting a thread on the .NET CF 2.0:</p> <pre><code>ThreadStart tStart = new ThreadStart(MyMethod); Thread t = new Thread(tStart); t.Start(); </code></pre> <p>If I call this inside a loop the items completely out of order. How do introduce a wait after <code>t.Start()</code>, so that the work...
<p>How much order do you need to impose on the threads? If you just need all of the work started in the loop to finish before the code continues, but you don't care about the order the work within the loop finishes, then calling Join is the answer. To add more detail to <a href="https://stackoverflow.com/questions/6890...
<p>If I'm reading this properly, you're starting work items on bunch of threads but you're concerned that the threads are completing out of order, and, would prefer to wait until each thread completes in the order they were started ? </p> <p>If this is the case then I'm not sure why you're creating a thread per work i...
2,856
<p>What Firefox add-ons do you use that are useful for programmers?</p>
<p>I guess it's silly to mention Firebug -- doubt any of us could live without it. Other than that I use the following (only listing dev-related):</p> <ul> <li>Console<sup>2</sup>: next-generation error console</li> <li>DOM inspector: as the title might indicate, allows you to browse the DOM</li> <li>Edit Cookies: cha...
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/60" rel="nofollow noreferrer">Web Developer</a> for web development. <a href="https://addons.mozilla.org/en-US/firefox/addon/1730" rel="nofollow noreferrer">Scribefire</a> if you're a blogger-progammer</p>
5,702
<p>Is contract to interface as object is to class?</p> <p>What is the need to differentiate identical things like this, from the code to the executing code? I sort of get the idea behind naming a class a class and the instantiated executing class an object, but overall, is that the only reason for these semi-redundan...
<p>Not really. There are four terms here, so I'll go over each of them:</p> <h2>Interface</h2> <p>An interface is an abstract class (in languages like Java where there is no multiple inheritance, sometimes there are other restrictions, such as a separate data type) that is intended to be used as a common base to acce...
<p>"Class" and "Object" represent two different things; they are related, but what they represent IS different, quite strongly.</p> <p>The best way to describe this is to look at Static. A class can have static members, which are completely separate from any INSTANCE of that class. Objects of that class may or may n...
27,010
<p>I'm looking for a way to do query auto-completion/suggestions in Lucene. I've Googled around a bit and played around a bit, but all of the examples I've seen seem to be setting up filters in Solr. We don't use Solr and aren't planning to move to using Solr in the near future, and Solr is obviously just wrapping arou...
<p>Based on @Alexandre Victoor's answer, I wrote a little class based on the Lucene Spellchecker in the contrib package (and using the LuceneDictionary included in it) that does exactly what I want.</p> <p>This allows re-indexing from a single source index with a single field, and provides suggestions for terms. Resul...
<p>You can use the class <strong>PrefixQuery</strong> on a "dictionary" index. The class <strong>LuceneDictionary</strong> could be helpful too.</p> <p>Take a look at this article linked below. It explains how to implement the feature "Did you mean ?" available in modern search engine such as Google. You may not need ...
14,617
<p>I've got an application that uses a hibernate(annotations)/mysql combination for ORM. In that application, I got an entity with a Date field. I'm looking for a way to select on that date within a time range (so <code>hh:mm:ss</code> without the date part). </p> <p>In MySQL there's a function <code>TIME(expression)<...
<p>The following functions are available in HQL, maybe you could use them:</p> <p><code>second(...), minute(...), hour(...), day(...), month(...), year(...)</code></p>
<p>Add the expression as a SQL restriction rather than having a full native query. I don't know MySQL specifically, but imagine something like this:</p> <pre><code>Criteria criteria = session.createCriteria(MyTable.class); criteria.add( Expression.sql( "TIME( {alias}.my_date, 'hh:mm:ss') &gt;= :1", dateRan...
12,704
<p>Is there any way to have a look at signatures of anonymous functions in ActionScript 3 during runtime?</p> <p>I would like to validate <code>Function</code> objects passed in as arguments to other functions and make sure that they accept the correct number of arguments (with the correct types) and return a value of...
<p>It doesn't look like the runtime allows you to reflect on anonymous functions, which is a shame.</p> <p>Anonymous functions are (perhaps by definition) marked as <code>dynamic</code>. If you pass an incompatible type into an anonymous function, <em>no error is thrown</em>. Any type mismatches will be silently cast ...
<p>As a rough approximation you can check the number of parameters using length property, e.g.:</p> <pre><code>function doStuff(callback:Function) { trace(callback.length); } </code></pre> <p>I'm not aware of any way to enumerate the arguments of an anonymous functions; you can of course validate ex-post catching A...
43,279
<p>I need to find 2 elements in an unsorted array such that the difference between them is less than or equal to (Maximum - Minimum)/(number of elements in the array).</p> <p>In O(n).</p> <p>I know the max and min values.</p> <p>Can anyone think of something?</p> <p>Thank you!</p>
<p>Step 1: Use <a href="http://en.wikipedia.org/wiki/Bucket_sort" rel="nofollow noreferrer">Bucket Sort</a>. Don't sort the individual buckets.</p> <p>Should be pretty obvious what to do from here, and how to size the buckets.</p>
<ol> <li><p>Number of buckets = <code>2n</code>.</p> <p>values in each bucket = <code>(min + k((max-min)/2n)) &lt;= value &lt; (min + (k+1)((max-min)/2n)).</code> </p> <p>0 &lt;= k &lt; 2n</p> <p>Range of each bucket = <code>((max-min)/2n)</code></p></li> <li><p>Assign each element into buckets. Dont sort inside bu...
48,064
<p>I'm looking for a suite of plugins that can help me finally switch over to vim full-time.</p> <p>Right now I'm using Komodo with some good success, but their vim bindings have enough little errors that I'm tired of it.</p> <p>What I do love in Komodo, though, is the code completion. So, here's what I'm looking for...
<p><a href="http://www.sontek.net/python-with-a-modular-ide-vim" rel="nofollow noreferrer">Here you can find some info</a> about this.</p> <p>It covers code completion, having a list of classes and functions in open files. I haven't got around to do a full configuration for vim, since I don't use Python primarily, but...
<p><strong>Code completion:</strong> <a href="http://github.com/orestis/pysmell/tree/master" rel="nofollow noreferrer">PySmell</a> looks promising. It's work-in-progress, but alredy useful.</p>
17,392
<p>After reading "<a href="http://web.archive.org/web/20090117062700/http://stackoverflow.com:80/questions/20702/whats-youra-good-limit-for-cyclomatic-complexity" rel="noreferrer">What’s your/a good limit for cyclomatic complexity?</a>", I realize many of my colleagues were quite annoyed with this new <a href="http://e...
<h3>With current logging frameworks, the question is moot</h3> <p>Current logging frameworks like slf4j or log4j 2 don't require guard statements in most cases. They use a parameterized log statement so that an event can be logged unconditionally, but message formatting only occurs if the event is enabled. Message con...
<p>As much as I hate macros in C/C++, at work we have #defines for the if part, which if false ignores (does not evaluate) the following expressions, but if true returns a stream into which stuff can be piped using the '&lt;&lt;' operator. Like this:</p> <pre><code>LOGGER(LEVEL_INFO) &lt;&lt; "A String"; </code></pre>...
13,139
<p>I recently bought a Windows Mobile device and since I'm a developer I want to use it as a development platform. Yes, it's not supposed to be used like that but it's always with me and my laptop isn't. I know <a href="http://www.animaniak.com/cke/cke_main.asp" rel="nofollow noreferrer">cke</a> is a good editor for co...
<p>There is a possibility to run <a href="http://uema2.s8.xrea.com/ruby-mswince/" rel="nofollow noreferrer"><strong>Ruby on Windows Mobile</strong></a></p> <p>Check this article for steps: <a href="http://andryshuzain.com/journal/ruby-on-windows-mobile-5" rel="nofollow noreferrer"><strong>Human vs Machine</strong></a>...
<p>This is n old port of Ruby to WinCE, but from what I've read it doesn't work all that well - who knows, give it a try, YMMV</p> <p><a href="http://uema2.s8.xrea.com/ruby-mswince/" rel="nofollow noreferrer">http://uema2.s8.xrea.com/ruby-mswince/</a></p> <p>As for Javascript, WinMo devices have Pocket Internet Explo...
8,539
<p>When using <code>before_filter :login_required</code> to protect a particular page, the <code>link_to_unless_current</code> method in the application layout template renders the "Login" link for the login page as a hyperlink instead of just text.</p> <p>The "Login" text/link problem only occurs when redirected to t...
<p>You can use a route helper method to perform the page redirection:</p> <pre><code> redirect_to login_url </code></pre> <p>If a "named route" for login is defined (which is done by adding an explicit path to "/login" in your "config/routes.rb" file).</p> <p>This path is actually the same as that generated by:</p> ...
<p>Appreciate the responses and you can tell by the nature of the question that we're new to rails. By the way, we posted the same question on this site: <a href="http://railsforum.com" rel="nofollow noreferrer">http://railsforum.com</a> (not sure if it's the official rails forum) with no response yet. StackOverflow so...
23,381
<p>I'm trying to learn about trees by implementing one from scratch. In this case I'd like to do it in C# Java or C++. (without using built in methods)</p> <p>So each node will store a character and there will be a maximum of 26 nodes per node.</p> <p>What data structure would I use to contain the pointers to each o...
<blockquote> <blockquote> <p>What data structure would I use to contain the pointers to each of the nodes?</p> </blockquote> </blockquote> <p>A Node. Each Node should have references to (up to) 26 other Nodes in the Tree. Within the Node you can store them in an array, LinkedList, ArrayList, or just about an...
<p>It doesn't really matter. You can use a linked list, an array (but this will have a fixed size), or a List type from the standard library of your language.</p> <p>Using a List/array will mean doing some index book-keeping to traverse the tree, so it might be easiest to use just keep references to the children in th...
44,828
<p><strong>Caveat:</strong> I try all the posibilities listed here: <a href="https://stackoverflow.com/questions/254002/how-can-i-ignore-everything-under-a-folder-in-mercurial">How can I ignore everything under a folder in Mercurial</a>.<br> None works as I hope. </p> <p>I want to ignore every thing under the folder ...
<p>Try it without the slash after the caret in the regexp version.</p> <pre><code>^test/ </code></pre> <p>Here's a test:</p> <pre><code>~$ mkdir hg-folder-ignore ~$ cd hg-folder-ignore ~/hg-folder-ignore$ echo '^test/' &gt; .hgignore ~/hg-folder-ignore$ hg init ~/hg-folder-ignore$ mkdir test ~/hg-folder-ignore$ touc...
<p>Create .hgignore file under root directory of the repository </p> <p>Now add the following contents in the file . </p> <blockquote> <p>syntax: glob</p> <p>bin/**</p> <p>*.DS_Store</p> </blockquote> <p>This will remove the bin directory and all the *.DS_Store files from the repository</p>
39,958
<p>I have some code that raises <code>PropertyChanged</code> events and I would like to be able to unit test that the events are being raised correctly.</p> <p>The code that is raising the events is like</p> <pre><code>public class MyClass : INotifyPropertyChanged { public event PropertyChangedEventHandler Propert...
<p>Everything you've done is correct, providing you want your test to ask "What is the last event that was raised?"</p> <p>Your code is firing these two events, in this order </p> <ul> <li>Property Changed (... "My Property" ...)</li> <li>Property Changed (... "MyOtherProperty" ...)</li> </ul> <p>Whether this is "co...
<p>I've made an extension here:</p> <pre><code>public static class NotifyPropertyChangedExtensions { private static bool _isFired = false; private static string _propertyName; public static void NotifyPropertyChangedVerificationSettingUp(this INotifyPropertyChanged notifyPropertyChanged, string prop...
30,946
<p>I have a few model classes with basic one-to-many relationships. For example, a book has many recipes, and each recipe has many ingredients:</p> <pre><code>class Book(models.Model): name = models.CharField(max_length=64) class Recipe(models.Model): book = models.ForeignKey(Book) name = models.CharFiel...
<p>Actually, it looks like there's a better approach using filter:</p> <pre><code>my_book = Book.objects.get(pk=1) all_ingredients = Ingredient.objects.filter(recipe__book=my_book) </code></pre>
<p>To print each recipe and its ingredients:</p> <pre><code>mybook = Book.objects.get(name="Jason's Cookbook") for recipe in mybook.recipe_set.all(): print recipe.name for ingredient in recipe.ingredients: print ingredient.text </code></pre> <p>And if you just want to get a list of all ingredient obje...
37,624
<p>What's the best way to pass data from one Windows Forms app (an office plugin) to another (exe written in C#) in C#? </p>
<p>I'll take a wild stab at this and say you probably want the office app to <em>phone home</em> to your exe? In this context, the &quot;exe&quot; is the server and the office app is the client.</p> <p>If you're using .NET 3.0, WCF is likely your best bet. I would structure the solution into three parts:</p> <ol> <li...
<p><a href="http://msdn.microsoft.com/en-us/netframework/aa663324.aspx" rel="nofollow noreferrer">WCF</a> is one of the easiest ways to do this. You can register a service endpoint in each app, or if one is the service and another is the client you can just use a single service host.</p> <p><a href="http://msdn.micros...
28,758
<p>We are considering switching from Adobe Flex to Silverlight because Flex is just too slow.</p> <p>I'm interested not in graphical performance, but computational performance and the speed at which it executes code.</p> <p>Does anyone have any anecdotes to share about their experience of Silverlight performance?</p>...
<p>Unlike Flex, Silverlight is multi-threaded. Which if used properly gives you the ability to write highly performant apps. There are many articles and blog posts on this. Here's a sample...</p> <p><a href="http://www.silverlighthack.com/post/2008/09/07/Silverlight-MultiThreading-with-a-Computational-Process-(Countin...
<p>I've found that Silverlight handles the computational performance quite well. I've been disapointed by some of the graphical performance. Since that isn't you problem, I'd suggest some test with a few complex processes. I haven't used Flex, so I don't have a my own test for the difference.</p>
47,524
<p>I'm trying to "install SGML::Parser::OpenSP" from the cpan shell, but it fails on the first "make test". I also get the same error if I go into the build directory and run make test.</p> <p>I believe this bit of the output below is the relevant part. Note the Symbol not found when perl gets to the "use" line for t...
<p>If you use the Settings for the project, you can mark each setting as either application or user.</p> <p>If they're set as user, they will be stored per-user and when you call the Save method it will be updated in the config for that user.</p> <p>Code project has a really detailed <a href="http://www.codeproject.c...
<p>app.config isn't what you want to use for user-tweakable data, as it'll be stored somewhere in Program Files (which the user shouldn't have write permissions to). Instead, settings marked with <code>a UserScopedSettingAttribute</code> will end up in a user-scoped .config file somewhere in %LocalAppData%.</p> <p>I f...
5,699
<p>In a <a href="https://stackoverflow.com/questions/9033#9099">question answer</a> I find the following coding tip:-</p> <p>2) simple lambdas with one parameter:</p> <pre><code>x =&gt; x.ToString() //simplify so many calls </code></pre> <p>As someone who has not yet used 3.0 I don't really understand this tip but i...
<p>When you need to create an instance of a delegate which has a single parameter, lambda expressions allow you to create that delegate "inline" in a very concise manner. For instance, here's code to find a particular person in a list, by their name:</p> <pre><code>List&lt;Person&gt; list = new List&lt;Person&gt;(); /...
<pre><code>string delegate(TypeOfX x) { return x.ToString(); } </code></pre>
18,978
<p>I printed a lot of models in last month. I spent 2 kg filament in total. I want to know how many hours have been passed while printing. As far as I read, 1 kg PLA (1.75 mm) is about 110 meters long. My default print speed is 70 mm/s. The nozzle diameter is 0.4 mm. The nozzle multiplier in the simplify3d is 0.9 .</p>...
<p>Your formula doesn't seem to take into account two important factors: layer height and average speed.</p> <p>Do the math differently:</p> <p>voumetric flow rate [mm^3/s] = layer height [mm] * line width [mm] * speed [mm/s]</p> <p>For example, 0.2 * 0.45 * 70 = 6.3 mm^3/s</p> <p>which is realistic, the extruder on th...
<p>Your math looks correct, and is also a good approximation for what I've seen in the first few weeks with my own Ender 3.</p> <p>Another way to calculate (to check yourself) is to calculate the volume extruded (nozzle area times extrusion percentage times print speed -- be sure you convert everything to the same unit...
1,950
<p>How can I make a Facebook RSS application that autoupdates from the provided RSS feeds. Of course doing this is trivial for canvas applications, but I need this for showing on the Facebook Page. All the RSS apps I've taken a look at either dont update or dont work on Facebook Pages. </p> <p>Especially now that inf...
<p>I specifically said I do not need this for canvas applications (as that is trivial to do), but on Facebook Pages! This is done with <a href="http://wiki.developers.facebook.com/index.php/Profile.setFBML" rel="nofollow noreferrer">profile.setFBML</a> and data published that way does reside on the facebook servers. </...
<p>You have two options. </p> <ol> <li><p>Convert your user session (when the user accesses your app manually) to infinite session, then periodically update the profile information for a user. There is some information on how to do this (and what API calls you can make without sessions) <a href="http://wiki.developers...
12,521
<p>Are there any good programs for dealing with reading large CSV files? Some of the datafiles I deal with are in the 1 GB range. They have too many lines for Excel to even deal with. Using Access can be a little slow, as you have to actually import them into a database to work with them directly. Is there a program ...
<p>MySQL can import CSV files very quickly onto tables using the <a href="http://dev.mysql.com/doc/refman/5.0/en/load-data.html" rel="noreferrer"><code>LOAD DATA INFILE</code></a> command. It can also read from CSV files directly, bypassing any import procedures, by using the <a href="http://dev.mysql.com/doc/refman/5....
<p>vEdit is great but don't forget you can always go back to "basics" check out <a href="http://www.cygwin.com/" rel="nofollow noreferrer">Cygwin</a> and start greping.</p> <p>Helpfull commands</p> <ul> <li>grep </li> <li>head</li> <li>tail</li> <li>of course perl!</li> </ul>
6,602
<p>How would I disable and later enable all indexes in a given schema/database in Oracle?</p> <p>Note: This is to make sqlldr run faster.</p>
<p>Here's making the indexes unusable without the file:</p> <pre><code>DECLARE CURSOR usr_idxs IS select * from user_indexes; cur_idx usr_idxs% ROWTYPE; v_sql VARCHAR2(1024); BEGIN OPEN usr_idxs; LOOP FETCH usr_idxs INTO cur_idx; EXIT WHEN NOT usr_idxs%FOUND; v_sql:= 'ALTER INDEX ' || cur_id...
<p>You should try sqlldr's SKIP_INDEX_MAINTENANCE parameter.</p>
15,692
<p>The documentation indicates that the error: option function will make available: XHR instance, a status message string (in this case always error) and an optional exception object returned from the XHR instance (Book: JQuery in Action)</p> <p>Using the following (in the $.ajax call) I was able to determine I had a ...
<p>Looking at the jQuery source code, there are four returned statuses, in additon to <strong>success</strong>:</p> <ul> <li><strong>timeout</strong> - when your specified timeout is exceeded</li> <li><strong>error</strong> - http error, like 404</li> <li><strong>notmodified</strong> - when requested resource was not ...
<p>Are you sure that response is correct? Parse error mean that there is sth wrong with data being evaluted in line <code>var t = eval( "(" + request + ")" ) ;</code></p>
12,114
<p>I'm trying to install a site under an alternative port on a server, but the port may be closed by a firewall. Is there a way to ping out or in, on a specific port, to see if it is open?</p>
<p>Assuming that it's a TCP (rather than UDP) port that you're trying to use:</p> <ol> <li><p>On the server itself, use <code>netstat -an</code> to check to see which ports are listening.</p></li> <li><p>From outside, just use <code>telnet host port</code> (or <code>telnet host:port</code> on Unix systems) to see if t...
<p>Another utility that I found and is good and small as well, is <a href="https://www.microsoft.com/en-us/download/details.aspx?id=17148" rel="nofollow noreferrer">PortQry Command Line Port Scanner version 2.0</a>.</p> <p>You can ping a server and a port and it will tell you the state of the port. There is a command-...
34,403
<p>This has been a problem that I haven't been able to figure out for sometime. Preventing the second instance is trivial and has many methods, however, bringing back the already running process isn't. I would like to:</p> <ul> <li>Minimized: Undo the minimize and bring the running instance to the front.</li> <li>Be...
<p>I found this code to be useful. It does the detection and optional activation of an existing application:</p> <p><a href="http://www.codeproject.com/KB/cs/cssingprocess.aspx" rel="noreferrer">http://www.codeproject.com/KB/cs/cssingprocess.aspx</a></p>
<p>Here is a simple and easily understandable method for preventing duplicate concurrent execution (written in c#).</p> <pre><code>public static void StopProgramOnSecondRun() { string //Get the full filename and path FullEXEPath = System.Reflection.Assembly.GetEntryAssembly().Location, //Iso...
11,993
<p>I've heard powershell 2.0 CTP has modules, but I can't find much example code or instructions. I've read what little help there seems to be online...</p> <p>But I just keep getting "The term 'Add-Module' is not recognized as a cmdlet..." when I try and load a module.</p> <p>Any help would be gratefully received!</...
<p>With the Win7 build, Add-Module is gone. The new cmdlet is Import-Module. The easiest way to create a module is rename a PS1 file to a PSM1 file. From there you can do all sorts of things including the module manifest.</p>
<p>Windows PowerShell v2.0: TFM (sapienpress.com) has information and samples in one of the chapters. It's available as an ebook which is updated as new CTPs are released. I also blogged about them on ConcentratedTech.com, and there's been discussion on them at PowerShellCommunity.org in the forums.</p>
44,367
<p>What is the best way to read and/or set Internet Explorer options from a web page in Javascript? I know that these are in registry settings.</p> <p>For example, I'm using the <a href="http://www.lutanho.net/diagram/" rel="nofollow noreferrer">JavaScript Diagram Builder</a> to dynamically generate bar charts within...
<p>Web pages have no business reading users' settings, therefore there is no interface for this.</p>
<p>This sounds like it would be a big security hole, one that the IE team would keep nailed very shut</p>
31,353
<p>I have many different branches/checkouts of the same project code on my development machine. Each one is virtually the same except for various maintenance bug fixes or improvements I'm working on within each project.</p> <p>The problem comes when I use Find in Files inside Visual Studio to search through my code. V...
<p>This drives me nuts too. But in "Look In:" dropdown on the find in files dlg you will find items for Solution and project. I think that should work for you.</p>
<p>In VS2008, with no files open, when I select 'Current Project' it searches whatever project is currently selected in the Solution Explorer. When I switch between files in different projects, it correctly searches the project of the currently selected file. I don't see any options for changing this behavior.</p>
44,486
<p>I am trying to migrate a part of an SVN repository using <code>svnadmin dump</code>.</p> <p>The provided svndumpfilter tool doesn't manage copy/move/rename dependencies from directories not included in the export.</p> <p>Is there a tool which can manage these dependencies?</p>
<p>I found a Python script by Simon Tatham called <a href="http://svn.tartarus.org/sgt/svn-tools/svndumpfilter2?view=markup" rel="nofollow noreferrer">svndumpfilter2</a>, which tries to cope with simple dependencies (I found some limitations, though).</p> <p>You can also check an <a href="http://www.chiark.greenend.or...
<p>With dependencies you mean those specified by the property svn:external?</p> <p>If yes, I think you should pass to svndumpfilter also the paths referrend in the property. For example, if your project is in <code>http://host/project</code> and the svn:external property is set to <code>http://host/dependencies</code>...
32,269
<p>During navigation of the <code>java.lang.reflect.Method</code> class I came across the method <code>isBridge</code>. Its Javadoc says that it returns true only if the Java spec declares the method as true.</p> <p>Please help me understand what this is used for! Can a custom class declare its method as a bridge if r...
<p>A bridge method may be created by the compiler when extending a parameterized type whose methods have parameterized arguments. </p> <p>You can find in this class <a href="https://fisheye.springsource.org/browse/spring-framework/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java?r=02a4473c6...
<p>Another case I stumbled across has nothing to do with generics:</p> <pre><code>protected abstract class Super { public void m() {} } public class Sub extends Super {} assert Sub.class.getMethod("m").isBridge(); </code></pre>
36,908
<p>The client has asked for a number of tables to be extracted into csv's, all done no problem. They've just asked we make sure the files are always in UTF 8 format.</p> <p>How do I check this is actually the case. Or even better force it to be so, is it something i can set in a procedure before running a query perha...
<p>You can check the database character set with the following query:</p> <pre><code>select value from nls_database_parameters where parameter='NLS_CHARACTERSET' </code></pre> <p>If it says AL32UTF8 then your database is in the format what you need and if the export does not impair it then your are done.</p> <p>You...
<p>What you have to look for is the eight-bit ascii characters in hte input (if any) are translated into double byte utf-8 characters.</p> <p>This is highly dependant on your local ASCII code page but typically:- ASCII "£" should be x'A3' in ascii magically becomes x'C2A3' in utf-8.</p>
46,341
<p>I have an app which consists of several different assemblies, one of which holds the various interfaces which the classes obey, and by which the classes communicate across assembly boundaries. There are several classes firing events, and several which are interested in these events. </p> <p>My question is as follow...
<p>You could put the event itself in an interface, so that A didn't need to know about C directly, but only that it has the relevant event. However, perhaps you mean that the instance of A doesn't have sight of an instance of C...</p> <p>I would try to steer clear of a centralised event system. It's likely to make tes...
<p>we have our own event broker implementation (open source) Tutorial at: <a href="http://sourceforge.net/apps/mediawiki/bbvcommon/index.php?title=Event_Broker" rel="nofollow noreferrer">http://sourceforge.net/apps/mediawiki/bbvcommon/index.php?title=Event_Broker</a></p> <p>And a performance analysis at: www.planetgee...
37,703
<p>I have a string that is like below.</p> <pre><code>,liger, unicorn, snipe </code></pre> <p>in other languages I'm familiar with I can just do a string.trim(",") but how can I do that in c#?</p> <p>Thanks.</p> <hr> <p><em>There's been a lot of back and forth about the StartTrim function. As several have pointed...
<pre><code>string sample = ",liger, unicorn, snipe"; sample = sample.TrimStart(','); // to remove just the first comma </code></pre> <p>Or perhaps:</p> <pre><code>sample = sample.Trim().TrimStart(','); // to remove any whitespace and then the first comma </code></pre>
<pre><code>if (s.StartsWith(",")) { s = s.Substring(1, s.Length - 1); } </code></pre>
9,935
<p>If you have a web application that will run inside a network, it makes sense for it to support windows authentication (active directory?).</p> <p>Would it make sense to use AD security model as well, or would I make my own roles/security module that some admin would have to configure for each user?</p> <p>I've ne...
<p>Basically windows handles everything, you never store usernames or passwords, AD and IIS do all the work for you</p> <p>add this to your <code>web.config</code></p> <pre><code> &lt;system.web&gt; ... &lt;authentication mode="Windows"/&gt; ... &lt;/system.web&gt; </code></pre> <p>To configure Windows authen...
<p>I used windows security on some of my internal sites.</p> <p>Basically the way I set it up is I remove anonymous access in IIS, then assign permissions on the sites files though the standard windows security model.</p> <p>I'm not sure if this is the best practices, but it has always worked well for me.</p>
47,073
<p>Please post a working source code example (or link) of how to search string in another process memory and getting offset of match if found. The similar way its done in game cheating utils which search for values in game memory using ReadProcessMemory.</p>
<p>Internationalization is hard, here's a few things I've learned from working with 2 websites that were in over 20 different languages:</p> <ul> <li>Use UTF-8 everywhere. No exceptions. HTML, server-side language (watch out for PHP especially), database, etc.</li> <li>No text in images unless you want a ton of work. ...
<p>I have a couple apps that are "bilingual" I used resource files in ASP.NET1.1</p> <p>There is also something called the String Resource Tool Basically you put all your strings in a .RES file for both languages and then determine what file to read from based on Culture or whether someone clicked a Link for the langu...
18,837
<p>Often, I find myself wanting to write a unit test for a portion of code that accesses HTTP resources as part of its normal function. Have you found any good ways to write these kinds of tests?</p>
<p>Extract the part that accesses the HTTP resources out of your main code. Create an interface for that new component, In your test, mock the interface and return data that you can control reliably.</p> <p>You can test the HTTP access as an integration test.</p>
<p>This is typically a function I would mock out for the tests... I don't like my tests depending on anything external... even worse if it is an external resource I have no control over (such as a 3rd party website).</p> <p>Databases is one of the few external resources I often won't mock... I use DBUnit instead.</p>
9,411
<p>I am searching for a good system for PHP, which does UnitTesting, Subversion, Coding Standards.</p> <p>I would love to hear your suggestions and which one is the best and why. I will be running it on a debian server so anything which runs on mac or windows servers would be out of the question.</p>
<p>I second Hudson for CI and PHP. I have written a tutorial on setting it up if you are interested.</p> <p>Edit:</p> <p>My tutorial is out of date.</p> <p>I highly recommend: <a href="http://jenkins-php.org/" rel="nofollow noreferrer">http://jenkins-php.org/</a></p>
<p>If it's continuous integration that you're looking for have you checked out <a href="http://www.jetbrains.com/teamcity/" rel="nofollow noreferrer">TeamCity</a>? It's not specifically for PHP but it's <em>very</em> easy to set up and manage. It's also free for the <a href="http://www.jetbrains.com/teamcity/buy/buy.js...
17,402
<p>So, im trying to write some code that utilizes Nvidia's CUDA architecture. I noticed that copying to and from the device was really hurting my overall performance, so now I am trying to move a large amount of data onto the device.</p> <p>As this data is used in numerous functions, I would like it to be global. Yes,...
<p>Something like this should probably work.</p> <pre><code>#include &lt;algorithm&gt; #define NDEBUG #define CUT_CHECK_ERROR(errorMessage) do { \ cudaThreadSynchronize(); \ cudaError_t err = cudaGetLastError(); ...
<p>Erm, it was exactly that problem of moving devPtr to global scope that was my problem.</p> <p>I have an implementation that does exactly that, with the two kernels having a pointer to data passed in. I explicitly don't want to pass in those pointers.</p> <p>I have read the documentation fairly closely, and hit up ...
10,449
<ol> <li>Is it possible to secure only the Login.aspx page (and the postback) and not the whole site in IIS?</li> <li>We are looking to do this specifically with a SharePoint site running Forms Based Authentication against our Active Directory.</li> <li>Links to this will be helpful.</li> </ol> <p>This is what we have...
<p>There's not a whole lot of point. If the only thing that's encrypted is the Login.aspx page, that would mean that someone could sniff all the traffic that was not sent through the login page.</p> <p>Which might prevent people from getting user:pass, but all your other data is exposed.</p>
<p>Besides all the data which is exposed, and the user's operation which can be changed en route, the user's session id (or other authentication data) is sent in the clear. This means that an attacker can steal your cookie (...) and impersonate you to the system, even without getting your password. (If I remember corre...
16,351
<p>I have a table with the following columns:</p> <pre> A B C --------- 1 10 X 1 11 X 2 15 X 3 20 Y 4 15 Y 4 20 Y </pre> <p>I want to group the data based on the B and C columns and count the distinct values of the A column. But if there are two ore more rows where the value on the A column is...
<p>I like to work in steps: first get rid of duplicate A records, then group. Not the most efficient, but it works on your example.</p> <pre><code>with t1 as ( select A, max(B) as B, C from YourTable group by A, C ) select count(A) as CountA, B, C from t1 group by B, C </code></pre>
<p>Check this out. This should work in Oracle, although I haven't tested it;</p> <pre><code>select count(a), BB, CC from ( select a, max(B) BB, Max(C) CC from yourtable group by a ) group by BB,CC </code></pre>
39,715
<p>I have several databases for my applications that use SQL Server 2005 mirroring to keep a nice copy of the data somewhere else. Works like a charm, however, the log file just seems to be growing and growing, one is at 15GB for a 3GB database. </p> <p>Normally, I can just shrink it - however an error pops up that...
<p>I would look at why your logfile is growing, then you can define a strategy for solving your issue. It might be worth checking your mirroring state</p> <p>When a principal database is exposed, it is active with user connections and processing transactions. However, no log records are being sent to the mirror datab...
<p>Please make sure to perform a full backup after performing log backup with TRUNCATE_ONLY. This breaks the log backup chain.</p>
31,323
<p>My organization is using CppUnit and I am trying to run the same test using different parameters. Running a loop inside the test is not a good option as any failure will abort the test. I have looked at <code>TestDecorator</code> and <code>TestCaller</code> but neither seems to really fit. Code samples would be help...
<p>It does not appear possible in CppUnit to parameterize a test case directly (see <a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=1090757&amp;group_id=11795&amp;atid=361795" rel="noreferrer">here</a> and <a href="http://sourceforge.net/forum/forum.php?thread_id=1560616&amp;forum_id=37107" rel="n...
<p>I'm not a C++ programmer but I can help with the unit-test concept:</p> <p>Test-cases are meant to run isolated and with no dependency on external parameters. Additionally you should keep the number of test-cases down to the minimum which covers most of your code. There are cases, however (and I have already dealt ...
36,969