instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Is there a way that I use <a href="http://en.wikipedia.org/wiki/Microsoft_Macro_Assembler" rel="noreferrer">MASM</a> under Linux. Even tough NASM is quite popular under Linux, it still differs for some instruction style on code.</p>
| <p>Wiki says</p>
<blockquote>
<p>The MASM32 EULA does not allow its usage in the development of open source software, and only allows it to be run in Windows operating systems.</p>
</blockquote>
<p>so it is a no. </p>
| <p>Run MASM under Wine or see at the wiki that MASM can only run at Windows.</p>
<p>Regards.</p>
| 39,141 |
<p>With .net 3.5, there is a SyndicationFeed that will load in a RSS feed and allow you to run LINQ on it. </p>
<p>Here is an example of the RSS that I am loading:</p>
<pre><code><rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
<title>Title of RSS feed</title>
... | <p>This should give you an idea on how to do it:</p>
<pre><code>using System.Linq;
using System.ServiceModel.Syndication;
using System.Xml;
using System.Xml.Linq;
</code></pre>
<hr>
<pre><code>SyndicationFeed feed = reader.Read();
foreach (var item in feed.Items)
{
foreach (SyndicationElementExtension extension... | <p>Quote "I can't seem to figure out how to get the attributes of the enclosure tag, or the values of the media tags."
Anything formatted <... ...= > is called an "Attribute"
For getting all URLs attributes...</p>
<pre><code>foreach(var item in feed.Items)
{
List<string> urlList = ... | 41,325 |
<p>Using Apache's commons-httpclient for Java, what's the best way to add query parameters to a GetMethod instance? If I'm using PostMethod, it's very straightforward:</p>
<pre><code>PostMethod method = new PostMethod();
method.addParameter("key", "value");
</code></pre>
<p>GetMethod doesn't have an "addParameter" me... | <p>Post methods have post parameters, but <a href="http://www.cs.tut.fi/~jkorpela/forms/methods.html" rel="noreferrer">get methods do not</a>.</p>
<p>Query parameters are embedded in the URL. The current version of HttpClient accepts a string in the constructor. If you wanted to add the key, value pair above, you coul... | <p>Try it this way:</p>
<pre><code> URIBuilder builder = new URIBuilder("https://graph.facebook.com/oauth/access_token")
.addParameter("client_id", application.getKey())
.addParameter("client_secret", application.getSecret())
.addParameter("redirect_uri", callbackURL)
... | 26,681 |
<p>I have a compiled GUI application. I need to learn whether it is programmed using MFC libraries. Depends.exe does not return any dependency to MFC42*.dll. Is there any tool to get additional information about executables? (If possible not just the libraries, but the compiler being used, etc..)</p>
| <p>If the application you are concerned with was dynamically linked to MFC it will have a dependancy on MFCXX.dll where XX is the version number. For instance, our application is dependant on MFC80.dll.</p>
<p>However, if the application was statically linked, all the source for MFC will be compiled straight into the ... | <p>Babak Farrokhi once wrote a very handy little program named "Language 2000" that scans exes looking for libraries and frameworks binary signatures. It used to detect statically linked MFC programs two fingers up the nose.
The program was already old when I used it a few years ago though. You'd have to check the web ... | 22,131 |
<p>I have a block of code that basically intializes several classes, but they are placed in a sequential order, as later ones reference early ones.</p>
<p>For some reason the last one initializes before the first one...it seems to me there is some sort of threading going on. What I need to know is how can I stop it fr... | <p>I won't provide code, but <code>java.math.BigInteger</code> should make this trivial.</p>
| <pre><code>In[1162] := Plus @@ IntegerDigits[2^1000]
Out[1162] = 1366
</code></pre>
| 49,414 |
<p>One of my clients is developing an ASP.NET application that will be dealing with large amounts of data. The initial size of their SQL Server database will be at least 5GB and could grow to 10GB within a year or so.</p>
<p>Most web hosting companies we've looked at charge $5/month for every extra 50MB of database, ... | <p>No, it's not your only option, you could always pay the extra for more diskspace or find someone who provides virtual servers (which is a step between a dedicated box and rented hosting). </p>
<p>Additionally, purchasing a dedicated server (or the virtual one), may be a more expensive option than paying the extra ... | <p>That's a sizable database for the typical shared hosting account and would tie up a lot of space on a server that hosts dozens or hundreds of sites. On this type of account the hosting companies make additional space very expensive so that you'll trade up to a more appropriate level of service. </p>
<p>I'd suggest ... | 45,076 |
<p>Suppose I want to store many small configuration objects in XML, and I don't care too much about the format. The <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/beans/XMLDecoder.html" rel="nofollow noreferrer">XMLDecoder</a> class built into the JDK would work, and from what I hear, <a href="http://xstream.cod... | <p>I really like the <a href="http://xstream.codehaus.org/" rel="noreferrer">XStream</a>
library. It does a really good job of outputting fairly simple xml
as a result of a provided Java object. It works great for reproducing
the object back from the xml as well. And, one of our 3rd party libraries
already depended o... | <p>You should avoid XMLEncoder/XMLDecoder like the plague if you're going to be persisting a non-trivial number of objects or your system needs to be multithreaded. See <a href="http://matthew.mceachen.us/blog/do-not-want-xmlencoder-129.html" rel="nofollow noreferrer">http://matthew.mceachen.us/blog/do-not-want-xmlenco... | 12,163 |
<p>I am building an MS Access application in which all the forms are modal. However, after data change in a form, I want to refresh the parent form of this form with newer data. Is there any way to do it. To elaborate further :</p>
<p>Consider there are two forms, Form A and Form B. Both are modal form. From Form A, I... | <blockquote>
<p>No, it is like I want to run Form_Load
of Form A,if it is possible</p>
</blockquote>
<p>-- Varun Mahajan</p>
<p>The usual way to do this is to put the relevant code in a procedure that can be called by both forms. It is best put the code in a standard module, but you could have it on Form a:</p>
... | <p><strong>to refresh the form you need to type -</strong>
me.refresh
in the button event on click</p>
| 26,084 |
<p>How (i.e. using which API) is the virtual keyboard opened on Symbian S60 5th edition? The documentation seems to lack information about this.</p>
| <p>You are right, this should obviously be a published API and it should be highlighted in the documentation. No such luck.</p>
<ul>
<li><p>If you are using one of the platform native controls, the virtual keyboard will automatically popup when the user accesses a text-editing control.</p></li>
<li><p>If you are makin... | <p>Thank you tihi, very useful tip! There's also the "close virtual keyboard" event that can be triggered:</p>
<pre><code>QApplication::postEvent(lineEdit, new QEvent(QEvent::CloseSoftwareInputPanel));
</code></pre>
| 39,824 |
<p>The project is ASP.NET 2.0, I have never been able to reproduce this myself, but I get emails informing me it happens to clients many times a week, often a few times in a row.</p>
<p>Here is the full error:</p>
<p>Exception Details: </p>
<blockquote>
<p>Microsoft.Reporting.WebForms.AspNetSessionExpiredException... | <p>We had the same problem. So far, we only found it when the session expired but they used the back button in a browser that does aggressive caching, which is fine. But the ReportViewer tried to to a refresh even though the main page did not. So, we just added some hacky Global.asax error handling:</p>
<pre><code>pro... | <p>What is the question? The session expired and they cannot continue.</p>
<p>Check the report process speed. Build in some kind of benchmark or simply ask them to measure the report processing. </p>
<p>Easily can be that it is working for you, but not for them (slower network, more data to handle, slower DB server, ... | 21,526 |
<p>I would like to extract from a general HTML page, all the text (displayed or not).</p>
<p>I would like to <strong>remove</strong> </p>
<ul>
<li>any HTML tags</li>
<li>Any javascript</li>
<li>Any CSS styles</li>
</ul>
<p>Is there a regular expression (one or more) that will achieve that?</p>
| <p>You can't really parse HTML with regular expressions. It's too complex. RE's won't handle <code><![CDATA[</code> sections correctly at all. Further, some kinds of common HTML things like <code>&lt;text></code> will work in a browser as proper text, but might baffle a naive RE.</p>
<p>You'll be happier ... | <p>If you're using PHP, try Simple HTML DOM, available at SourceForge.</p>
<p>Otherwise, Google html2text, and you'll find a variety of implementations for different languages that basically use a series of regular expressions to suck out all the markup. Be careful here, because tags without endings can sometimes be ... | 21,852 |
<p>I'm implementing a math library in C++. The library will be compiled to a DLL so those who use it will only need the header files the classes' definitions.</p>
<p>The users of my classes will be people who are new to the language. However, there are some objects that might be referenced in several parts of their pr... | <p>What you tried was to overload an operator for scalar types. C++ doesn't allow you to do that except for enumerations (beside the point that operator= has to be a member). At least one of the types has to be a user defined type. Thus, what you want to do is to wrap the raw pointer into a user defined class, which ov... | <p>I'd recommend intrusive_ptr instead of shared_ptr for objects you can control for better performance and usability, as you can assign a raw pointer to intrusive_ptr later, because the reference count is embedded in the object. </p>
| 48,401 |
<p>I have an app written in C# that lies on a network share. When I run it from a local drive, everything works fine. When I start it from the remote share, calls like</p>
<pre><code>try
{
System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Directory.GetCurrentDirectory();
}
</code></pre>
<p>throw a ... | <p>This is due to <a href="http://msdn.microsoft.com/en-us/library/930b76w0.aspx" rel="nofollow noreferrer">CAS</a>; code started from the local machine has much more trust than code in the intranet, which in turn has more trust that code from the internet.</p>
<p>IIRC, with the latest SP (3.5SP1?) if you have <em>map... | <p>They changed this to some degree in .Net Framework 3.5 SP1. See <a href="http://www.infoq.com/news/2008/08/.NET-3.5-SP1-Runs-Managed-Code" rel="nofollow noreferrer">.NET 3.5 SP1 Runs Managed Applications From Network Shares</a></p>
| 21,394 |
<p>Here's a quick question I've been banging my head against today.</p>
<p>I'm trying to convert a .Net dataset into an XML stream, transform it with an xsl file in memory, then output the result to a new XML file. </p>
<p>Here's the current solution:</p>
<pre><code> string transformXML = @"pathToXslDocument"... | <p>I'm not sure but it seems that you didn't reset position in stream before passing it to XmlReader. Try to seek at the beginning of your stream before trying to read from it. Also it may be necessary to close\flush stream after you wrote some data to it.</p>
<p><strong>EDIT</strong>:</p>
<p>Just tried following cod... | <p>please look it and use..</p>
<pre><code>using (MemoryStream memStream = new MemoryStream())
{
memStream.Write(Encoding.UTF8.GetBytes(xmlBody), 0, xmlBody.Length);
memStream.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(memStream... | 6,228 |
<p>recently I downloaded this open source project and I am trying to compile it.</p>
<p>However, one of the line is giving me an error.</p>
<p>"import com.sun.org.apache.xpath.internal.functions.WrongNumberArgsException;"</p>
<p>Seems that i am missing a library.... is there a way to know WHICH library do I need?</p... | <p>The <a href="http://hppsys.passport.hp.com/hp_docs/xmltools/xalan_manual/apidocs/org/apache/xpath/functions/WrongNumberArgsException.html" rel="nofollow noreferrer">WrongNumberArgsException</a> class in Xalan is in the <code>org.apache.xpath.functions</code> package. With the Xalan jar in your project, you should j... | <p>The OpenSource author (what ever "this open source project" is) imported the internal exception class from the sun adopted xalan classes in Java 6. This should not be done at all! Will not work with older VMs and may be broken with later ones.</p>
<p>Never import com.sun.*! </p>
| 34,936 |
<p>I am using the following methods:</p>
<pre><code>public void M1(Int32 a)
{
// acquire MyMutex
DoSomething(a);
// release MyMutex
}
</code></pre>
<p>and</p>
<pre><code>public void M2(String s, String t)
{
// acquire MyMutex
DoSomethingElse(s, t);
// release MyMutex
}
</code></pre>
<p>From what I have ... | <p>Absolutely you can mix delegates with generics. In 2.0, <code>Predicate<T></code> etc are good examples of this, but you must have the same number of args. In this scenario, perhaps an option is to use captures to include the args in the delegate?</p>
<p>i.e.</p>
<pre><code> public delegate void Action();... | <p>If you look at the <code>Func<T></code> and <code>Action<T></code> delegates in the framework, you'll see that they define a number of similar delegates with different number of parameters. You can use generics, but that doesn't solve the number of arguments issue you're talking about. </p>
| 49,396 |
<p>My question concerns c# and how to access Static members ... Well I don't really know how to explain it (which kind of is bad for a question isn't it?) I will just give you some sample code:</p>
<pre><code>Class test<T>{
int method1(Obj Parameter1){
//in here I want to do something which I would ... | <p>The problem is that TryParse isn't defined on an interface or base class anywhere, so you can't make an assumption that the type passed into your class will have that function. Unless you can contrain T in some way, you'll run into this a lot.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/d5x73970.aspx" ... | <p>That is not how statics work. You have to think of statics as sort of in a Global class even if they are are spread across a whole bunch of types. My recommendation is to make it a property inside the T instance that can access the necessary static method.</p>
<p>Also T is an actual instance of something, and jus... | 4,023 |
<p>I'm looking to make validation for a page in which one or more fields have a value in them. I have an advanced search form in asp.net and I'm trying to pop up an error and not post back if all the fields are empty. I've looked into required fields validators but I'm not sure how to make them work together in a AND... | <p>You need to dive into OLE for that purpose. </p>
<p>Things like IOleDocument, IOleInPlaceSite (see <a href="http://msdn.microsoft.com/en-us/library/ms687196.aspx" rel="nofollow noreferrer">MSDN</a> for that). Figure out which interfaces are needed for the client (as IE would be the container and will need to commun... | <p>Look at <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.domdocument.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.domdocument.aspx</a>, it's .NET wrapper for DOM Document</p>
| 44,794 |
<p>As a test engineer, I often engage in exploratory testing. When I encounter a bug, it is not always immediately clear which steps led to the problem. So, obviously, I have to find the required steps to reproduce the problem. Depending on the situation, this can take a large amount of time.</p>
<p>What would be real... | <p><a href="https://stackoverflow.com/questions/7440/what-do-you-use-to-unit-test-your-web-ui">This question</a> lists tools that can be used test web applications. Some of the answers may be useful.</p>
<p>One for example is Selenium - a mozilla plugin that records your actions and can be replayed later.</p>
| <p>There's also Session Tester:
<a href="http://sessiontester.openqa.org/" rel="nofollow noreferrer">http://sessiontester.openqa.org/</a></p>
<blockquote>
<p>Session Tester is an exploratory testing tool for managing and recording Session-Based Testing. Session Tester has a timer so you can keep your test sessions a... | 26,067 |
<p>I have a problem with the <a href="https://jqueryui.com/dialog/" rel="nofollow noreferrer"><code>jquery-ui dialog box</code></a>. </p>
<p><strong>The problem is that when I close the dialog box and then I click on the link that triggers it, it does not pop-up again unless I refresh the page.</strong> </p>
<p>How c... | <p>You're actually supposed to use <code>$("#terms").dialog({ autoOpen: false });</code> to initialize it.
Then you can use <code>$('#terms').dialog('open');</code> to open the dialog, and <code>$('#terms').dialog('close');</code> to close it.</p>
| <p>The jQuery documentation has a link to this article
'<a href="http://blog.nemikor.com/2009/04/08/basic-usage-of-the-jquery-ui-dialog/" rel="nofollow noreferrer">Basic usage of the jQuery UI dialog</a>'
that explains this situation and how to resolve it.</p>
| 47,879 |
<p>I'd like to store a properties file as XML. Is there a way to sort the keys when doing this so that the generated XML file will be in alphabetical order? </p>
<pre><code>String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
try {
FileOutputStream xmlStream = new ... | <p>Here's a quick and dirty way to do it:</p>
<pre><code>String propFile = "/path/to/file";
Properties props = new Properties();
/* Set some properties here */
Properties tmp = new Properties() {
@Override
public Set<Object> keySet() {
return Collections.unmodifiableSet(new TreeSet<Object>(super.... | <p>Why do you want the XML file to be sorted in the first place? Presumably, there is another piece of code that reads the file and puts the data in another Properties object. Do you want to do this so you can manually find and edit entries in the XML file?</p>
| 7,792 |
<p>I have a body of text that I have to scan and each line contains at least 2 and sometimes four parts of information. The problem is that each line can be 1 out of 15-20 different actions.</p>
<p>in ruby the current code looks somewhat like this:</p>
<pre>
text.split("\n").each do |line| #around 20 times..
......... | <p>I would suggest </p>
<ul>
<li><a href="http://spirit.sourceforge.net/" rel="nofollow noreferrer">Boost Spirit</a> or </li>
<li><a href="http://www.antlr.org/" rel="nofollow noreferrer">Antlr</a> if the grammar is complex; </li>
<li><a href="http://www.boost.org/doc/libs/1_37_0/doc/html/xpressive.html" rel="nofollow... | <p>Do the regular expression matches ever overlap? That is, when two or more regexes match the same line, do they always match different parts of the line (no overlap)?</p>
<p>If the matches never overlap, run your search using one regular expression that combines the 15 regexes you have now:</p>
<pre><code>regex1|r... | 39,037 |
<p>I'm currently looking for ways to create automated tests for a <a href="https://jsr311.dev.java.net/" rel="noreferrer">JAX-RS</a> (Java API for RESTful Web Services) based web service. </p>
<p>I basically need a way to send it certain inputs and verify that I get the expected responses. I'd prefer to do this via JU... | <p><a href="http://jersey.java.net/" rel="noreferrer">Jersey</a> comes with a great RESTful client API that makes writing unit tests really easy. See the unit tests in the examples that ship with Jersey. We use this approach to test the REST support in <a href="http://activemq.apache.org/camel/" rel="noreferrer">Apache... | <blockquote>
<blockquote>
<p>An important thing to do is to independently test your business logic</p>
</blockquote>
</blockquote>
<p>I certainly would not assume that the person who wrote the JAX-RS code and is looking to unit test the interface is somehow, for some bizarre, inexplicable reason, oblivious to ... | 14,751 |
<p>Why should I choose to use one instead of the other and in which cases?</p>
<p>I mainly focus on desktop applications and personally speaking I do find the humble dialog box more easy and natural to use.</p>
| <p>In MVC, you would still use your "humble" dialog. Except all the business logic for it would be farmed off to another class somewhere else.</p>
<p><a href="http://en.wikipedia.org/wiki/Model-view-controller" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Model-view-controller</a></p>
<p>You need to weight ... | <p>There is no simple answer.</p>
<p>You should use whatever will make your life easier.</p>
<p>If dialog is really simple, and you <em>know</em> for sure it is going to stay that way, go with humble dialog.</p>
<p>If you have something more complex, like multiple view presentations of the same data, or you know you... | 28,377 |
<p>I have custom coded several enterprise applications for mid to large organizations to use internally (some with a minimal external footprint). I now have plans for a web project that may (hopefully) see a large userbase with more daily traffic than my previous projects have ever attained. Obviously I want my desig... | <p>The <a href="http://highscalability.com/" rel="nofollow noreferrer">High Scalability</a> blog is good. You can look at some of their examples that go over the physical parts of large sites. I would say the common first level physical scaling technique would be a load balancer. That is pretty easy but at the simplest... | <p>It's hard to give exact answer without knowing something about what technologies you plan to use. The approach to the application can't be completely unaware of planned physical infrastructure if scaling is a major driver.</p>
<p>Caching would have to be a big concern. Also ways to expand the hardware where your d... | 29,648 |
<p>I'm able to connect to and read an excel file no problem. But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?</p>
| <p>I believe you have to set the option in your connect string to force textual import rather than auto-detecting it.</p>
<pre><code>Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\path\to\myfile.xlsx;
Extended Properties=\"Excel 12.0 Xml;IMEX=1\";
</code></pre>
<p>Your milage may vary depending on the vers... | <p>I think the way to do this would be to format the source excel file such that the column is formatted as Text instead of General. Select the entire column and right click and select format cells, select text from the list of options.</p>
<p>I think that would explicitly define that the column content is text and sh... | 4,289 |
<p>I wrote a C++ project in VS2005, and used lots of STL container with its plus-in STL. However, I found STL in VS2005 does not have a hash_map in it, I want to use SGI hash_map. How can I change my project to use SGI STL?</p>
<p>Thanks for Brian's method, it works! And it's simple.</p>
| <p>VS2005 does have a hash_map:</p>
<pre><code>#include <hash_map>
stdext::hash_map
</code></pre>
<p>If you still want to though you can <a href="http://www.sgi.com/tech/stl/download.html" rel="nofollow noreferrer">download the sgi stl here</a>. You should be able to just set the include directory to the sgi l... | <p>I do not know if VS2005 has TR1, but if it has (or if you later decide to use another compiler which has it), you can use <code>unordered_map</code>:</p>
<pre><code>#include <tr1/unordered_map>
std::tr1::unordered_map mymap;
</code></pre>
<p>Also, for completeness, GCC (which used to have <code><hash_map&... | 32,172 |
<p>I have just received and bypassed a problem with LightWindow and IE7 where, on page load, it throws a JavaScript error on line 444 of <code>lightwindow.js</code>, claiming that the <code>object does not support this property or method</code>. Despite finding various postings on various forums, no Google result I cou... | <p>Instead of the try..catch maybe you could try using </p>
<pre><code>if( this && this._getGalleryInfo )
{
//use the function
}
</code></pre>
<p>you could also check in the same way <strong>this.element.rel</strong> ( <code>if(this && this.element && this.element.rel)</code> ... ) before... | <p>I had the same problem with Lightwindow 2.0, IE6, IE7, IE8 (beta); I resolved in the following way for IE6, IE7, IE8 (beta).</p>
<p>Instead of:<br/>
<code>if(gallery = this._getGalleryInfo(link.rel))</code><br/>
I put on lines 443 and 1157:<br/>
<code>gallery = this._getGalleryInfo(link.rel)</code><br/>... | 6,333 |
<p>What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I've seen people <em>insist</em> that every <code>if</code> statement is followed by a brace block (<code>{...}</code>).</p>
<p>I'm interes... | <p>A few of my personal favorites:</p>
<p>Strive to write code that is <a href="http://www.parashift.com/c++-faq-lite/const-correctness.html" rel="noreferrer">const correct</a>. You will enlist the compiler to help weed out easy to fix but sometimes painful bugs. Your code will also tell a story of what you had in m... | <p>make sure you indent properly</p>
| 8,565 |
<p>I'm developing a C# assembly which is to be called via COM from a Delphi 7 (iow, native win32, not .net) application.</p>
<p>So far, it seems to work. I've exported a TLB file, imported that into my Delphi project, and I can create my C# object and call its functions.</p>
<p>So that's great, but soon I'm going to ... | <p>In the VS2008 project properties page, on the Debug tab, there's an option to set a different Start Action.</p>
<p>This can be used to run an external program (e.g. your Delphi app) when you press F5.</p>
| <p>You can just attach to the native application and see breakpoint, view stacks, watches etc. normally. You'll need to attach after the COM object is created.</p>
<p>I put a Afx MsgBox when the object is created to stop the application's flow and then attach the debugger.</p>
| 15,435 |
<p>Very simple question, is there any cloud server enviroments avaliable these days for us .NET guys that rivals Amazons ec2? </p>
<p>EDIT: </p>
<p>PDC 2008 looks like there are some very interesting info, and only 4 days 2 hours to wait :-). Looks like I need to get saving fast for the conference fee though. </p>
| <p>Hold your breath for <a href="http://www.microsoftpdc.com/" rel="nofollow noreferrer">PDC 2008</a> and you'll see. Also Amazon's EC2 service support for Windows images is in Beta. <a href="http://aws.typepad.com/aws/2008/10/coming-soon-ama.html" rel="nofollow noreferrer">AWS Windows Support Blog Post</a></p>
<p><... | <p>Check out <a href="http://www.microsoft.com/sql/dataservices/default.mspx" rel="nofollow noreferrer">Sql Server Data Services</a> and make sure to tune in to PDC 2008 next week. </p>
| 28,221 |
<p>How do I execute the following shell command using the Python <a href="https://docs.python.org/library/subprocess.html" rel="noreferrer"><code>subprocess</code></a> module?</p>
<pre><code>echo "input data" | awk -f script.awk | sort > outfile.txt
</code></pre>
<p>The input data will come from a string, so I don... | <p>You'd be a little happier with the following.</p>
<pre><code>import subprocess
awk_sort = subprocess.Popen( "awk -f script.awk | sort > outfile.txt",
stdin=subprocess.PIPE, shell=True )
awk_sort.communicate( b"input data\n" )
</code></pre>
<p>Delegate part of the work to the shell. Let it connect two proc... | <p><strong>EDIT:</strong> <code>pipes</code> is available on Windows but, crucially, doesn't appear to actually <em>work</em> on Windows. See comments below.</p>
<p>The Python standard library now includes the <code>pipes</code> module for handling this:</p>
<p><a href="https://docs.python.org/2/library/pipes.html" r... | 37,762 |
<p>Is there a way to have the compile deduce the template parameter automatically?</p>
<pre><code>template<class T>
struct TestA
{
TestA(T v) {}
};
template<class T>
void TestB(T v)
{
}
int main()
{
TestB (5);
}
</code></pre>
<p>Test B works fine, however when i change it to TestA it will not c... | <p>No, there isn't. Class templates are never deduced. The usual pattern is to have a <code>make_</code> free function:</p>
<pre><code>template<class T> TestA<T> make_TestA(T v)
{
return TestA<T>(v);
}
</code></pre>
<p>See <code>std::pair</code> and <code>std::make_pair</code>, for example.</p>
... | <p>Sunlight is right, but if I may ask you a question: is that really a problem in your code. I mean:</p>
<pre><code>TestA(5);
</code></pre>
<p>Would become</p>
<pre><code>TestA<int>(5);
</code></pre>
<p>As long as it's only one template argument, it's not that bad, IMHO. It's not like you can get around typi... | 36,223 |
<p>One of the things that has been talked about a few times on the podcast is whether menu items should always be enabled to prevent "WHY ISN'T THIS AVAILABLE!" frustration for the end user.</p>
<p>This strikes me as a good idea, but then there's the issue of communicating the lack of availability (and the reason why)... | <p>One thing I've seen a printer manufacturer do with their printer properties dialog is to have a little help baloon icon beside disabled items that display a tooltip when hovered over.</p>
<p>Another thing you can do with disabled items is to add in parenthesis why it's disabled or what the user would have to do to ... | <p>Joel has a post on that <a href="http://www.joelonsoftware.com/items/2008/07/01.html" rel="nofollow noreferrer">http://www.joelonsoftware.com/items/2008/07/01.html</a> which might be a good place to start thinking about this.</p>
| 3,959 |
<p>I am not a mathematician. I enjoy a good math puzzle, but I admit my weaknesses whole heartedly. That said, I've always had an interest in Neural Networks, and while I understand them enough to implement them from scratch, I hit a wall when I need to understand any concept that I can only find mathematic proofs for.... | <p>Another alternative is a non-math, non-programming explanation. The book <a href="https://rads.stackoverflow.com/amzn/click/com/1558607838" rel="noreferrer" rel="nofollow noreferrer">Blondie24: Playing at the Edge of AI</a> contains a really great explanation of neural networks. It's about a checkers-playing AI de... | <p>You need a bit of understanding in either Pascal or Delphi but <a href="http://library.thinkquest.org/C007009/introduction/preface/preface.html" rel="nofollow noreferrer">this overview</a> from ThinkQuest is pretty helpful from a programming stand-point. It also explains some of the difficulties and why the mathemat... | 40,294 |
<p>Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value</p>
<pre><code>Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1)
</code></pre>
<p>WHERE....</p>
<p><code>DataCache.Tags</code> is an array of cu... | <p>Your code is currently checking whether the count is <em>exactly</em> one.</p>
<p>The equivalent of EXISTS in LINQ is <a href="http://msdn.microsoft.com/en-us/library/system.linq.queryable.any.aspx" rel="noreferrer">Any</a>. You want something like:</p>
<pre><code>Return DataCache.Tags.Any(Function(tag) tag.FldTag... | <p>Many Thanks for the response.</p>
<p>Your code did not work. Then I realised that I was comparing to an array value so it would be case sensitive. </p>
<p>However glad I asked the question, as I found a better way than mine.</p>
<p>Many thanks again !</p>
| 48,636 |
<p>I'm an end-user of one of my company's products. It is not very suitable for integration into Spring, however I am able to get a handle on the context and retrieve the required bean by name. However, I would still like to know if it was possible to inject a bean into this class, even though the class is not managed... | <p>You can do this:</p>
<pre><code>ApplicationContext ctx = ...
YourClass someBeanNotCreatedBySpring = ...
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(
someBeanNotCreatedBySpring,
AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT, true);
</code></pre>
<p>You can use <code>@Autowired</code> and so ... | <p>Be careful that in oldest version of Spring, there is thread-safe problem with bean factory <a href="http://jira.springframework.org/browse/SPR-4672" rel="nofollow noreferrer">http://jira.springframework.org/browse/SPR-4672</a></p>
| 39,977 |
<p>I have a class in system-C with some data members as such: </p>
<pre><code>long double x[8];
</code></pre>
<p>I'm initializing it in the construction like this:</p>
<pre><code>for (i = 0; i < 8; ++i) {
x[i] = 0;
}
</code></pre>
<p>But the first time I use it in my code I have garbage there.</p>
<p>Becau... | <p>The trick is to combine a <code>UNION</code> with a literal string to determine the type of 'object' returned. In most (?) cases, UNION ALL will be more efficient, and should be used unless duplicates are required in the sub-queries. The following pattern should suffice:</p>
<pre><code> SELECT "group" type, name
... | <p>If you use "UNION ALL" then the db doesn't try to remove duplicates - you won't have duplicates between the two queries anyway (since the first column is different), so UNION ALL will be faster.<br>
(I assume that you don't have duplicates inside each query that you want to remove)</p>
| 8,024 |
<p>In an aspx page I get the Windows username with the function <code>Request.LogonUserIdentity.Name</code>. This function returns a string in the format "domain\user".</p>
<p>Is there some function to only get the username, without resorting to the <code>IndexOf</code> and <code>Substring</code>, like this?</p>
<pre... | <p>I don't believe so. I have got the username using these methods before-</p>
<pre><code>var user = System.Web.HttpContext.Current.User;
var name = user.Identity.Name;
var slashIndex = name.IndexOf("\\");
return slashIndex > -1
? name.Substring(slashIndex + 1)
: name.Substring(0, name.IndexOf("@"));
... | <p>I was suggesting to use regexpes but they would be overkill.
[System.String.Split](<a href="http://msdn.microsoft.com/en-us/library/b873y76a(VS.80).aspx)" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/b873y76a(VS.80).aspx)</a> do the job.</p>
<pre><code>string[] parts= username.Split( new char[]... | 42,788 |
<p>I have a 3d printer that uses ABS filament. The software I use will generate vertical supports for my objects before printing that can be easily broken off after they have been used during print to hold sharp angles up that would normally fall.</p>
<p>After breaking off the stints, the print is far from smooth. Is ... | <p>I have a bunch of solutions to this problem but I'm always looking for additional ideas. I usually start by slicing as much as possible off with a hobby knife. The more than can be removed before sanding the better.</p>
<p>For big prints I like big <a href="http://rads.stackoverflow.com/amzn/click/B001449TPS">gener... | <p>I've noticed if I'm printing too close too the bed or if the bed isn't level to nozzle across the whole bed the supports will leave marks on the print where the print was 'smushed' by the nozzle being slightly closer on that side. Also, in Simplify3d you can increase the vertical and horizontal distance between the ... | 109 |
<p>Why was C# designed this way?</p>
<p>As I understand it, an interface only describes behaviour, and serves the purpose of describing a contractual obligation for classes implementing the interface that certain behaviour is implemented.</p>
<p>If classes wish to implement that behavour in a shared method, why shoul... | <p>Assuming you are asking why you can't do this:</p>
<pre><code>public interface IFoo {
void Bar();
}
public class Foo: IFoo {
public static void Bar() {}
}
</code></pre>
<p>This doesn't make sense to me, semantically. Methods specified on an interface should be there to specify the contract for interactin... | <p>When a class implements an interface,it is creating instance for the interface members. While a static type doesnt have an instance,there is no point in having static signatures in an interface.</p>
| 32,349 |
<p>I have around 25 worksheets in my workbook (Excel spreadsheet).
Is there a way I can protect all the 25 worksheets in single click ? or this feature is not available and I will have to write a VBA code to accomplish this. I need very often to protect all sheets and unprotect all sheets and doing individually is time... | <p>I don't believe there's a way to do it without using VBA. If you are interested in a VBA solution, here is the code:</p>
<pre><code>Dim ws as Worksheet
Dim pwd as String
pwd = "" ' Put your password here
For Each ws In Worksheets
ws.Protect Password:=pwd
Next ws
</code></pre>
<p>Unprotecting is virtually the... | <p>You can protect the workbook rather than each sheet and this will stop changes being made across the entire workbook</p>
| 23,245 |
<p>I'm building a .NET 3.5 web app and I am thinking about all the fundamental issues as I work through the project, like monitoring, exception handling, the lot.</p>
<p>The app will obviously be small in size when it is rolled out because it won't have a high load until the site is heavily promoted (lines of code/cyc... | <p>You will probably find it easier to run a second server running Linux than to shoe horn nagios and company into an environment that they were not developed for.</p>
<p>If you do insist on trying to run them in Windows, and if you have lots and lots of problems, <em>please</em> resist the urge to badmouth these prod... | <p>Rather than having an additional hardware server, you could use VMWare or VirtualBox for Windows, host a small Linux VM and install Nagios on it. It is pretty straight forward and the Nagios install is simple for DEB and RPM based distros (and others too presumably, but not sure).</p>
<p>//Nicholas</p>
| 29,921 |
<p>I'm currently working in a piece of code where both logic and data access are present in the GUI classes. Obviously, I would like to improve on this situation.</p>
<p>The current structure is basically:</p>
<ul>
<li>Big ball of mud</li>
</ul>
<p>The ultimate goal is to achieve a DDD-like structure:</p>
<ul>
<li>... | <p>Never attempt "Big Bang". It almost always blows in your face, since it's a high-risk, desperate measure when everything else has failed.</p>
<p>Divide and conquer: This works well ... if your world has only two sides. In real software, you have to conquer so many fronts at the same time, you can rarely afford to l... | <p>Starting with a clean new architecture and moving the old peices of code into this new architecture piece by piece and refactoring it to suit the new arch would be a good option. I think a bottom up approach when moving the functions would be good.</p>
| 42,781 |
<p>I have 3 tables in database shown below. And I want to make a report just like shown link below. How can I do it with datagrid or datalist? Which one is the best chois? I have tried to do it for a week. </p>
<p><img src="https://i.stack.imgur.com/uZtmk.jpg" alt="http://img123.imageshack.us/my.php?image=61519307xx5.... | <p>What version of SQL are you running? Using PIVOT might be a quick way to get the data into the form you want, and then you can use the generic DataGrid to just display the data in it's (almost) "raw" form - that is, the way the data is presented by the SQL server. You could then think of the DataGrid more like a s... | <p>Use nested Repeaters Control. The outer repeater will repeat Companies and the inner will repeat Products. </p>
| 43,182 |
<p>I'm trying to make a webpage that allows the uploading of multiple files at the same times. I will limit the file extensions to the most common images like JPG, JPEG, PNG and GIF.</p>
<p>I've done some research on this and everywhere I look it's flash this and flash that.</p>
<p>I don't want to use flash really. E... | <p>You can keep adding 'file' inputs but use a name of something like 'upload[]'</p>
<pre><code><input type="file" name="upload[]">
</code></pre>
<p>Then in $_FILES['upload'] you will have an array of files you can loop over like </p>
<pre><code>foreach ($_FILES['upload'] as $file) {
echo $file['size'];
}
... | <p>In using JavaScript to add new upload fields, you could also have JavaScript update some "hidden" input field with the number of upload fields in the form. That way, once you click Submit, that hidden value should be submitted and it will be trivial to parse out the $_FILES array for all the uploaded files.</p>
| 34,854 |
<p>What methods to use a database from Clojure are there?</p>
<p>I know from Clojure you can do anything you can with Java, but that means that I may end up using something overly complicated (like Hibernate) which clashes with Clojure simplicity. Any recommendations or comments?</p>
| <p><a href="http://sourceforge.net/projects/clojure-contrib" rel="noreferrer">clojure-contrib</a> has an sql library which is a thin wrapper around JDBC (java.sql.DriverManager). The test file that comes with it has some examples of its usage.</p>
| <p>You could also try CLJ-Record, <a href="https://github.com/duelinmarkers/clj-record" rel="nofollow">https://github.com/duelinmarkers/clj-record</a></p>
| 37,635 |
<p>Coming from <code>J2ME</code> programming are there any similarities that would make it easy to adapt to <code>Android API</code>. Or is <code>Android API</code> completely different from the <code>J2ME</code> way of programming mobile apps. </p>
| <p>Actually the Android API is much more powerful than the J2ME.</p>
<p>It is much easier to create an application for the Android.</p>
<p>Using the J2ME you are limited to simple forms due to the absent of swing-like libraries (though now there exists a library called LWUIT, avoiding the need to recreate from scratc... | <p>Well, you may not actually need to adapt.</p>
<p>There is a good chance that a J2ME stack will become available for Android before long since Android is not supposed to become as restrictive of third-party runtimes as the iPhone.</p>
<p>I know one guy who has been working on just that:
<a href="http://justanapplic... | 9,031 |
<p>Say your company is willing to sponsor the fees for taking programming certification examination. What is the best aproach to implement this?</p>
<p>I would say if the programmer passes the exam at the first try, it shoud be fully sponsored. </p>
<p>If the programmer doesn't pass the first try, the 2nd exam should... | <p>For optional certification:
At our company, you must receive a pass to get any sort of compensation. Anything below, and you get nada. If you fail the first two times and pass the 3rd time, you still pay for the first two times...but the company will pay for the third.</p>
<p>For required certification:
Company pay... | <p>Sponsor the first time regardless, that includes the necessary training.</p>
<p>Failure or success of the exam is of secondary importance comapred to the training, many companies often require staff to be regularly trained too, so its not much of a cost in the first place.</p>
<p>Taking the exam is also up to the ... | 14,348 |
<p>Has anyone had good experiences with any Java libraries for Graph algorithms. I've tried <a href="http://www.jgraph.com/jgraph.html" rel="noreferrer">JGraph</a> and found it ok, and there are a lot of different ones in google. Are there any that people are actually using successfully in production code or would reco... | <p>If you were using JGraph, you should give a try to <a href="http://jgrapht.org/" rel="noreferrer">JGraphT</a> which is designed for algorithms. One of its features is visualization using the JGraph library. It's still developed, but pretty stable. I analyzed the complexity of JGraphT algorithms some time ago. Some... | <p>If you are actually looking for Charting libraries and not for Node/Edge Graph libraries I would suggest splurging on Big Faceless Graph library (<a href="http://big.faceless.org/products/graph/" rel="nofollow noreferrer">BFG</a>). It's way easier to use than JFreeChart, looks nicer, runs faster, has more output op... | 7,470 |
<p>How can I get the start and end positions of all matches using the <code>re</code> module? For example given the pattern <code>r'[a-z]'</code> and the string <code>'a1b2c3d4'</code> I'd want to get the positions where it finds each letter. Ideally, I'd like to get the text of the match back too.</p>
| <pre><code>import re
p = re.compile("[a-z]")
for m in p.finditer('a1b2c3d4'):
print(m.start(), m.group())
</code></pre>
| <p>note that the span & group are indexed for multi capture groups in a regex</p>
<pre><code>regex_with_3_groups=r"([a-z])([0-9]+)([A-Z])"
for match in re.finditer(regex_with_3_groups, string):
for idx in range(0, 4):
print(match.span(idx), match.group(idx))
</code></pre>
| 31,134 |
<p>Is there any way I can detect when my page has been set as the user's homepage in their browser?</p>
<p>I'm most interested in something in javascript, but I'd be happy to hear about other approaches as well.</p>
<p><strong>Edit</strong>: I'm not looking for anything sneaky. I'm wondering if there is anything tha... | <p>There isn't likely to be a foolproof method, as that's an intrusion into the privacy of the user. </p>
<p>One thing that comes to mind is checking for a referrer. If the user arrived at your page without following a link, they a) typed the url, b) followed a bookmark, or c) have your page set as their homepage. ... | <p>Simple solution, you shouldn't be checking if you or anyone else's site is set as the user's homepage. If they want it as their homepage, they'll make it so. </p>
<p>However, if you've got some Javascript that will check their email and see if they've sent links to your site to their friends or colleagues, I'd be... | 30,439 |
<p>What we are looking for is: while compiling the same configuration, say Release|Win32, is there a way to only do the postbuild steps sometimes. Like, if I am on a dev machine do all the post-build steps or if I am on a build server then don't do them. Or is the only way to accomplish this is by implementing a new co... | <p>You could use environment variables in the post build script. Something like this:</p>
<pre><code>if NOT %ComputerName% == DEVMACHINENAME GOTO end
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ngen "$(TargetPath)"
:end
</code></pre>
| <p>If you don't like to have a separate build configuration (which I think would make most sense) you could e.g. define an environment variable on your build server which you then can test for in you post-build script.</p>
| 42,890 |
<p>Hi i want to write a game with a main game form and lot of other normal forms. What is the best way to manage update-paint cycle in that case?</p>
<p>Should the game form paint loop only should be overriden? or should i do an application.do events() in the main method?</p>
<p>Please guide me regarding this. i am n... | <p>Your logic thread should be separate from the form, so you won't need DoEvents(). If you're using GDI+, then you should force an Update() on a loop. Windows Forms doesn't do double buffering very well, so depending on how sophisticated your graphics will be you might have some difficulties with flicker.</p>
<p>My... | <p>If you are making a game, you should be looking into <a href="http://msdn.microsoft.com/en-us/magazine/cc164112.aspx" rel="nofollow noreferrer">DirectX</a>, <a href="http://csgl.sourceforge.net/" rel="nofollow noreferrer">OpenGL</a>, or <a href="http://xna101.spaces.live.com/" rel="nofollow noreferrer">XNA</a>.</p>
| 10,006 |
<p>For example if I have an Enum with two cases, does it make take more memory than a boolean? Languages: Java, C++</p>
| <p>In Java, an <a href="http://download.oracle.com/javase/tutorial/java/javaOO/enum.html" rel="noreferrer"><code>enum</code> is a full-blown class</a>:</p>
<blockquote>
<p>Java programming language enum types
are much more powerful than their
counterparts in other languages. The
enum declaration defines a clas... | <p>No, an enum is generally the same size as an int, same as boolean.</p>
| 17,307 |
<p>My application uses 2.0. At some point in the future I may want to start using newer features added in later framework versions. Should I wait until then? Or are there advantages to updating to the latest .NET 3.5 now?</p>
<p>I suppose by the time I am ready for next spring's release 4.0 will be out. Perhaps I ... | <p>In my opinion, you should ship with what your app needs. Otherwise you are making your install longer for no reason and as you noted using your customer's HD space again essentially for no reason.</p>
| <p>I appreciate the new language features in .NET 3.5 but until you're making use of them I would avoid upgrading to the latest runtime as it is a larger file / install that your users may have to deal with.</p>
| 8,143 |
<p>I'm currently working through an assignment that deals with Big-O and running times. I have this one question presented to me that seems to be very easy, but I'm not sure if I'm doing it correctly. The rest of the problems have been quite difficult, and I feel like I'm overlooking something here.</p>
<p>First, you ... | <p>It wouldn't make sense if you had O(n^3) but you are not using big O notation in your example. I.e. if you had O(n^3) you would know the complexity of your algorithm but you would not know the exact number of operations as you said. </p>
<p>Instead it looks as though you are given the exact number of operations t... | <p>Your 50*n^3 data is called "running time", but that's because the model used for speed evaluations assumes a machine with several basic operations, where each of these takes 1 time unit.</p>
<p>In you case, running the algorithm takes 50*500^3 time units. On computer A each time unit is 1ms, and on computer B 2ms.<... | 26,657 |
<p>I have some constants that represent the valid options in one of my model's fields. What's the best way to handle these constants in Ruby?</p>
| <p>You can use an array or hash for this purpose (in your environment.rb):</p>
<pre><code>OPTIONS = ['one', 'two', 'three']
OPTIONS = {:one => 1, :two => 2, :three => 3}
</code></pre>
<p>or alternatively an enumeration class, which allows you to enumerate over your constants as well as the keys used to assoc... | <p>You can also group constants into subjects, using a module -- </p>
<pre><code>class Runner < ApplicationRecord
module RUN_TYPES
SYNC = 0
ASYNC = 1
end
end
</code></pre>
<p>And then have,</p>
<pre><code>> Runner::RUN_TYPES::SYNC
=> 0
> Runner::RUN_TYPES::ASYNC
=> 1
</code><... | 33,318 |
<p>while exploring jQuery I came up with the following weird script. I don't see myself doing this really however concatenating strings to achieve a variable name is not unusual in JavaScript. </p>
<p>Any feedback welcome.</p>
<pre><code>...
<script type="text/javascript">
var a = 'y';
$(doc... | <p>Short answer is no, there aren't side-effects. Your example is quirky, but as you said you were just exploring to see what you could do. I have used string concatenation and function value returns inside jQuery selectors before, it can be a useful technique for managing sets of related elements which reside in dif... | <p>In my opinion its unreadable, unmaintainable...anything like that should be avoided. Imagine you joined a new company and they put you in front of a whole bunch of js/jquery code that looked like that!!</p>
<p>P.S you should use addClass to change the color. I would rather change a css class after all it is a style... | 37,246 |
<p>I have seen a few different in-process SQL databases for .NET (including one from Microsoft), but either they do not work under medium trust (ASP.NET) or the documentation/websites don't even talk about.</p>
<p>What experiences have you had with in-process databases in general, and do you know of any that work unde... | <p>Try <a href="http://vistadb.net/" rel="nofollow noreferrer">VistaDB</a>, it works in medium trust configuration, and can be deployed in the application's <strong>bin</strong> file. </p>
<p>It also supports ASP.Net Membership API, 100% .Net, encryption, uses SQL Server syntax, etc.</p>
| <p>Lots of them will work (I <em>know</em> SQLite does) when the assemblies are stored in the GAC.</p>
<p>I assume you're on some form of shared hosting to experience the woes of Medium Trust. Most providers are understanding enough to add binaries to the global cache on the basis that they're third party and look fai... | 26,557 |
<p>I need to set my process to run under 'nobody', I've found os.setuid(), but how do I find <code>uid</code> if I have <code>login</code>?</p>
<p>I've found out that uids are in /etc/passwd, but maybe there is a more pythonic way than scanning /etc/passwd. Anybody?</p>
| <p>You might want to have a look at the <a href="http://docs.python.org/library/pwd.html" rel="noreferrer">pwd</a> module in the python stdlib, for example:</p>
<pre><code>import pwd
pw = pwd.getpwnam("nobody")
uid = pw.pw_uid
</code></pre>
<p>it uses /etc/passwd (well, technically it uses the posix C API, so I suppo... | <p>Never directly scan <code>/etc/passwd</code>.</p>
<p>For instance, on a Linux system I administer, the user accounts are not on <code>/etc/passwd</code>, but on a LDAP server.</p>
<p>The correct way is to use <code>getpwent</code>/<code>getgrent</code> and related C functions (as in @TFKyle's answer), which will g... | 37,590 |
<p>I have an interesting situation where I need to deploy an ASP.NET MVC app to a (pseudo-boss's) local desktop machine so they can run it locally for data entry purposes. What would be the best way to get the app running on a vista machine without Visual Studio installed? </p>
<p>Ideally, It would be a one click th... | <p>You need IIS installed, which should be available for Vista. Then just set up a working directory and put your app there, it's not 1 click but maybe.,.. 5.. :)</p>
| <p>Could you use something like UltiDev Cassini: <a href="http://www.ultidev.com/products/Cassini/" rel="nofollow noreferrer">http://www.ultidev.com/products/Cassini/</a> and build your own installer to set everything up for your user?</p>
| 49,979 |
<p>I've written my first C# iterator today. Woohoo.</p>
<p>Interestingly, it has side effects. My iterator filters out invalid files from a directory and returns a sequence of valid files to process. Wheneve it encounters an invlaid file, it moves it to another directory.</p>
<p>I tried implementing it as a LINQ quer... | <p>I'd say it's <em>generally</em> a bad idea to have side-effects in an iterator, but it's not a complete no-no. If you have side-effects, it makes it hard/impossible for callers to work in a purely functional way. This may or may not be a problem depending on your use case.</p>
<p>I suggest you have two ways of gett... | <p>My rule of thumb is if I'm iterating over a collection, no. But in Python, a for loop is often used idiomatically to execute code a certain number of times, in which case I have no problem using it with side-effects.</p>
| 41,445 |
<p>I want to use JavaScript to control an embedded Windows Media Player, as well as access any properties that the player exposes. I've found a few hacky examples online, but nothing concrete. </p>
<p>I really need access to play, pause, stop, seek, fullscreen, etc. I'd also like to have access to any events the playe... | <p>There is an API in Microsoft's developer center, but it will only work if you embed windows media player using active-x.</p>
<p>To "learn" more about the API, check out MSDN: <a href="http://msdn.microsoft.com/en-us/library/dd564034(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/dd56... | <p>There is no open JavaScript library as far as I know for crossbrowser clientside handling of a WMP player.
However, <a href="http://dotupdate.wordpress.com/2007/08/15/using-wmp-and-quicktime-with-silverlight/" rel="nofollow noreferrer">this link</a> should make it quite easy for you to start your own little library.... | 38,388 |
<p>How do I get the physical addresses of my machine in <strong>Java</strong>?</p>
| <p>As of Java 6, java.net.NetworkInterface class now has the method getHardwareAddress()</p>
<p><a href="http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress()" rel="nofollow noreferrer">http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress()</a></p>... | <pre><code>try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}
</code></pre>
| 12,288 |
<p>Is it possible to create custom events in C++? For example, say I have the variable X, and the variable Y. Whenever X changes, I would like to execute a function that sets Y equal to 3X. Is there a way to create such a trigger/event? (triggers are common in some databases)</p>
| <p>This is basically an instance of the Observer pattern (as others have mentioned and linked). However, you can use template magic to render it a little more syntactically palettable. Consider something like...</p>
<pre><code>template <typename T>
class Observable
{
T underlying;
public:
Observable<T>... | <p>Think you should read a little about <a href="http://en.wikipedia.org/wiki/Design_pattern_(computer_science)" rel="nofollow noreferrer">Design Patterns</a>, specifically the <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">Observer Pattern</a>.</p>
<p>Qt from <a href="http://trollte... | 10,343 |
<p>I am trying to load a small sample of records from a large database into a test database.</p>
<p>How do you tell mysqldump to only give you n records out of 8 million?</p>
<p>Thanks</p>
| <p>As skaffman says, use the <strong>--where</strong> option:</p>
<pre><code>mysqldump --opt --where="1 limit 1000000" database
</code></pre>
<p>Of course, that would give you the first million rows from every table.</p>
| <p>mysqldump can be given a SQL query to execute, from which it will take the data for the dump. You can then use the "limit X" clause in your query to restrict the number of rows.</p>
| 16,448 |
<p>I'm interested in the Presentation-Abstraction-Control? (aka Hierarchical-Model-View-Controller (HMVC)) Architectural Pattern for constructing complex user interfaces (GUI or web) and was wondering if anyone was aware of any examples in the wild where I could read the code?</p>
<p>I'm aware of the JavaWorld article... | <p>In the php world, I'm aware of a few methods that might qualify as HMVC. They all allow calling a controller and displaying the results from within a view. The calls can be nested infinitly creating widgets within widgets. </p>
<ul>
<li>Zend Framework: <a href="http://framework.zend.com/manual/en/zend.view.helpers.... | <p>I wrote an HMVC framework in PHP called Alloy:</p>
<p><a href="http://alloyframework.org/" rel="nofollow noreferrer">http://alloyframework.org/</a></p>
<p>It's pretty lightweight and has a modular structure.</p>
| 11,689 |
<p>I have a method that, given an angle for North and an angle for a bearing, returns a compass point value from 8 possible values (North, NorthEast, East, etc.). I want to create a unit test that gives decent coverage of this method, providing different values for North and Bearing to ensure I have adequate coverage t... | <p>First off, you're right, you do <em>not</em> want your test code to reproduce the same calculation as the code under test. Secondly, your second approach is a step in the right direction. Your tests <em>should</em> contain a specific set of inputs with the pre-computed expected output values for those inputs.</p>
... | <p>So I took a software testing class <a href="http://cs.gmu.edu/~offutt/softwaretest/" rel="nofollow noreferrer">link text</a> and basically what you want is to identify the class of inputs.. all real numbers? all integers, only positive, only negative,etc... Then group the output actions. is 360 uniquely different fr... | 32,136 |
<p>How do I check for an open connection in jdbc for oracle database?</p>
<p>Note: <code>conn.isClosed()</code> cannot be used for this.</p>
| <p>Something like:</p>
<pre><code>Statement stmt = null;
ResultSet rs =null;
try {
stmt = conn.createStatement();
// oracle
rs = stmt.executeQuery("SELECT 1 FROM Dual");
// others
// rs = stmt.executeQuery("SELECT 1");
if (rs.next())
return true; // connection is valid
}
catch (SQLException e) ... | <p>See <a href="https://stackoverflow.com/questions/128527/is-there-any-way-to-have-the-jboss-connection-pool-reconnect-to-oracle-when-conne">this</a> posting.</p>
<p>The referenced solutions are similar to the one posted here (quick query against DUAL to validate) but there is also an interesting solution provided by... | 34,626 |
<p>I should probably take this for a forum but figured someone here might know the answer. I'm trying to install sql server 2008 on a home vista machine but it keeps telling 'Restart computer failed' everytime it does a check to make sure pre-reqs are met. I've restarted my computer and even uinstalled/installed .net... | <p>Found this here:
<a href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3762432&SiteID=1" rel="noreferrer">http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3762432&SiteID=1</a></p>
<p>"You can open Regedit, and modify this key"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager"... | <p>Also try removing reboot keys under:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run... | 21,303 |
<p>I am not able to use the breakpoint in Studio with Javascript. I'm able to debug if I use the debugger; </p>
<p>I've seen this <a href="https://stackoverflow.com/questions/163133/breakpoint-not-hooked-up-when-debugging-in-vsnet-2005">Breakpoint not hooked up when debugging in VS.Net 2005</a> question already. I ... | <p>try typing "debugger" in the source where you want to break</p>
| <p>Just type alert function in script for each line or any line, if the alert is not triggered then we can identify the line where its through the error</p>
<pre><code><script type="text/javascript">
$(function() {
//event handler to the checkbox selection change event
$("input[type=checkbox]").change(... | 49,272 |
<p>From index.jsp code, </p>
<pre><code>statement.executeQuery("select * from fus where tester_num like 'hf60' ") ;
</code></pre>
<p>Example I want "hf60" to be a variable(userinput), wherein USER must input/write data from input text then submit and get the data so that the result will be </p>
<pre><code>("select ... | <p>You have access to the request in a <code>JSP</code>. So if your <code>JSP</code> were to be accessed like this:</p>
<pre><code>test.jsp?q=userinput
</code></pre>
<p>You could get to it like this in the <code>JSP</code>:</p>
<pre><code>request.getParameter('userinput');
</code></pre>
<p>You should convert your <... | <p>As tvanfosson said, you should remove all database access code from your view logic (JSP). You should just show the info in your JSP, let the Servlet do all the processing. I also strongly recommend you to use an OMR framework like Hibernate.</p>
| 41,888 |
<p>This is a follow-up to a previous question I had about interfaces. I received an answer that I like, but I'm not sure how to implement it in VB.NET.</p>
<p>Previous question:</p>
<p><a href="https://stackoverflow.com/questions/239909/should-this-property-be-part-of-my-objects-interface">Should this property be pa... | <p>Simply define the getter in one interface, and create a second interface that has both the getter and the setter. If your concrete class is mutable, have it implement the second interface. In your code that deals with the class, check to see that it is an instance of the second interface, cast if so, then call the... | <p>In VB.NET I would implement it this way:</p>
<pre><code>Public Interface ICanBeSecure
ReadOnly Property IsSecureConnection() As Boolean
End Interface
Public Interface IIsSecureable
Inherits ICanBeSecure
Shadows Property IsSecureConnection() As Boolean
End Interface
</code></pre>
| 29,705 |
<p>I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth).</p>
<p>I want to drive it from a scripting language (I'm comfortable with Python and slightly less ... | <p>One way to call C libraries from Python is to use <a href="https://docs.python.org/library/ctypes.html" rel="nofollow noreferrer">ctypes</a>:</p>
<pre><code>>>> from ctypes import *
>>> windll.user32.MessageBoxA(None, "Hello world", "ctypes", 0);
</code></pre>
| <p>For Python, you could compile an extension which links to the DLL, so that in Python you could just import it like a normal module. You could do this by hand, by using a library like Boost.Python, or by using a tool such as SWIG (which also supports Perl and other scripting languages) to generate a wrapper automatic... | 29,573 |
<p>When working on a VS2005 project that involves referencing Microsoft.SharePoint.dll, building the project causes Microsoft.SharePoint.Search.dll to be copied to my bin folder. Why is this? Okay, maybe it's just a bug, but I want to know the mechanism.</p>
<p>[Edit: Copy local is most definitely turned off -- Micros... | <ul>
<li>It's not in the GAC</li>
<li>It's being used by one of the Assemblies you reference (i think Microsoft.Sharepoint.dll references it)</li>
<li>Since you don't reference it, you cannot set Local Copy to FALSE as far as I know</li>
<li>I've changed my build/deployment scripts to just delete it.</li>
</ul>
| <p>Did you try turning off 'Copy Local' in the properties for the reference to Microsoft.SharePoint.dll ?</p>
| 24,163 |
<p>I've just come across this in a WHERE clause:</p>
<pre><code>AND NOT (t.id = @id)
</code></pre>
<p>How does this compare with:</p>
<pre><code>AND t.id != @id
</code></pre>
<p>Or with:</p>
<pre><code>AND t.id <> @id
</code></pre>
<p>I'd always write the latter myself, but clearly someone else thinks diffe... | <p>These 3 will get the same exact execution plan</p>
<pre><code>declare @id varchar(40)
select @id = '172-32-1176'
select * from authors
where au_id <> @id
select * from authors
where au_id != @id
select * from authors
where not (au_id = @id)
</code></pre>
<p>It will also depend on the selectivity of the in... | <p>There will be no performance hit, both statements are perfectly equal.</p>
<p>HTH</p>
| 2,944 |
<p>My form does not go to recipient when submitted! I changed the file mail.tpl.txt to direct to my own email address as a test and I got the email just fine.</p>
<p>Client has checked junk mail folder as well and he is just not getting information.</p>
<p>Below is the form code, followed by the code from mail.tpl.tx... | <p>Your sending a plain text email right now - you should correct the header content type of that email.</p>
<p>Just set it to text/html. There might be more information here:</p>
<ul>
<li><a href="http://www.ietf.org/rfc/rfc2387.txt" rel="nofollow noreferrer">http://www.ietf.org/rfc/rfc2387.txt</a></li>
<li><a href=... | <p>To add the appropiate headers, see:<br>
<a href="http://nl2.php.net/manual/en/function.mail.php" rel="nofollow noreferrer">http://nl2.php.net/manual/en/function.mail.php</a><br>
example 4.<br>
This btw is just Sebastian's aswer with a link.</p>
| 39,369 |
<p>I've been playing around with ASP.NET MVC and had a question. Or maybe its a concern that I am doing this wrong. Just working on a lame site to stretch my wings a bit. I am sorry this question is not at all concise.</p>
<p>Ok, here's the scenario. When the user visits home/index, the page should show a list of ... | <blockquote>
<p>Because I was calling RenderAction()
from a view in Product</p>
<p>...</p>
<p>I do not understand why I needed
to specify the full path of the view.
It would make sense to me for the
relative name to be interpreted
relative to the current view's path
rather than the original controller's
view path</p>
<... | <p>[edit:</p>
<p>I was thinking, you have 2 cases:</p>
<ul>
<li>the Home controller is the only one that ever references Product / Articles List user control</li>
<li>the user controls are shared by several controllers</li>
</ul>
<p>In the first case, the view user controls really belong to the home controller and i... | 34,987 |
<p>In Cocoa, if I want to loop through an NSMutableArray and remove multiple objects that fit a certain criteria, what's the best way to do this without restarting the loop each time I remove an object?</p>
<p>Thanks,</p>
<p>Edit: Just to clarify - I was looking for the best way, e.g. something more elegant than manu... | <p>For clarity I like to make an initial loop where I collect the items to delete. Then I delete them. Here's a sample using Objective-C 2.0 syntax:</p>
<pre><code>NSMutableArray *discardedItems = [NSMutableArray array];
for (SomeObjectClass *item in originalArrayOfItems) {
if ([item shouldBeDiscarded])
... | <p>Iterating backwards-ly was my favourite for years , but for a long time I never encountered the case where the 'deepest' ( highest count) object was removed first. Momentarily before the pointer moves on to the next index there ain't anything and it crashes. </p>
<p>Benzado's way is the closest to what i do now bu... | 13,706 |
<p>Why does Visual studio take so long to delete a file from the solution tree? The app freezes and sits there for what feels like an eternity. </p>
<p>If I delete the file from the file system first, then delete it in the solution it happens instantly.</p>
<p>Is there an option I can set somewhere to avoid this?</p... | <p>I've found that when there is a lot in my Recycle Bin (1000s of files), it takes longer to delete a file in Windows Explorer as well as Visual Studio.</p>
| <p>It may be normal if your project size is very big. We are talking about a <a href="https://stackoverflow.com/questions/163740/aspnet-project-size#164598">50-200 projects solution</a>.</p>
<p>If you have R# installed on your PC try to <a href="http://tech.groups.yahoo.com/group/altdotnet/message/11685" rel="nofollow... | 22,202 |
<p>If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into?</p... | <p>Just an update on this: I decided to go with the <a href="http://en.wikipedia.org/wiki/Decorator_pattern" rel="noreferrer">Decorator pattern</a>. That is, I have one 'generic' table class that implements an <code>IValidateableTable</code> interface (which contains <code>validate()</code> method). Then, I created se... | <p>I think you are really talking about a concept called <a href="http://en.wikipedia.org/wiki/Database_constraints" rel="nofollow noreferrer">constraints</a> in the world of databases. Constraints are how a database guarantees the integrity of the data it contains. It makes much more sense to put this sort of logic in... | 6,806 |
<p>In Jesse Liberty's Learning C# book, he says "Objects of one type can be converted into objects of another type. This is called casting."</p>
<p>If you investigate the IL generated from the code below, you can clearly see that the casted assignment isn't doing the same thing as the converted assignment. In the form... | <p>Absolutely not!</p>
<p>Convert tries to get you an Int32 via "any means possible". Cast does nothing of the sort. With cast you are telling the compiler to treat the object as Int, without conversion.</p>
<p>You should always use cast when you know (by design) that the object is an Int32 or another class that has ... | <p>The difference there is whether the conversion is implicit or explicit. The first one up there is a cast, the second one is a more explicit call to a function that converts. They probably go about doing the same thing in different ways.</p>
| 17,370 |
<p>When I call <code>Response.Redirect(someUrl)</code> I get the following HttpException:</p>
<blockquote>
<p>Cannot redirect after HTTP headers have been sent.</p>
</blockquote>
<p>Why do I get this? And how can I fix this issue?</p>
| <p>According to the MSDN documentation for <code>Response.Redirect(string url)</code>, it will throw an HttpException when "a redirection is attempted after the HTTP headers have been sent". Since <code>Response.Redirect(string url)</code> uses the Http "Location" response header (<a href="http://en.wikipedia.org/wiki... | <p>There are 2 ways to fix this:</p>
<ol>
<li><p>Just add a <code>return</code> statement after your <code>Response.Redirect(someUrl);</code>
( if the method signature is not "void", you will have to return that "type", of course )
as so:</p>
<p>Response.Redirect("Login.aspx");</p>
<p>return;</p></li>
</ol>
<p>Note... | 19,296 |
<p>I've done development in both VB6 and VB.NET, and I've used ADODB objects in VB6 to handle recordset navigation (i.e. the MoveFirst, MoveNext, etc. methods), and I have used ADO.NET to handle queries in a row-by-row nature (i.e For Each Row In Table.Rows ...)</p>
<p>But now I seem to have come to a dilemma. I am n... | <p>There is no need to go back to the bad old days. If you can give a pseudo code example, I can translate to vb.net for you. </p>
<p>This is kind of a generic way to do it. </p>
<pre><code>Dim ds as DataSet
'populate your DataSet'
For each dr as DataRow in ds.Tables(<tableIndex>).Rows
'Do something with th... | <p>In .Net, there are many ways to do this. One that I like is to use a DataReader, which can return multiple recordsets. You can loop through its records using While DataReader.Read.</p>
<p>One of the advantages of using DataReader is that it is a forward-only, read-only object, so it's fast and light-weight.</p>
<p... | 34,371 |
<p>First of all, I'm still new to this 3D printing and I've bought myself a second hand Ender 3 with some mods done to it.</p>
<p>I've successfully printed with PLA in different colors but after a good first layer the print seems like it is skipping lines.</p>
<p>I've already tried to:</p>
<ul>
<li>Change the nozzle</l... | <p>Many questions on 3D Printing SE are answered, at least by me, not with a "this is the problem", but instead, this is how I would analyze it.</p>
<p>Looking at the picture you supplied, there is something strangely periodic about the under-extrusion in the top visible flat layer.</p>
<p>I don't think it is... | <p>I'd suggest running through basic maintenance. Check</p>
<ul>
<li>Is the nozzle clean/unblocked? If not clean it out</li>
<li>Is the nozzle worn? If so, replace it</li>
<li>Is the bowden tube okay in the hot end ? If not, replace, or at least shorten it.</li>
<li>Are your e-steps calibrated correctly?<br />
...... | 1,674 |
<p>Ok I’m so new at Blender. Half the time it’s knowing what question you have to ask to get the answer you need...</p>
<p>I want to make a 3D printable warrior type action figure but I only have one very detailed frontal view. Can I input that image into somewhere and it gives me a 3D model to start from? Like will it... | <p>In short, no. A 2D image has insufficient information to determine a 3D form.</p>
<p>If you want to do this yourself, what you could do is start with the 2D outline in a program like Blender (as 0scar mentioned in a comment), extrude it to make a thin "cardboard cutout", then begin shaping it into three di... | <p>If you only have a 2D photo then as others have already said its not really possible. However if you have the action figure itself you could try a technique called Photogrammetry where you use your phone to take multiple images of the object and then use software to build up a model. Search youtube for guides on Ph... | 2,008 |
<p>I have an SVN repository structure like below. We are using multiple levels under branches for various release maintenance branches, plus a directory for feature branches.</p>
<p>git-svn init seems to work with a single --branches argument, i.e. it seems to expect all of the branches to be in a single location.</p>... | <p>In your config file, set the svn-remotes section to something like:</p>
<pre><code>[svn-remote "svn"]
url = svn://svnserver/repo
fetch = trunk:refs/remotes/trunk
branches = branches/*/*:refs/remotes/*
tags = tags/*:refs/remotes/tags/*
</code></pre>
<p>This should let you grab the nested branches.</... | <p>Would it be feasible to create a <code>git</code> repo for each of the branch subdirectories?</p>
| 32,280 |
<p>I'm using <strong>mysqldump</strong> to replicate a database between accounts on a particular machine. Everything works just great, except when we get to our defined views. Because the dump includes a line like the following ...</p>
<pre><code>/*!50013 DEFINER=`user_a`@`localhost` SQL SECURITY DEFINER */
</code><... | <p>same problem. I solved it that way:</p>
<pre><code>mysqldump -uuser1 -ppassword1 database1 > backup.sql
sed '/^\/\*\!50013 DEFINER/d' backup.sql > backup_without_50013.sql
mysql -u user2 -ppassword2 -D database2 < backup_without_50013.sql
</code></pre>
<p>The interesting thing is the <a href="http://sof... | <p>Run <code>mysqldump</code> with the option <code>"--skip-triggers"</code></p>
| 18,652 |
<p>I have a colleague who insists that his code doesn't need comments, it's "self documenting."</p>
<p>I've reviewed his code, and while it's clearer than code which I've seen others produce, I still disagree that self-documenting code is as complete and useful as well commented and documented code.</p>
<p>He... | <p>In my opinion, any code should be self-documenting. In good, self-documented code, you don't have to explain every single line because every identifier (variable, method, class) has a clear <em>semantic</em> name. Having more comments than necessary actually makes it harder (!) to read the code, so if your colleague... | <p>Self documented code is code that is so clear that a comment would be unnecessary. I'll give a small example:</p>
<pre><code>//iterate from 0 to 100
for(int i=0; i < 100; i++) {
println i
}
</code></pre>
<p>The comment is pretty useless, because the code is clear. Documentation is a good practice, but extra ... | 25,644 |
<p>We get the following error;</p>
<pre><code>The request was aborted: Could not create SSL/TLS secure channel
</code></pre>
<p>while using a <code>WebRequest</code> object to make an <code>HTTPS</code> request. The funny thing is that this only happens after a while, and is temporarily fixed when the application is ... | <p>I seem to recall having this problem last year. I suspect that you aren't closing your WebRequest objects properly, which is why after a certain amount of use it won't allow you to create any new connections.</p>
| <p>It looks like it may be a Conenction: Keep-alive thing: <a href="http://blogs.x2line.com/al/archive/2005/01/04/759.aspx#780" rel="nofollow noreferrer">http://blogs.x2line.com/al/archive/2005/01/04/759.aspx#780</a></p>
| 6,365 |
<p>I am using Cura 4.13.1 as a slicer for my Ender 3 v2 printer.</p>
<p>I want to print a model which I scaled to 400 %. To improve bed adhesion I wanted to add a default raft (Extra Margin = 15 mm). Unfortunately, Cura is not able to slice the model despite being still within the printer's build volume (400 % = 190x20... | <p>The raft still needs to fit on the bed, and it counts as a print, because, it is printed. You want the raft for better adhesion, so that means that you need more contact with the bed. If you’re not, your basically wasting filament. Its kinda logical actually.</p>
| <h2>Adjusted model Dimensions</h2>
<p>The model has the size determined by the base area of the bounding box, in this case, <span class="math-container">$\pu{190 \times 200 mm }$</span>. The raft as told by OP adds 15mm on <strong>all</strong> sides of the model, and thus adds 30 mm in total on both the X and Y dimensi... | 2,223 |
<p>Let's say I want to represent <code>\q</code> (or any other particular "backslash-escaped character"). That is, I want to match <code>\q</code> but not <code>\\q</code>, since the latter is a backslash-escaped backslash followed by a <code>q</code>. Yet <code>\\\q</code> would match, since it's a backslash-escaped... | <p>Updated:
My new and improved Perl regex, supporting more than 3 backslashes:</p>
<pre>/(?<!\\) # Not preceded by a single backslash
(?>\\\\)* # an even number of backslashes
\\q # Followed by a \q
/x;</pre>
<p>or if your regex library doesn't support extended syntax.</p>
<pre>/(?<!\\)(?>\\\\)... | <p>The best solution to this is to do your own string parsing as Regular Expressions don't really support what you are trying to do. (rep @Frank Krueger if you go this way, I'm just repeating his advice)</p>
<p>I did however take a shot at a exclusionary regex. This will match all strings that do not fit your criteria... | 8,051 |
<p>I have a client who is still using Visual Studio 6 for building production systems. They write multi-threaded systems that use STL and run on mutli-processor machines. </p>
<p>Occasionally when they change the spec of or increase the load on one of their server machines they get 'weird' difficult to reproduce error... | <p>Not supported on 64-bit systems, compatibility issues with Vista, and it was moved out of extended support by Microsoft on April 8, 2008</p>
<p><a href="http://msdn.microsoft.com/en-us/vbrun/ms788708.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/vbrun/ms788708.aspx</a></p>
| <p>If they use the STL, they may be interested in the recently-released <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=D466226B-8DAB-445F-A7B4-448B326C48E7&displaylang=en" rel="nofollow noreferrer">feature pack</a>, which includes an implementation of <a href="http://en.wikipedia.org/wiki/Technic... | 23,226 |
<p>We need to handle this event in the base form, regardless of which controls currently have focus. We have a couple of global key commands that need to work regardless of control focus.</p>
<p>This works by handling the PreviewKeyDown event in the form normally. When we add a user control to the form, the event no ... | <p>The hidden menu you are using works fine for shortcuts that are valid menu item shortcuts, but if you want to use any key as a shortcut (such as Page Up/Page Down), you'll need a different trick.</p>
<p>Another way to do this that doesn't involve P/Invoke is to set the <code>Form.KeyPreview</code> property of your ... | <p>This is probably not the best way of doing it, but the first way that comes to mind. </p>
<p>In your forms constructor, after you call InitializeComponent(); do something like this:</p>
<pre><code> foreach (Control control in this.Controls)
{
control.PreviewKeyDown += new Pre... | 33,510 |
<p>How important is it to make a website layout fit on 640 x 480 and 800 x 600 displays? For some time I have been designing with the assumption of <em>at least</em> 1024 x 768, but I haven't been doing it professionally (just on my site which is just a blog that only 10-15 friends read). Does anyone have any non-ane... | <p>I think the general assumption these days is that 1024x768 is acceptable, thats certainly the route I take. A good benchmark is to look at big sites like the <a href="http://www.bbc.co.uk" rel="nofollow noreferrer">BBC</a>, they recently switched to a 1024x768 design. Thats not to say every site has to be that, for ... | <p>Look, Monitors are getting bigger and people are wanting more and more. People like the bigger monitors. The only people that have small monitors would be a shared computer center or some old aged people.</p>
<p>@All, We need to join together as developers and require to only build apps on the 1024x768. If we a... | 18,680 |
<p>Is there a way to identify unused attributes/methods in Visual C++ 2008 Professional? If it's not possible by default, recommendations of 3rd-party tools are also much appreciated.</p>
<p>Thanks,<br>
Florian </p>
<p><strong>Edit:</strong> nDepend only works for .NET assemblies. I'm looking for something that can ... | <p>Try <a href="http://www.gimpel.com/" rel="nofollow noreferrer">PC-Lint</a>. It's pretty good at finding redundant code.
I haven't tried version 9 yet. Version 8 does take some time to configure.
Try the online interactive demo.</p>
| <p><a href="http://www.ndepend.com/" rel="nofollow noreferrer">nDepend</a> will do it, along with cleaning your house and taking the dog for a walk. There's a nagware version available for free. </p>
<p>The following code query language statement will get you a list of unused methods</p>
<pre><code> WARN IF Count >... | 17,926 |
<p>How should a relational database be designed to handle multi-valued attributes ?</p>
<p><strong>edit</strong>: To elaborate: </p>
<p>There are two ways I could think of for doing this -</p>
<ol>
<li>Trying something like putting comma separated values in the field, which appears a bit clumsy.</li>
<li>Create anot... | <p>In conventional relational database design, each row & column must store only one value. </p>
<p>Don't store comma-separated lists or anything wacky like that.</p>
<p>For example, say a sports team has seven members. You could do this:</p>
<pre><code>CREATE TABLE team (
team_id INT PRIMARY KEY,
tea... | <p>Is the relationship one-to-many or many-to-many? With the one-to-many relationship, I recommend a foreign key in the child table (the many) referencing the parent table (the one). With a many-to-many relationship, then your best bet will most probably be a separate table with foreign keys to both parent and child.</... | 36,618 |
<p>I am not a fan of using SQL*PLUS as an interface to Oracle. I usually use <a href="http://sourceforge.net/projects/yasql/" rel="noreferrer">yasql</a>, but it hasn't been updated since 2005 and can do with some improvements. A quick <a href="http://www.google.com/search?q=sql*plus+replacement" rel="noreferrer">Goog... | <p>I presume that you want a low-overhead method of knocking out queries, but want more functions than SQL*Plus provides? Why not use Oracle's <a href="http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html" rel="noreferrer">SQL Developer</a>? It's free.</p>
<p>Install, make a new connecti... | <p>I used my own tool <a href="http://gaiustech.wordpress.com/2011/05/14/ocaml-as-a-sqlplus-replacement/" rel="nofollow">ocimlsh</a> in conjunction with <a href="http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap.html" rel="nofollow">rlwrap</a>. </p>
| 36,345 |
<p>I've a question about KConfig usage. I'm able to write and read settings in my .kde4/share/config/_appname_rc configuration file like that</p>
<pre><code> KConfig basicconf;
KConfigGroup conf = KConfigGroup(basicconf.group("Settings"));
conf.writeEntry("filepath",QString("/path/"));
basicconf.sync();
</code></pr... | <p>First, this:</p>
<p>KConfigGroup conf = KConfigGroup(basicconf.group("Settings"));</p>
<p>can be written more clearly, at least imho, as:</p>
<p>KConfigGroup conf(&basicconf, "Settings");</p>
<p>Also note that "General" is the most common "generic" group name used. Anyways...</p>
<p>You can install a defaul... | <p>Use <a href="http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/namespaceKGlobal.html#f056d0c68c6a17389f084a8112d2d222" rel="nofollow noreferrer">KGlobal::config()</a> to get a pointer to the default KConfig object owned by your app. It automagically refers to the file in $KDEHOME/share/config.</p>
<p><a hre... | 49,313 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.