instruction stringlengths 0 30k ⌀ |
|---|
As Ovid says, it's a contractual, social problem. If they change the code, they invalidate the warranty. Charge them a lot to fix that, but at the same time, give them a channel where they can suggest changes. Also, look at what they want to change and make that part of the configuration if you can. They have something... |
You can test them, but they won't be unit tests. Unit test is something that doesn't cross the boundaries, such as crossing over the wire, hitting database, running/interacting with a third party, Touching an untested/legacy codebase etc.
Anything beyond this is integration testing.
The obvious answer of the qu... |
To make forms as accessible as possible and semantically correct, I use the following format:
<fieldset>
<ol>
<li>
<label for='text_field'>Text Field</label>
<input type='text' name='text_field' id='text_field' />
</li>
</ol>
</fieldset>
|
I second the opensta suggestion. I would just add that it allows you to do things to monitor the server you're testing using SMTP. We keep track of processor load, memory used, byes sent, etc. The only downside is that if you find something boken and want to do a fix it relies on several open-source libraries that a... |
To quote another post on the subject,
> some aspect of your process for
> submitting URIs is doing some bad
> encoding.
> http://www.usenet-forums.com/archive/index.php/t-39111.html
I recommend changing the name of the JPG to not have spaces in it as a good practice, then later try to figure out with a non-... |
The [Community Wiki link][1] has good answers for everything except
- **Do abstract classes simply have a NULL for the function pointer of at least one entry?**
The answer for that is that it is unspecified - calling the pure virtual function results in undefined behavior if it is not defined (which it usually ... |
The [Community Wiki answer][1] has good answers for everything except
- **Do abstract classes simply have a NULL for the function pointer of at least one entry?**
The answer for that is that it is unspecified - calling the pure virtual function results in undefined behavior if it is not defined (which it usuall... |
This answer has been incorporated into the [Community Wiki answer][1]
- **Do abstract classes simply have a NULL for the function pointer of at least one entry?**
The answer for that is that it is unspecified - calling the pure virtual function results in undefined behavior if it is not defined (which it usuall... |
Specifically to your example of using a collection that you would return, it seems possible that the implementation of such a collection might change (unlike simpler member variables) making the utility of encapsulation higher.
That being said, I kinda like Python's way of dealing with it. Member variables are publi... |
This is normal, but that doesn't mean it's ideal. It probably only has a small impact on app startup time, but it'll have a slightly greater impact than that on memory usage.
If you'd like this to be improved, the best thing to do is to head on over to [Apple's bug reporter][1] and file a bug about it. Attach a co... |
What is the easiest way to upgrade a large C# winforms app to WPF |
|c#|.net|wpf|upgrade| |
I work on a large C# application (approximately 450,000 lines of code), we constantly have problems with desktop heap and GDI handle leaks. WPF solves these issues, but I don't know what is the best way to upgrade (I expect this is going to take a long time). The application has only a few forms but these can contain m... |
You can precompile the site, which will make the first run experience better
[http://msdn.microsoft.com/en-us/library/ms227972.aspx][1]
[1]: http://msdn.microsoft.com/en-us/library/ms227972.aspx |
You shouldn't need to add any templates, this is what happens by default.
The closest thing to a normal Cocoa Touch application would be the Window-Based application as it gives you a window and a delegate...
The others, like Martin said, have different styles already applied to them... OpenGL, Navigation Control... |
One of the important things to do is keeping projects of not-so-often changed assemblies unloaded. When a change occurs, load it, compile and unload again. It makes huge differences in large solutions. |
Do you use a lot of User controls for the pieces? WPF can host winform controls, so you could piecewise bring in parts into the main form. |
Your answers here will be very subjective. Different tastes and programming backgrounds will give you different preferences.
Perhaps what will be most important to you in the long run is consistancy among all of your projects, so that regardless of who developed the code you will be able to understand it when readi... |
WPF allows you to embed windows forms user controls into a WPF application, which may help you make the transition in smaller steps.
Take a look at the [WindowsFormsHost][1] class in the WPF documentation.
[1]: http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx |
[unzip un-needed in Python][1]
Someone blogged about Python not having an unzip function to go with zip(). unzip is straight-forward to calculate because:
>>> t1 = (0,1,2,3)
>>> t2 = (7,6,5,4)
>>> [t1,t2] == zip(*zip(t1,t2))
True
On reflection though, I'd rather have an explicit unzip().
... |
Yes. Think of how a RPN calculator works. Now, instead of calculating the value, instead you add the operation to the tree. So, for example, `2 3 4 + *`, when you get to the +, then rather than putting 7 on the stack, you put `(+ 3 4)` on the stack. And similarly when you get to the * (your stack will look like `2 (+ 3... |
Yes. Think of how a RPN calculator works. Now, instead of calculating the value, instead you add the operation to the tree. So, for example, `2 3 4 + *`, when you get to the +, then rather than putting 7 on the stack, you put `(+ 3 4)` on the stack. And similarly when you get to the * (your stack will look like `2 (+ 3... |
Next time try [Google][1] as well, as they are the programmer's best friend. Search keywords: `gnu screen delete scrollback buffer`.
For me, [this thread][2] was the second hit.
In the window whose scrollback you want to dele
> te, set the scrollback to zero, then
> return it to its normal value (in your
> c... |
How to clear the scrollback in the screen command? |
|command-line|linux| |
How important do you think Progressive Enhancement is? |
|ajax|graceful-degradation|progressive-enhancement|unobtrusive-javascript| |
[Progressive Enhancement][1] is a web development methodology that not only allows greater portability and accessibility but in my opinion, makes the development process easier.
What I want is to know what the rest of the community think of this approach.
In particular: What do you believe is the minimum set of t... |
One of the big differences is that exceptions force you to handle an error, whereas error return codes can go unchecked.
Error return codes, if used heavily, can also cause very ugly code with lots of if tests similar to this form:
if(function(call) != ERROR_CODE) {
do_right_thing();
}
els... |
I love webforms, but ASP.NET AJAX is a pile of crap.
I prefer to use WebForms + custom HTTPHandlers handling the server side of any AJAX calls.
|
I love webforms, but ASP.NET AJAX is a pile of crap.
I prefer to use WebForms + custom HTTPHandlers handling the server side of any AJAX calls.
Heh, downvoted...
ASP.NET AJAX Is a pile of crap because a callback requires the entire page class to be reinstantiated, you aren't calling a single method, you are re... |
Fit the tool to the job... recently I saw some code like this in my current codebase:
private static class SomeSmallDataStructure {
public int someField;
public String someOtherField;
}
And then this class was used internally for easily passing around multiple data values. It doesn't a... |
Use the Database Session store. all the info is [on the Rails wiki][1].
The short of it is this:
To generate the table, at the console, run
rake db:sessions:create
in your environment.rb, include this line
config.action_controller.session_store = :active_record_store
[1]: http://wiki.r... |
In Rails 2.0 there is now a CookieStore that stores all session data in an encrypted cookie on the client's machine.
http://izumi.plan99.net/blog/index.php/2007/11/25/rails-20-cookie-session-store-and-security/ |
Some useful classes are:
Package javax.swing.table :
TableModel - Interface for a tablemodel
AbstractTableModel - Nice class to extend for creating your own table with custom data structures
DefaultTableModel - Default table model which can deal with arrays[] and Vectors
To disable editing on any cell you ne... |
example
DECLARE @Max int
SELECT @Max = 5
SELECT t1.*
FROM [MyTable] t1
JOIN(
SELECT [Date]
FROM [MyTable]
GROUP By [Date]
HAVING COUNT(*) < @Max
) t2 on t1.[Date] = t2.[Date]
|
Do you test private method? |
|unit-testing|testing| |
I have read the post about how to test private (http://stackoverflow.com/questions/34571/whats-the-best-way-of-unit-testing-private-methods) method because I usually do not test them, I always thought it's more fast to only test public method that will be called from the external of the object.
Do you test private m... |
You can actually use var in 2.0 projects. It's syntactical sugar and the compiler works with it. Check out this for more info.
http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx |
Oracle Enterprise assumes that there is an Enterprise to support it, ie, a real Oracle DBA. A novice (but competent) DBA should be able to secure MySQL much more easily than Oracle, just because Oracle is inherently more complex. Of course, Oracle has the Enterprise monitoring tools beyond what MySQL currently features... |
Try the ".NET CLR Interop" for "# of marshalling" performance counter.
See this article for more <http://msdn.microsoft.com/en-us/library/ms998551.aspx>. |
I'm not sure what the "polution" is. Either the requirement is that your Business Object returns a value expressed as a percentage, in which case your business object should offer that -OR- you are testing the true value of the response as float, which you have now.
Trying to get fitnesse to massage the value for... |
I use the `screen` command for command-line multitasking in Linux and I set my scrollback buffer length to a very large value. Is there a key combination to clear the buffer for a certain tab when I don't want it sitting there anymore?
Thanks. |
|linux|command-line|gnu-screen|screen| |
You will need to use [Windows Image Acquition (WIA)][1] to integrate a webcam with your application. There are plenty examples of this readily available. Here is a [C# Webcam User Control][2] with source.
Here are some more articles and blog posts from people looking to solve the same problem you are:
- [Webca... |
You will need to use [Windows Image Acquition (WIA)][1] to integrate a webcam with your application. There are plenty examples of this readily available. Here is a [C# Webcam User Control][2] with source.
Here are some more articles and blog posts from people looking to solve the same problem you are:
- [MSDN ... |
If you have some source text (string/s) that you're looking to convert from RPN (postfix notation) to "normal notation" (infix), this is certainly possible (and likely not too difficult).
RPN was designing for stack-based machines, as the way the operation was represented ("2 + 3" -> "2 3 +") fit how it was actually... |
I feel the above answers wont fit for the following reasons..
JasonS Solution - The application is developed on J2EE technologies.
Other's solution - Some of the the URL Launched in the child window will communicate to the parent window through standard APIs. If i am using div or other in-built plug-in windows, t... |
I've used [XDebug profiling](http://www.xdebug.org/docs/profiler) recently in a similiar situation. It outputs a full profile report that can be read with many common profiling apps ( Cant give you a list tough, I just used the one that came with slackware ).
|
I've used [XDebug profiling](http://www.xdebug.org/docs/profiler) recently in a similiar situation. It outputs a full profile report that can be read with many common profiling apps ( Can't give you a list though, I just used the one that came with slackware ).
|
As far as I understand (although no reference seems to mention it), `iptables-restore` is atomic. At the end, when the `COMMIT` line is read, `iptables` calls `iptc_commit` in `libiptc` (which in an internal interface you aren't supposed to use), which then calls `setsockopt(SO_SET_REPLACE)` with your new rulesets.
... |
What are the best open source Nagios interfaces? |
|networking|monitoring|nagios|daemon|opensource| |
[Centreon][1]?
[NagVis][2]?
Other?
[1]: http://www.centreon.com/
[2]: http://www.nagvis.org/ |
(best in your own eyes) Most features? Coolest Features? Slickest Design?
[Centreon][1]?
[NagVis][2]?
Other?
[1]: http://www.centreon.com/
[2]: http://www.nagvis.org/ |
|open-source|networking|monitoring|daemon|nagios| |
My first reaction is that this might not be an issue of calling cross-server, but one of calling a second proc from a first, and that *this* might be what's acting differently in the two different environments.
My first question is this: what happens if you remove the cross-server aspect from the equation? If you... |
I prefer Mootools because it is lightweight and is based on Prototype, but like Jay said you should check them out for yourself. |
In Java, I use (in the following order):
1/ Design-by-contract (ensuring preconditions are met before trying *anything* that might fail). This catches most things and I return an error code for this.
2/ Returning error codes whilst processing work (and performing rollback if needed).
3/ Exceptions, but these ... |
How do I get the "Command Buffer" in Solaris 10 ? |
|solaris| |
When working on a linx CShell u get the option to press the up / down arrows to select the last command/s typed or the Command Buffer. This even works on Windows.
However this is not functional when working on Solaris, to which i recently switched. I am guessing that the shell is also a CShell.
Please tell me wh... |
Typically, there is no "click" event. The action of clicking is broken into its two parts: Mouse Down and Mouse Up. Typically what you think of as a "left click" event is actually handled in a "left up" event.
Try it out:
- Hover over a button (such as the "Add Comment" button this page)
- Click the lef... |
Typically, there is no "click" event (and in the case of [wxWidgets][1] - [there isn't][2]
). The action of clicking is broken into its two parts: Mouse Down and Mouse Up. Typically what you think of as a "left click" event is actually handled in a "left up" event.
Try it out:
- Hover over a button (such as t... |
My general rule in the exception vs. return code argument:
- Use errorcodes when you need localization/internationalization -- in .NET, you could use these errorcodes to reference a resource file which will then display the error in the appropriate language. Otherwise, use exceptions
- Use exceptions only for e... |
Tools are important, but don't get too bogged down in finding the magic tool. No tool I've found yet has a "document everything magically using tiny invisible elves" tickbox. :-)
A wiki will work fine. Or Sharepoint. Or Google docs. Or you could use a SVN repository. Hell you could do it with pens, notepaper, ... |
If you have some source text (string/s) that you're looking to convert from RPN (postfix notation) to "normal notation" (infix), this is certainly possible (and likely not too difficult).
RPN was designed for stack-based machines, as the way the operation was represented ("2 + 3" -> "2 3 +") fit how it was actually ... |
My vote goes for cloud storage of some kind. The problem with nearly all 'home' backups is they stay in the home, that means any catastrophic damage to the system being backed up will probably damage the backups as well (fire, flood etc). My requirements would be
1) automated - manual backups get forgotten, usually... |
I second the vote for [JungleDisk][1]. I use it to push my documents and project folders to S3. My average monthly bill from amazon is about 20c.
All my projects are in Subversion on an external host.
As well as this, I am on a Mac, so I use SuperDuper to take a nightly image of my drive. I am sure there are goo... |
Not sure why you're doing that level of analysis in your lexer.
Lexical analysis should probably be used to separate the input stream into lexical tokens (number, line-change, keyword and so on). It's the parsing phase that should be dojng that level of analysis, including table lookups for typedefs and such.
Th... |
I used the following solution from codeproject in one of recent my projects
[Obtaining (and managing) file and folder icons using SHGetFileInfo in C#][1]
[1]: http://www.codeproject.com/KB/files/fileicon.aspx
##
The demo project is pretty self explanatory but basically you just have to do:
private... |
How do you diagnose a leak in C memory caused by a Java program? |
|java|memory-leaks| |
I'm working on a large application (300K LOC) that is causing a memory leak in the Sun 1.6 JVM (1.6_05). Profiling the Java shows no leak. Are there any diagnostics available from the JVM that might detect the cause of the leak?
I haven't been able to create a simple, isolated Java test case. Is the only way to figu... |
From man fdopen:
> The file descriptor is not dup’ed, and will be closed when the stream created by fdopen() is closed
So I would just use fclose(), which also closes the underlying file descriptor. I don't know whether shutdown() is needed, either. |
You could use a command line tool for killing processes like [SysInternals PsKill][1] and use [java.lang.Runtime.exec][2] to execute it.
[1]: http://www.sysinternals.com/Utilities/PsKill.html
[2]: http://www.docjar.com/docs/api/java/lang/Runtime.html#exec(String) |
You could use a command line tool for killing processes like [SysInternals PsKill][1] and [SysInternals PsList][2].
You could also use the build-in tasklist.exe and taskkill.exe, but those are only available on Windows XP Professional and later (not in the Home Edition).
Use [java.lang.Runtime.exec][3] to execute... |
There are plenty of great answers here already, I just want to add to the conversation another way of thinking about it.
' -> ' means function.
'a -> 'b is a function that takes an 'a and returns a 'b
('a * 'b) -> ('c * 'd) is a function that takes a tuple of type ('a, 'b) and returns a tuple of ('c, 'd). Suc... |
C++ 'mutable' keyword |
|c++|mutable| |
A while ago I came across some code that marked a member variable of a class with the 'mutable' keyword. As far as I can see it simply allows you to modify a variable in a 'const' method:
class Foo
{
private:
mutable bool done_;
public:
void doSomething() const { ...; ... |
Another somewhat rare use for the this keyword is when you need to invoke an explicit interface implementation from within the implementing class. Here's a contrived example:
class Example : ICloneable
{
private void CallClone()
{
object clone = ((ICloneable)this).Clone();
... |
Why don't you try [modwsgi][1]? It sounds as the preffered way these days for WSGI applications such as Django.
If you don't wan't to compile stuff for Fedora Core, that might be trickier.
Regarding 1) [this][2] seems to solve the fcgid configuration problem.
[1]: http://code.google.com/p/modwsgi/
[2]:h... |
Why don't you try [modwsgi][1]? It sounds as the preffered way these days for WSGI applications such as Django.
If you don't wan't to compile stuff for Fedora Core, that might be trickier.
Regarding 1) [this][2] seems to solve the fcgid configuration problem.
Note that you don't want to run the django applica... |
In Jakub Šturc's answer his #5 about passing data between contructors probably could use a little explanation. This is in overloading constructors, and is the one case where use of `this` is mandatory. In the following example:
class MyClass {
private int _x
public MyClass() : this(5) {}
... |
Another option is to use apache as a frontend, connecting tomcat with mod_jk. This way you can let apache serve static content (e.g. images, css, javascript) and let tomcat generate the dynamic content. Might leave a bit of work to separate the static content from the dynamic ones, but works great for me.
On Unix, h... |
Some time ago I've done some research on this topic and came to the conclusion [that using GeSHi is the way to go][1]. However recently I've been looking to some more alternatives:
- Using Windows Live Writer with a syntax highlighter plugin ([there][2] [are][3] [several][4] available)
- Using the [syntaxhighli... |
What is the cost of using a pointer to member function vs. a switch? |
|c++| |
I have the following situation:
<pre><code>
class A
{
public:
A(int whichFoo);
int foo1();
int foo2();
int foo3();
int callFoo(); // cals one of the foo's depending on the value of whichFoo
};
</code></pre>
In my current implementation I save the value of <code>whichFoo</code> in a d... |
I have the following situation:
<pre><code>
class A
{
public:
A(int whichFoo);
int foo1();
int foo2();
int foo3();
int callFoo(); // cals one of the foo's depending on the value of whichFoo
};
</code></pre>
In my current implementation I save the value of <code>whichFoo</code> in a d... |
I switched from websites to web appications. Compile time went down by a factor of ten at least. Also, I try not to use the debugger if possible ("Run without debugging"). This cuts down by a lot the time it takes to start the web application. |
I have a hard time wrapping my head around Applescript, but since Apple runs BASH scripts just fine, I just use those instead. I've got a development server on my mac, so I've got a script that I can run to create a new site directory, create a new virtual host in apache, add a new domain to my /etc/hosts file, etc.
... |
For longer stuff I do it this way:
root.Nodes.Add(new TNode() {
Foo1 = bar1,
Foo2 = bar2,
Foo3 = bar3
}); |
What you describe sounds a lot like "secret splitting." The basic idea is you can come up with a polynomial that includes your "secret" (a key) as a point on the line. You can give out "shares" by picking other points on this polynomial. Two points define a line of the form f(x) = ax + b, three points define a polynomi... |
What you describe sounds a lot like "secret splitting" (Section 12.1. <u>Introduction to Cyptography</u>. Trappe & Washington. 2nd ed) The basic idea is you can come up with a polynomial that includes your "secret" (a key) as a point on the line. You can give out "shares" by picking other points on this polynomial. Two... |
I would recommend adding as much memory to your PC as you can. If your solutions are super large you may want to explore 64bit so that your machine can address more than 3GB of ram.
Also Visual Studio 2008 SP1 seems to be markedly faster than previous versions, make certain you are running the latest release with t... |
As others have said, automatic type-casting would eliminate type safety. Generics have multiple benefits and really aren't any harder to declare. With Eclipse, you can can just declare the generic variable and then use auto-complete on the instantiation and it will automatically fill in the type you used. Plus you (or ... |
1. So number 1 [above][1]. http://stackoverflow.com/questions/3058/what-is-inversion-of-control#99100
2. Maintenance is the number one thing it solves for me. It guarantees I am using interfaces so that two classes are not intimate with each other.
In using a container like Castle Windsor, it solves maintenance... |