instruction
stringlengths
0
30k
Why can't a forward declaration be used for a std::vector?
|c++|
If I create a class like so: // B.h #ifndef _B_H_ #define _B_H_ class B { private: int x; int y; }; #endif // _B_H_ and use it like this: // main.cpp #include <iostream> #include <vector> class B; // Forward declaration. ...
Here is an implementation of Bayesian filtering in C#: [A Naive Bayesian Spam Filter for C#][1] (hosted on CodeProject). [1]: http://www.codeproject.com/KB/recipes/BayesianCS.aspx
Exceptions in C++
|c++|exception|
<p>Exceptions in C++ don't need to be catched (no compile time errors) by the calling function. So its up to developer's judgment whether to catch it using try/catch (unlike in Java). </p> <p>Is there a way one can ensure that the exceptions thrown are always caught using try/catch by the calling function?</p>
No; see [A Pragmatic Look at Exception Specifications](http://www.gotw.ca/publications/mill22.htm) for reasons why not. The only way you can "help" this is to document the exceptions your function can throw, say as a comment in the header file declaring it. This is not enforced by the compiler or anything. Use code rev...
**AppDomain.UnhandledException** is an **event**, not a global exception handler. This means, by the time it is raised, your application is already on its way down the drain, and there is nothing you can do about it, except for doing cleanup and error logging. What happened behind the scenes is this: The framework d...
I've just set up Sandcastle again. Try installing it (the May 2008 release) and search for SandcastleGui.exe or something similar (it's in the examples folder or so). Click Add Assembly and add your Assembly or Assemblies, add any .xml Documentation files (the ones generated by the compiler if you enabled that optio...
<p>Follow <a href="http://saftsack.fs.uni-bayreuth.de/~dun3/archives/integrate-xml-code-comments-into-visual-studio-20052008-using-sandcastle-and-html-help-20/150.html">this simple 5 step article</a> and you are pretty much done. As a bonus you can use <a href="http://www.helpware.net/mshelp2/h2viewer.htm">H2Viewer</a>...
User authentication on Resin webserver
|apache|configuration|webserver|resin|caucho|
I'm currently tasked with replacing an Apache + Resin Java web server with a Resin-only configuration. Currently in our apache setup, we use .htaccess and a small user database to provide passwording at a directory level. Does anyone know the equivalent setup when using just Resin as the web server?
If it's just a few tables you could probably script this in your preferred scripting langauge and have it all done by the time it'd take to read all the replies or track down a suitable tool. I would any way. :)
The main application that my division sells does something very similar to provide client customisations (which means that I can't post any source). We have a C# application that loads dynamic VB.Net scripts (although any .Net language could be easily supported - VB was chosen because the customisation team came from a...
We use CruiseControl with NUnit, NCover, FxCop, SVN and some custom tools we wrote ourselves to produce the reports. In my opinion it has proven (over the last few years) to be an excellent combination. It's frustrating that MS restricts *all* of its integration tools to VSTS. Its test framework is as good as NUnit...
[This is the Firebug Lite][1] that @John was referring to that works on IE, Safari and Opera. [1]: http://getfirebug.com/lite.html "Firebug Lite"
Change the width of a scrollbar
|vb.net|
Is it possible to change the width of a scroll bar on a form. This app is for a touch screen and it is a bit too narrow.
The width of the scrollbars is controlled by Windows. Tou can adjust the scrollbar width in Display Properties and it will affect all windows on the terminal.
I will have to check-out Hoard, Google Perftools and jemalloc sometime. For now we are using scalable_malloc from Intel Threading Building Blocks and it performs well enough. For better or worse, we're using C++ on Windows, though much of our code will compile with gcc just fine. Unless there's a compelling reason t...
I believe the simple version is that they drop the server connection and replace it with the P2P connection. Something along the lines of: 1. Machine1 connects to copilot's servers. 2. Machine1 connects to copilot's servers. 3. Machine1 connects to copilot's servers. 4. Machine2 subsequently connects, and ...
There will be such a formula as soon as computers can start generating *all* code themselves. Until then you are stuck with human developers who all have different levels of skill and development speed.
In addition to what Simon said, you may want to read the [CSV how-to guide][1] and make sure your output doesn't run across any of the gotchas. To clarify something Simon said: > Then surround this by quotes if you want Fields that contain doubled up double quotes ("") will need to be completely surrounded wi...
You can use JDeveloper and try to find some tutorials for it (I actually had some from my university). It integrates well with rest of Oracle stack (db and application server). Down site is that although you can download some developers editions to run for personal usage, running Oracle db + Oracle application server +...
cmd defaults to F: drive
|windows|cmd|
When I open cmd on my laptop it is defaulting to the F: drive. This is troubling me does anyone know how it got that way or how to get it back to where it opens to the C: drive by default?
In terms of allocations, it'd be better to look at [this blogpost][1]. It shows in exactly in what circumstances an enumerator is allocated on the heap. [1]: http://blogs.msdn.com/etayrien/archive/2007/03/17/foreach-garbage-and-the-clr-profiler.aspx
quick answer: cmd /k c: long answer to make it "automagical": <http://windowsxp.mvps.org/autoruncmd.htm>
There's no set formula out there that I've seen that would really work. Fogbugz has its monte carlo simulator which has somewhat of a concept for this, but really, experience is going to be your best point of reference. Every developer and every project will be different!
[http://blog.stevienova.com/2007/04/08/change-your-default-cmd-prompt-path/][1] [1]: http://blog.stevienova.com/2007/04/08/change-your-default-cmd-prompt-path/
Generally those variables are stored in the program's memory space, which you should (theoretically) should not be able to access. You'll need to find out how to initiate interprocess communication with the other instances and trade data. Named pipes are one good option, but you might want to start a new stackoverf...
The latest Sun Java VM actually have multiple GC algorithms which you can tweak. The Java VM specifications intentionally omitted specifying actual GC behaviour to allow different (and multiple) GC algorithms for different VMs. For example, for all the people who dislike the "stop-the-world" approach of the default...
If you need to take the curvature of the earth into account, the Great-Circle distance is what you're looking for. The Wikipedia [article][1] probably does a better job of explaining how the formula works than me, and there's also [this][2] aviation formulary page that covers this in detail. The formulas are only th...
If you need to take the curvature of the earth into account, the Great-Circle distance is what you're looking for. The Wikipedia [article][1] probably does a better job of explaining how the formula works than me, and there's also [this][2] aviation formulary page that covers that goes into more detail. The formulas...
You do not need domain admin rights to *look* at the active directory. By default, any (authenticated?) user can read the information that you need from the directory. If that wasn't the case, for example, a computer (which has an associated account as well) could not verify the account and password of its user. ...
Advantage: * Only one place to update your assemblys * You use a little less hard drive space Disadvantage: * If you need to update only one website, you can't. You may end with the other websites in the webserver broken. Recommendation: Leave the GAC to MS and friends. The gigabyte is very cheap now.
I highly recommend [HostRocket][1]. I have been with them for about 6 or 7 years now with multiple domains and have found uptime and database availability flawless. The only reason I'm leaving them is because I'm doing some .NET web apps now and HostRocket is purely LAMP based. But without making things an ongoing a...
AWStats and Webalizer are both good and free (I think both free speech as well as free beer). I generally prefer the look of AWStats - it has a nice modern look whereas Webalizer looks like something created in about 1992. They both give roughly the same information which includes: - Most frequently accessed pa...
I am a big fan of [Thrift][1] an interoperability stack from Facebook. You said they code will probably run on the same machine so it could be overkill but you can still use it. [1]: http://developers.facebook.com/thrift/
I used JNBridge (<http://www.jnbridge.com/jnbpro.htm>) on a relatively simple project where we had a .NET client app using a relatively significant jar file full of business object logic that we didn't want to port. It worked quite nicely, but I wouldn't say we fully exercised the capabilities of JNBridge.
HTML would be the next best choice, ONLY IF you would serve them from a public web server. If you tried to bundle it with your app, all the files (and images (and stylesheets (and ...) ) ) would make CHM look like a gift from gods. That said, when actually bundled in the installation package, (instead of being serve...
Is the question how to generate your own help files, or what is the best help file format? Personally, I find CHM to be excellent. One of the first things I do when setting up a machine is to download the PHP Manual in CHM format (<http://www.php.net/download-docs.php>) and add a hotkey to it in [Crimson Editor][1]...
In French, but you should be able to find the download link :) [PHP Naive Bayesian Filter][1] [1]: http://xhtml.net/scripts/PHPNaiveBayesianFilter
Our software is both distributed locally to the clients and served from a network share. We opted for generating both a CHM file and a set of HTML files for serving from the network. Users starting the program locally use the CHM file, and users getting their program served from a network share has to use the HTML file...
Our software is both distributed locally to the clients and served from a network share. We opted for generating both a CHM file and a set of HTML files for serving from the network. Users starting the program locally use the CHM file, and users getting their program served from a network share has to use the HTML file...
Just a shot in the dark because I haven't tried it yet but when you realloc it returns the pointer much like malloc. Because realloc can move the pointer if needed you are most likely operating on an invalid pointer if you don't do the following: input = realloc(input, strlen(input) + delta);
Combined answers from @adam-wright and pix0r will work the best IMHO: <pre><code> using System.IO; string path = Path.GetTempPath() + Path.GetRandomFileName(); while (Directory.Exists(path)) path = Path.GetTempPath() + Path.GetRandomFileName(); File.Delete(path); Directory.CreateDirectory(path); </co...
Alternatively, you could just programmatically save the current state of autoplay and turn it off when your program starts, then restore the original state when your program closes. This would be a lot simpler. Check out [the NoDriveTypeAutoRun key](http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/re...
The advantage to using System.IO.Path.GetTempFileName is that it will be a file in the user's local (i.e., non-roaming) path. This is exactly where you would want it for permissions and security reasons.
I would propose to use three databases. One production database, one development database (filled with some meaningful data for each developer) and one testing database (with empty tables and maybe a few rows that are always needed). A way to test database code is: 1. Insert a few rows (using SQL) to initialize s...
How are the Eclipse settings saved? Perhaps you could simply adapt [this macro](http://xona.com/2005/08/02.html) and load the resulting file into Eclipse?
I've heard good things about [IKVM](http://www.ikvm.net/), the JVM that's made with .NET.
Whether you choose XSD and/or Schematron depends on what you are trying to validate. XSD is probably the most common validation strategy, but there are limits on what it can validate. If all you want to do is ensure that the right type of data is in each field, XSD should work for you. If you need to assert, for exampl...
We found out this morning why our code was mishandling the extender. Since the db was handling the date as a date/time it was returning the date in this format 99/99/9999 99:99:99 but we had the extender mask looking for this format 99/99/9999 99:99 <pre><code>Mask="99/99/9999 99:99:99"</code></pre> the above ...
The google maps sample is using this code... var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat(); ...which is putting the SouthWest/North...
|c++|stl|
This is how I was able to solve the issue: - strongly sign the custom assembly in question - modify the rssrvpolicy.config file to add permissions for the assembly <CodeGroup class="UnionCodeGroup" version="1" ...
Datasets/tables aren't so bad are they? Best advise I can give is to use it as much as you can in your own code, and hopefully through peer reviews and bugfixes, the other developers will see how code becomes more readable. (make sure to push the point when these occurrences happen). Ultimately if the code wo...
In short, yes. Protected member variables allow access to the variable from any sub-classes as well as any classes in the same package. This can be highly useful, especially for read-only data. I don't believe that they are ever necessary however, because any use of a protected member variable can be replicated us...
The consumer of your service doesn't care what's underneath your service. To really test your service layer, I think your layer needs to go down to DLLs and the database and write at least [CRUD][1] test. [1]: http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
i think when you do step 2 and install the documentation just tell direct it to the usb key drive letter. easy peasy.
A quick look at [http://www.update.uu.se/~ams/slask/emacs/src/frame.h](http://www.update.uu.se/~ams/slask/emacs/src/frame.h) returns: List of buffers that were viewed, then buried in this frame. The most recently buried buffer is first. So in theory you can use cdr to obtain the same list as Ben Colli...
Arithmetic with Arbitrarily Large Integers in PHP
|php|integer|
Ok, so PHP isn't the best language to be dealing with arbitrarily large integers in, considering that it only natively supports 32-bit signed integers. What I'm trying to do though is create a class that could represent an arbitrarily large binary number and be able to perform simple arithmetic operations on two of the...
Advantage: - Only one place to update your assemblys - You use a little less hard drive space Disadvantage: - If you need to update only one website, you can't. You may end with the other websites in the webserver broken Recommendation: Leave the GAC to MS and friends. The gigabyte is very cheap...
Your best bet would be putting Apache httpd in front of port 80 and relay requests meant for other servers through Apache by using modules. Most popular scenario would be Tomcat behind Apache where you'll be able to run both php and jsp applications. I'm not familiar with CherryPy, so I can only suggest you look for...
Alternatively, to Ishmaeel's correct answer, if you have a server with 2 network cards, you could have each server answer requests on different IP addresses.
Help me live - I can't believe all of the people that say using it is a "best practice" and such - I hope I never work in your code... Use "this" when there is ambiguity, as in Corey's example or when you need to pass the object as a parameter, as in Ryan's example. There is no reason to use it otherwise because bei...
Help me live - I can't believe all of the people that say using it is a "best practice" and such - I hope I never work in your code... Use "this" when there is ambiguity, as in Corey's example or when you need to pass the object as a parameter, as in Ryan's example. There is no reason to use it otherwise because bei...
Help me live - I can't believe all of the people that say using it is a "best practice" and such - I hope I never work in your code... Use "this" when there is ambiguity, as in Corey's example or when you need to pass the object as a parameter, as in Ryan's example. There is no reason to use it otherwise because bei...
I can't believe all of the people that say using it always is a "best practice" and such. Use "this" when there is ambiguity, as in Corey's example or when you need to pass the object as a parameter, as in Ryan's example. There is no reason to use it otherwise because being able to resolve a variable based on the sc...
I believe it defaults to <code>%HOMEDRIVE%\%HOMEPATH%</code> so if you can muck about with those environment variables that might be an option. I can't edit these environment variables on my company's network, so I had to use the <a href="http://technet.microsoft.com/en-us/library/cc756720.aspx">AutoRun</a> to change ...
If you are opening it from a shortcut change the working dir for the shortcut.
[Expert Oracle JDBC Programming][1] is a book aimed directly at developers who want to use Java with Oracle. Before you make even that small monetary investment though, you might want to check out the [JDBC tutorial][2] published by Sun. [1]: http://www.amazon.com/Expert-Oracle-JDBC-Programming-Menon/dp/1590594...
Mike Taulty's Blog: <http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/category/1024.aspx> A great EF intro deck: <http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/03/13/10235.aspx> And these ADO.NET Data Services screencasts are nice too: <http://mtaulty.com/CommunityServe...
Mike Taulty's Blog: <http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/category/1024.aspx> A great EF intro deck: <http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/03/13/10235.aspx> And these ADO.NET Data Services screencasts are nice too: <http://mtaulty.com/CommunityServe...
[@Ravi](http://stackoverflow.com/questions/44190?sort=newest#44250) Here's working example of your code <html> <head> <title>Font Detect please</title> <script src="prototype.js" type="text/javascript"></script> <script type="text/javascript"> function ch...
**Note, try to edit your code to get rid of the html escape codes.** Well, though it has been a while since I used C/C++, realloc that grows only reuses the memory pointer value if there is room in memory after your original block. For instance, consider this: (xxxxxxxxxx..........) If your pointer points...
As a general rule, you should **never** do a free or realloc on a user provided buffer. You don't know where the user allocated the space (in your module, in another DLL) so you cannot use any of the allocation functions on a user buffer. Provided that you now cannot do any reallocation within your function, you sho...
My quick hints. Instead of: `void strrep(char *input, char *search, char *replace)` try: `void strrep(char *&input, char *search, char *replace)` and than in the body: `input = realloc(input, strlen(input) + delta);` Generally read about passing function arguments as values/reference and realloc() ...
How do I index a database field
|sql|database|indexing|
Hopefully, I can get answers for each database server. For an outline of how indexing works check out: <http://stackoverflow.com/questions/1108/how-does-database-indexing-work>
Why am I getting a malloc: double free error with realloc()?
|c|malloc|
I've tried to write a string replace function in C, which works on a char * which has been allocated using malloc(). It's a little different in that it will find and replace strings, rather than characters in the starting string. It's trivial to do if the search and replace strings are the same length (or the repla...
DotNetOpenId available at [http://code.google.com/p/dotnetopenid][1] [1]: http://code.google.com/p/dotnetopenid
You will have to mark the CLR as EXTERNAL_ACCESS in order to get access to the System.IO namespace, however as things go that is not a bad way to go about it. >SAFE is the default permission set, but it’s highly restrictive. With the SAFE setting, you can access only data from a local database to perform computatio...
I'm considering the same thing. On the Open ID site, there's a link 'For Developers' @ http://openid.net/developers/ and from there is a link to 'Open Libraries' @ http://wiki.openid.net/Libraries and finally from there is one called 'DotNetOpenID' @ http://dotnetopenid.googlecode.com/ which is probably what you're loo...
how to get locale information on a GWT application
|url|gwt|locale|
In GWT I have to specify what locales are supported in my application. The code get compiled in various files, one for each locale (beside other versions), but I have to give my clients one only URL. This URL is supposed to be a page that should be displayed according to the locale preferred by the browser. I dont't w...
You should check out the [DotNetNuke][1] codebase as well, they have been using OpenID for the last several revisions, and you'll find working code for implementing it there. [1]: http://www.dotnetnuke.com
> 1. Does anyone know of anyway to > reduce/optimize the PDF export phase > and or the size of the PDF without > lowering the total page count? I have a few ideas and questions: 1. Is this a graphics-heavy report? If not, do you have tables that start out as text but are converted into a graphic by the SSRS P...
Do it by example and tread lightly. Anything stronger will just alienate you from the rest of the team. Remember to consider the possibility that they're onto something you've missed. Being part of a team means taking turns learning & teaching. No single person has all the answers.