instruction
stringlengths
0
30k
In C, you actually have two different choices. One, you can let the system manage the memory for you. Alternatively, you can do that by yourself. Generally, you would want to stick to the former as long as possible. However, auto-managed memory in C is extremely limited and you will need to manually manage the memory i...
I've learned from experience that having only one app per Tomcat instance has a very significant advantage: when a Tomcat instance dies, *you don't have to dig through logs (or guess) which app is to blame*.
NetBeans has a built-in profiler.
A tool is a big help. However, there are times when you can't use a tool: the heap dump is so huge it crashes the tool, you are trying to troubleshoot a machine in some production environment to which you only have shell access, etc. In that case, it helps to know your way around the hprof dump file. Look for ...
if ((testItem & FlagTest.Flag1) == FlagTest.Flag1) { // Do something }
if((testItem & FlagTest.Flag1) == FlagTest.Flag1) { ... }
Try this: <pre><code> if ((testItem & FlagTest.Flag1) == FlagTest.Flag1) { // do something } </code></pre>Basically, your code is asking if having both flags set is the same as having one flag set, which is obviously false. The code above will leave only the Flag1 bit set if it is set at all, then compares t...
There's a specific problem with mixing doPostback, UpdatePanel and SharePoint -- and the symptom is exactly what you're seeing: a full-page postback instead of an asynchronous postback. See this KB article for a workaround: http://support.microsoft.com/kb/941955
[List of Web Safe Fonts][1]. [1]: http://www.fonttester.com/help/list_of_web_safe_fonts.html
Good [article on Mutex's and Semaphores][1] - what makes them different, and why they might or might not be used given various conditions. -Adam [1]: http://www.netrino.com/Embedded-Systems/How-To/RTOS-Mutex-Semaphore
By just going over the features good source control brings: - ability to easily see logs of who did what, when, and in what order, to which files - keep a history of past versions of everything - easily go back and reproduce a specific version of your files from any past version, to more easily reproduce bugs repo...
The internet is littered with well written articles on the flaws of VSS. I would collect this as a body of evidence for moving away from VSS. Find a key requirement that VSS can't support (remote working, support on other OSs, tools integration) and use it to drive your issue. You then need to find a source control sys...
being able to handle branching and forking is a start. Try using subversion for a while in parallel to vss you will most likely find many arguments to convince your boss. If you don't, your boss is right, no reason to switch.
Get them to google for 'vss problem', 'source safe corruption' or simply look at the Wiki page for it. That ought to convince them that it's probably not a long-term viable thing for you to be betting such a vital part of your business on. How big is your team? (ie, I mean how many members, not whether or not you're...
Even if it ain't broke, there's a potential benefit to migrating from VSS. First and most trivially, you won't have to buy new VSS licenses. Second, there are many examples of deficiencies in the VSS product (some also acknowledged by MS). The learning curve for SVN is at least as low as for VSS, and if you have dev...
You'll probably need to create a piece of code that updates AssemblyInfo.cs according to the version number stored in the .csproj file. (The ClickOnce deploy version is stored inside an XML tag.) You'd then change your .csproj file to run this bit of code when Publish|Release build is performed. The MSBuild folks ha...
> Also, I actually fixed the std::string problem. How? By replacing it with a vector, compiling, then replacing the string again. It was consistently crashing there, and that fixed even though it...couldn't. There's something nasty there, and I'm not sure what. That sounds like you really did shake a chicken at it. ...
Puzzle: Find largest rectangle
|algorithm|geometry|math|
What's the most efficient algorithm to find the rectangle with the largest area which will fit in the empty space? Let's say the screen looks like this ('#' represents filled area): .................... ..............###### ##.................. .................### .................### ...
|algorithm|geometry|math|language-agnostic|
Puzzle: Find largest rectangle (maximal rectangle problem)
|language-agnostic|algorithm|math|geometry|
What's the most efficient algorithm to find the rectangle with the largest area which will fit in the empty space? Let's say the screen looks like this ('#' represents filled area): .................... ..............###### ##.................. .................### .................### ...
It's probably the [awesome firefox3 fsync "bug"](http://shaver.off.net/diary/2008/05/25/fsyncers-and-curveballs/), which is a giant pile of fail. In summary * Firefox3 saves its bookmarks and history in an SQLite database * Every time you load a page it writes to this database several times * SQLite cares de...
You might or might not already know this (R# does suffer from a lack of discoverability, unless you get the one-page key-shortcut page printed out), but ALT-INS opens a box which can at least mass-generate properties for fields. Not sure if that's any use - it's not the same as a retrospective encapsulation.
C++ 0x is introducing initialization lists which will allow you to do: std::vector<std::string> v = {"Hello", "World"}; Probably doesn't help you now. Although GCC 4.4 apparently [supports this already][1]. [1]: http://gcc.gnu.org/projects/cxx0x.html
I'm not certain I fully understand the problem, but just to hack & slash at it you could try: SELECT TOP 1 FROM cteLevelOne ORDER BY CustID DESC That assumes that the CustID is also in order as in the example, and not something like a GUID.
rsync will only upload the differences. I haven't personally used it, but [Mark Pilgrim][1] wrote a long time ago about how it even [handles binary diffs brilliantly][2]. svn+rsync sounds like a fantastic solution. I'll have to try that in the future. [1]: http://diveintomark.org [2]: http://diveintomark.o...
nmake, visualstudio, and .mak files
|visual-studio|nmake|.mak|
I was given a C++ project that was compiled using MS Visual Studio .net 2003 C++ compiler, and a .mak file that was used to compile it. I am able to build it from the command line using nmake project.mak, but the compiler complains that afxres.h was not found. I did a little searching around and the afxres.h is in th...
Depending on your situation, you *might* have another option: in-license third-party code. I've consulted at a couple of companies where that would be the sensible choice, although seemingly "throwing away IP" can be a big barrier for management. At my current company, we seriously considered the viable option of us...
There should be an icon in your Start menu under Programs that opens a cmd.exe instance with all the correct MSVS environment variables set up for command line building.
When you create the project you can specify whatever directory you want, you are not limited to the default.
To monitor the servers we use the free [tools from Maatkit][1] ... simple, yet efficient. The binary replication is available in 5.1, so I guess you've got some balls. We still use 5.0 and it works OK, but of course we had our share of issues with it. We use a Master-Master replication with a MySql Proxy as a loa...
I came into contact with Octal through [PDP-11](http://www.retrologic.com/jargon/P/PDP-11.html), and so, apparently, did the C language :)
If you're writing a program that will be used by many people, it's best to have some kind of mechanism to choose what will be logged and what won't. One argument in favor of .logthis() functions is that they can be an excellent replacement for inline comments in some instances (if done properly). Plus, it helps you...
@Roddy - I've already read the links you point to, they are both referenced from Paul Tyma's presentation "Thousands of Threads and Blocking I/O - The old way to write Java Servers is New again". Some of the things that don't necessarily jump out from Paul's presentation, however, are that he specified -Xss:48k to t...
Basic answer is that you have to make the case that switching meets the needs of the business. For example: 1. lower cost of development 2. shorter schedule (another shade of #1) 3. more apt for meeting process requirements (like software requirements traceability, or build reproducibility, etc). Making the...
1. I use Parallels. I used Vista for 4 months then switched to XP. I prefer XP as it is faster. 2. Key bindings are quirky. Using function keys while debugging in the hosted XP will trigger events in OS X, effectively popping you out. 3. I have 3 "spaces" set up. One for OS X, one for XP VM, and the last for a RD...
1. I use Parallels. I used Vista for 4 months then switched to XP. I prefer XP as it is faster. 2. Key bindings are quirky. Using function keys while debugging in the hosted XP will trigger events in OS X, effectively popping you out. 3. I have 3 "spaces" set up. One for OS X, one for XP VM, and the last for a RD...
I'm all for using static **functions**. These just make sense especially when organized into modules (`static class` in C#). However, *the moment* those functions need some kind of external (non compile-time const) data, then that function should be made an instance method and encapsulated along with its data. So...
I'm all for using static **functions**. These just make sense especially when organized into modules (`static class` in C#). However, *the moment* those functions need some kind of external (non compile-time const) data, then that function should be made an instance method and encapsulated along with its data into a...
Is there an "exists" function for jQuery
|jquery|exists|
So I know that you can do: if ($(selector).length>0) { // Do something } But is there a more elegant method?
|jquery|
|javascript|jquery|
Check following variables: - The environment variable TMPDIR - The value of the P_tmpdir macro If all fails try to use the directory `/tmp'. You can also use tempnam function to generate a unique temporary file name.
What control is this?
|.net|.net-2.0|windowscontrols|
The "Open" button on the open file dialog used in certain windows applications includes a dropdown arrow with a list of additional options -- namely "Open with..". I haven't seen this in every windows application, so you may have to try a few to get it, but SQL Server Management Studio and Visual Studio 2005 will ...
I set up an extension method to do it: [related question](http://stackoverflow.com/questions/7244/anyone-know-a-good-workaround-for-the-lack-of-an-enum-generic-constraint). Basically: public static bool IsSet( this Enum input, Enum matchTo ) { return ( Convert.ToUInt32( input ) & Convert.ToUInt3...
Yes, that'd be best, except you'd omit the `$`s on the parameter names.
Yes, that'd be best<s>, except you'd omit the `$`s on the parameter names</s>, as others have pointed out. For those interested in the rationale behind the lack of default parameter values, see @[Giovanni Galbo](#40121)'s explanation.
How to Compare Flags in C#?
|c#|.net|flags|attributes|
I have a flag enum below. [Flags] public enum FlagTest { None = 0x0, Flag1 = 0x1, Flag2 = 0x2, Flag3 = 0x4 } I cannot make the if statement evaluate to true. FlagTest testItem = FlagTest.Flag1 | FlagTest.Flag2; if (testItem == FlagTest.Fla...
|c#|.net|attributes|enums|flags|
GUIDs as Primary Keys - Offline OLTP
|sql-server|guid|oltp|offline|
We are working on designing an application that is typically OLTP (think: purchasing system). However, this one in particular has the need that some users will be offline, so they need to be able to download the DB to their machine, work on it, and then sync back once they're on the LAN. I would like to note that I ...
|sql-server|synchronization|guid|offline|oltp|
What is the best way to migrate an existing messy webapp to elegant MVC?
|java|model-view-controller|architecture|
|java|model-view-controller|architecture|jsp|
I joined a new company about a month ago. The company is rather small in size and has pretty strong "start-up" feel to it. I'm working as a Java developer on a team of 3 others. The company primarily sells a service to for businesses/business-type people to use in communicating with each other. One of the main thing...
Some places to start: If you're on windows, and using visual C++6 (I hope to god nobody still uses it these days) it's implentation of std::string is not threadsafe, and can lead to this kind of thing. [Here's an article I found which explains a lot of the common causes of memory leaks and corruption.](http://www...
> [Adam Haile][1] writes: >> check out the System.Web.Mail namespace By which you mean System.Net.Mail in .Net 2.0 and above :) [1]: http://stackoverflow.com/questions/6210/e-mail-notifications#6212
Some kind of task manager for JavaScript in Firefox 3?
|firefox|javascript|memory|cpu|
Recently I have been having issues with Firefox 3 on Ubuntu Hardy Heron. I will click on a link and it will hang for a while. I don't know if its a bug in Firefox 3 or whatever, but I would like to try and debug it a bit. So, my question is, is there a way to have some kind of process explorer, or task manager sor...
Recently I have been having issues with Firefox 3 on Ubuntu Hardy Heron. I will click on a link and it will hang for a while. I don't know if its a bug in Firefox 3 or a page running too much client side JavaScript, but I would like to try and debug it a bit. So, my question is, is there a way to have some kind of...
|javascript|firefox|memory|cpu|
Recently I have been having issues with Firefox 3 on Ubuntu Hardy Heron. I will click on a link and it will hang for a while. I don't know if its a bug in Firefox 3 or a page running too much client side JavaScript, but I would like to try and debug it a bit. So, my question is, is there a way to have some kind of...
Adding more information to TestResult.xml file from NUnit
|unit-testing|nunit|
I would like to be able to add a "message" to a unit test, such that it actually appears within the TestResult.xml file generated by NUnit. For example, this is currently generated: <results> <test-case name="MyNamespace.Tests.MyTest" executed="True" success="True" time="0.203" asserts="4" /> </resul...
I agree with Andrew Peters, DRY. It should also be pointed out that you can specify your controller, action, and params to the .Form() helper and if they fit into your routing rules then no query string parameters will be used. I also understand what Will was saying about the V in MVC. In my opinion I do not think...
I use a Mac Book Pro as well but I run Vista. I set aside a little space so I could also run Leopard and just use Boot Camp. You can use Boot Camp to just boot from windows so you never have to deal with Leopard unless you want to. I would highly reccomend it because Apple makes great hardware while Microsoft makes...
How to ensure that the same thread is used to execute code in IIS?
|vb.net|iis|dll|multithreading|
We have a third party dll that is used in our web service hosted in IIS6. The problem is that once this dll is loaded into memory, the exception <a href="http://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx">AccessViolationException</a> gets thrown if a thread different then the one that created...
|vb.net|iis|dll|multithreading|
We have a third party dll that is used in our web service hosted in IIS6. The problem is that once this dll is loaded into memory, the exception <a href="http://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx">AccessViolationException</a> gets thrown if a thread different then the one that created...
I would have said that something must have updated either the LIBEAY32.dll or another dll that depends on it. You may find some helpful information using the [depends tool][1]. If you use this to open up the perl.exe then it should highlight the dependency path that produces the problem. You can compare this with other...
XML Serialization and Inherited Types
|serialization|xml|c#|inheritance|
following on from my [previous question](http://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods) I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!). The problem I have is that I have a collection, which is of a abs...
|c#|xml|serialization|inheritance|
following on from my [previous question](http://stackoverflow.com/questions/19454/enforce-attribute-decoration-of-classesmethods) I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!). The problem I have is that I have a collection, which is of a abs...
You might wanna check out [Domain Driven Design][1], by Eric Evans. DDD has this notion of a Specification: > ... explicit predicate-like VALUE > OBJECTS for specialized purposes. A > SPECIFICATION is a predicate that > determines if an object does or does > not satisfy some criteria. I think failing fast is...
<a href = "http://trolltech.com/products/qt/">Qt Cross-Platform Application Framework</a> Qt is a cross-platform application framework for desktop and embedded development. It includes an intuitive API and a rich C++ class library, integrated tools for GUI development and internationalization, and support for Java™ ...
You are right. Validation should not be done during getters/setters. Accessors and mutators have a very specific job -- validation should be handled in a seperate module (a validator) or at least seperate method calls.
Validation should not be done during getters/setters, but not because of performance, but rather because you want **separation of concerns**. Getters and setters have a very specific job -- validation should be handled in a seperate module (a validator) or at least seperate method calls. In the case of the setter...
Validation should be captured separately from getters or setters in a validation method. That way if the validation needs to be reused across multiple components, it is available. When the setter is called, such a validation service should be utilized to sanitize input into the object. That way you know all inform...
Not free, but [ReSharper][1] is definitely one recommendation. [1]: http://www.jetbrains.com/resharper/index.html
Xen - Can't get a Console to VMs
|ubuntu|virtualization|xen|