instruction stringlengths 0 30k ⌀ |
|---|
Trying to understand what the software you're writing is about and reflecting that understanding in the model. |
I had issues along the same lines you do. In order to test the software behavior, I just unplugged the network cable at the appropriate time. I had to set a break-point right before I wanted to unplug the cable.
If I were doing it again, I'd put a switch (a normally closed momentary push button one) in a network... |
In SQL Server, it does not make a difference whether you use `SELECT 1` or `SELECT *` within `EXISTS`. You are not actually returning the contents of the rows, but that rather the set determined by the `WHERE` clause is not-empty. Try running the query side-by-side with `SET STATISTICS IO ON` and you can prove that the... |
Providing as much information as possible during errors is a good thing... Right?
Helps out tracking the bugs.
**Edit:** (Yes) |
It's some Rails specific patching of Ruby, [symbol to proc][1].
[1]: http://blog.hasmanythrough.com/2006/3/7/symbol-to-proc-shorthand |
White-box:
pros:
- simple
cons:
- requires intrinsic knowledge on
component internals
- can be difficult to implement (OO inheritance constraints)
Black-box:
pros:
- low coupling (gives late binding and other goodies)
cons:
- not obvious
- interfaces are more fragile ... |
White-box:
pros:
- simple (very natural concept)
cons:
- requires intrinsic knowledge on
component internals
- can be difficult to implement (OO inheritance constraints)
sometimes it leads to broken\incorrect inheritance chains
Black-box:
pros:
- low coupling (gives late bind... |
White-box:
pros:
- simple (very natural concept)
- you have more control over things
cons:
- requires intrinsic knowledge on
component internals
- can be difficult to implement (OO inheritance constraints)
sometimes it leads to broken\incorrect inheritance chains
Black-box:
... |
Depending on your situation, extra qualifiers will generate a warning (if this is what you mean by redundant). If you then treat warnings as errors, that's a pretty serious downside.
I've run into this with GCC for example.
struct A {
int A::b; // warning!
} |
Alexandru's suggestion of using class constants for enums works quite well.
I also like to add a dictionary for each set of constants to lookup a human-readable string representation.
This serves two purposes: a) it provides a simple way to pretty-print your enum and b) the dictionary logically groups the const... |
Why is this regular expression faster? |
|regex|regularexpression| |
I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed [here](http://www.termsys.demon.co.uk/vtansi.htm#colors)).
One method I have is one to find all the codes and remove them, so I can render the... |
I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed [here](http://www.termsys.demon.co.uk/vtansi.htm#colors)).
One method I have is one to find all the codes and remove them, so I can render the... |
|regex|regular-expression| |
|regex| |
|regex|ansi| |
I'm writing a Telnet client of sorts in C# and part of what I have to parse are ANSI/VT100 escape sequences, specifically, just those used for colour and formatting (detailed [here](http://www.termsys.demon.co.uk/vtansi.htm#colors)).
One method I have is one to find all the codes and remove them, so I can render the... |
Another reasonable solution should be `git-gui`, which requires a Tcl/Tk framework to be installed. |
Can you provide a code snippet to explain your question a bit?
A rather straight forward aproach would be to type cast the object as the collection and directly use that. |
You may want to use the Page.RegisterStartupScript to ensure that the javascript fires on page load. |
office 97:
<br/>
"The universal character set provided by Unicode overcomes this problem. Office 97 was the first version of Office to support Unicode in all applications except Microsoft Access and Microsoft Outlook®. In Office 2000, Access and Microsoft Publisher gain Unicode support. Microsoft FrontPage® 2000 also... |
I think you'll have to do the comparison on a character-by-character fashion. Grab a character, if it's a number character, keep grabbing, then reassemble to characters into a single number string and convert it into an `int`. Repeat on the other string, and only then do the comparison. |
You could generate a SSL client certificate, and have your users install it. From then on, their browser would identify them using their certificate.
* [HOWTO: Securing A Website With Client SSL Certificates](http://it.toolbox.com/blogs/securitymonkey/howto-securing-a-website-with-client-ssl-certificates-11500)
* [... |
Do away with the (in)security questions completely. They're such an obvious security hole that I'm actually a bit surprised that it's taken this long for them to create a serious (well, highly-publicized) incident.
Until they disappear, I'm just going to keep on telling websites which use them that I went to "n4weu... |
This allows the consuming developer the ability to write a single event handler for multiple events, regardless of sender or event.
**Edit:** Why would you need a different pattern? You can inherit EventArgs to provide any amount of data, and changing the pattern is only going to serve to confuse and frustrate any ... |
If your application is creating PARADOX.LCK and PDOXUSRS.LCK files, it is also creating or accessing a PDOXUSRS.NET file somewhere.
The BDE uses a single common PDOXUSRS.NET file, and a PARADOX.LCK and PDOXUSRS.LCK file in each shared directory, to coordinate shared access among the distributed instances of the engi... |
If your colours are in RGB format (or, presumably CMYK), you can use the fairly crude method of increasing the value of each component of the colour. E.g., in HTML colours are represented as three two-digit hex numbers. #ff0000 will give you a bright red, which can then be faded by increasing the values of the G and ... |
If you are using RGB colors I would transform this color paramaters to [HSL][1] (hue, saturation, lightness), modify the lightness parameter and then transform back to RGB. Google around and you'll find a lot of code samples on how to do these color representation transformations (RGB to HSL and viceversa).
This is ... |
When position is absolute, top is vertical distance from the parent (probably the body tag, so 0 is the top edge of the browser window). Left 50% is distance from the left edge. The negative margin moves it back left 445px. As to why, your guess is as good as mine. |
Django's lipsum addon seemed pretty straightforward. As I didn't want to install python just to run this script, I ported it to php.
Here's my PHP version:
[http://pastebin.com/f7c58bbb9][1]
[1]: http://pastebin.com/f7c58bbb9 |
I follow [aarojensen's method][1], but put it in the file menu (right click on the menu and select customize). Then Alt-F-B closes all but the current.
[1]: http://stackoverflow.com/questions/97279/keyboard-shortcut-to-close-all-tabs-but-current-one-in-visual-studio#97298 |
Ok, just to make sure I've got the question right: I'm assuming you have test.c which includes test.h, and you want to generate subdir/test.d (while *not* generating subdir/test.o) where subdir/test.d contains
subdir/test.o: test.c test.h
rather than
test.o: test.c test.h
which is what you get right... |
Err... Just my two cents, but:
void get_sequence(std::vector<int> & p_aInt);
This would remove the potential return by copy problem.
Now, if you really want to avoid imposing a container, you could try something like:
template <typename T>
void get_sequence(T & p_aInt)
{
p_aInt.push... |
Or just don't do GC at all. There can be situations where it's better to just forget the memory leak and let the process clean up after it when it's done.
Depending on your qualms about GC, you might be afraid of the periodic GC sweeps. In this case you could do a selective GC when an item falls out of scope or the ... |
There are some features in an IDE that are so transformative that you don't know how you lived without them. Integrated help was one. IntelliSense-like functionality was another. VS 6.0's Debug and Continue was absolutely killer. Visual Studio kicked butt for quite a while. Not bad, given the awful NeXTstep rip-of... |
[Getting Started With Windows Workflow Foundation][1]
[1]: http://social.msdn.microsoft.com/content/en-us/msft/netframework/wf/GettingStarted |
Do the duplicates necessarily need to be in the list in the first place? There's no overhead as far as looking the elements up, but there is a little bit more overhead in adding elements (though the overhead should be O(1) ).
>>> x = []
>>> y = set()
>>> def add_to_x(val):
... if val not in ... |
WF is a framework for creating workflows. It consists of a type of workflow (state machine or sequential), hosting different "activities" and logic controlling how application flow travels from one activity to another.
You can use it for describing business processes, from page flow in an ASP.NET application to th... |
I like the CSS answer. When you can use CSS instead of Javascript it results in simpler markup.
Another thing to look into is the Community Kit for SharePoint Enhanced Wiki Edition on [Codeplex](www.codeplex.com). You can download the source code and add in your own features. Or you can suggest this as a new featur... |
Something's very broken there. Perl's scoping is relatively simple, and you're unlikely to stumble upon anything odd like that unless you're doing something daft. As has been suggested, switch on the strict pragma (and warnings, too. In fact you should be using both anyway).
It's pretty hard to tell what's going on... |
I had issues along the same lines you do. In order to test the software behavior, I just unplugged the network cable at the appropriate time. I had to set a break-point right before I wanted to unplug the cable.
If I were doing it again, I'd put a switch (a normally closed momentary push button one) in a network... |
download the jsf source and point to the working folder for source lookup..
It will dig into the code |
Half a year ago I took over a large web application (fortunately already in Python) which had some major architectural deficiencies (templates and code mixed, code duplication, you name it...).
My plan is to eventually have the system respond to WSGI, but I am not there yet. I found the best way to do it, is in smal... |
A scripting language is a language that "scripts" other things to do stuff. The primary focus isn't primarily building your own apps so much as getting an existing app to act the way you want, e.g. JavaScript for browsers, VBA for MS Office. |
The web services do allow a loosely coupled architecture. With RMI, you have to make sure that the objects stay in sync in all applications, which means that you always have to deploy both of them at the same time even if only one of them is changed (not necessarily, but it is required quite often because of serial UU... |
We had very much the same problem before we switched to NIO, so I will second Liedmans recommendation to go with that framework. You should be able to find a tutorial, but if you want the details, I can recommend [Java NIO][1] by Ron Hitchens.
Swithcing to NIO increased the number of connections we could handle a lo... |
How do I change the colors displayed in cygwin rxvt? |
|bash|cygwin|rxvt| |
When I use "\[\e[34m\]sometext" i get sometext in blue, but can I specify the shade of blue somewhere? |
The benefit is that you don't need to add an import for everything you use, especially if it's the only thing you use from a particular namespace, it also prevents collisions.
The downside, of course, is that the code balloons out in size and gets harder to read the more you use specific qualifiers.
Personally I ... |
You need a JUnit4 aware TestFactory. I've included one below.
import junit.framework.JUnit4TestAdapter;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import com.clarkware.junitperf.TestFactory;
class JUnit4TestFactory extends TestFactory {
static ... |
Here is the best resource we found to help us pick a Continuous Integration tool. We have been evaluating 5 or 6 tools on this page.
http://confluence.public.thoughtworks.org/display/CC/CI+Feature+Matrix |
How to test if a line segment intersects an axis-aligned rectange in 2D? |
|graphics|geometry|2d| |
How to test if a line segment intersects an axis-aligned rectange in 2D? The segment is defined with its two ends: p1, p2. The rectangle is defined with top-left and bottom-right points. |
I generally use the shortest form available in order to keep the code as clean and readable as possible. That's what using directives are for, after all, and tooltips in the VS editor give you instant detail on the provenance of a type.
I also tend to use a namespace tag for RCWs in a COM interop layer, to call out... |
For me OMP support in "standard" is what's nice to have, if your into that |
Try a regular expression. Something like this should work:
(html =~ /<a.*href='(.*?)'.*>(.*?)<\/a>/).each { url, text ->
// do something with url and text
}
Take a look at [Groovy - Tutorial 4 - Regular expressions basics][1] and [Anchor Tag Regular Expression Breaking][2].
[1]: http://g... |
Have your decode function return an object of type Array, which is the base class of all arrays. Then people who care about the type can do "if (a is ushort[,])" and so on if they want to go through the pixels. If you do it this way, you need to allocate the array in ImageData, not the other way around.
Alternativ... |
Disclaimer: I work for a .NET Imaging vendor ([Atalasoft][1])
Our product doesn't do this, but you might be looking for Seam carving. I wrote this application
[http://www.atalasoft.com/cs/blogs/31appsin31days/archive/2008/05/26/simple-seam-carver.aspx][2]
with our library that could be ported to just using t... |
Disclaimer: I work for a .NET Imaging vendor ([Atalasoft][1])
It depends on what kind of image you are talking about. If you are talking about 1-bit document images (like faxes or scans) we can do this.
If you are talking about photographs, our product doesn't do this, but you might be looking for Seam carving. ... |
> top is like padding from the top right?
Yes, the top of the page.
> what does left 50% do?
It moves the content to the center of the screen (100% would be all the way to the right.)
> why is the left margin at -445px?
After moving it with "left: 50%", this moves it 445 pixels back to the left. |
You'll find out every thing you need to know by reading up on the [CSS box model][1]
[1]: http://www.w3.org/TR/CSS2/box.html |
I realize you're in java, but you can take a look at how StrCmpLogicalW works. It's what Explorer uses to sort filenames in Windows. You can look at the WINE implementation [here][1].
[1]: http://source.winehq.org/source/dlls/shlwapi/string.c#L2113 |
The future of Functional programming |
|functional-programming| |
Joel Spolsky [praise][1] compiled version of program. How are with the functional programming? What are compilers for functional languages?
[1]: http://www.joelonsoftware.com/articles/PleaseLinker.html |
Because it's a good pattern for any callback mechanism, regardless of language. You want to know who sent the event (the sender) and data that is pertinent to the event (EventArgs). |
scp will do the job, but there is one wrinkle: the connection to the second remote destination will use the configuration on the first remote destination, so if you use .ssh/config on the local environment, and you expect rsa and dsa keys to work, you have to forward your agent to the first remote host. |
STL map does not have to "resize" container. map (just like list) is a node based container; each insert allocates memory.
That said, out of memory situation is handled just like any other out-of-memory situation in C++: it throws a std::bad_alloc. STL containers with default allocators don't do anything fancy, they... |
STL map does not have to "resize" container. map (just like list) is a node based container; each insert allocates memory.
That said, out of memory situation is handled just like any other out-of-memory situation in C++: it throws a std::bad_alloc. STL containers with default allocators don't do anything fancy, they... |
In my opinion, you should pick a mainstream database (such as Oracle) and study everything it offers and go from there.
Oracle offers:
- Replication
- Data guard (standby database and beyond- physical, logical)
- Real Application Clusters - (multiple instances, one DB)
and more !
A bit of hands-o... |
The <tt>if-else</tt> implementation you have is the right way to do this, since <tt>switch</tt> won't work with objects. Apart from maybe being a bit harder to read (which is subjective), there is no real downside in using <tt>if-else</tt> statements this way.
|
The `if-else` implementation you have is the right way to do this, since `switch` won't work with objects. Apart from maybe being a bit harder to read (which is subjective), there is no real downside in using `if-else` statements this way.
|
I don't think you can use the same webflow definition with the actions configured in two different ways.
If you want to use different actions you'll either have to reconfigure your action beans then redeploy your app or create a separate webflow definition with the differently configured beans.
[This][1] is a gre... |
InfoQ have a free eBook:
[Domain Driven Design Quickly][1]
It is a good read with plenty of examples.
[1]: http://www.infoq.com/minibooks/domain-driven-design-quickly |
Your criteria sounds about right,but is always a bit fuzzy. For instance, Java is both compiled (to bytecode) and then interpreted (by the JVM). Yet it is normally not categorized as a scripting language.
This might be because Java is statically typed. Where as JavaScript, Ruby, Python, Perl etc. are not (all of wh... |
How to return multiple rows from the stored procedure? (Oracle PL/SQL) |
|sql|oracle-database|plsql| |
I want to create a stored procedure with one argument which will return different sets of records depending on the argument. What is the way to do this? |
I want to create a stored procedure with one argument which will return different sets of records depending on the argument. What is the way to do this? Can I call it from plain SQL? |
I guess it has to do with the fact that the JVM is coded in C++. Apart from that, pointers and references are nearly similar. You could say that the reference mechanism in Java is implemented using C++ pointers and the name 'NullPointerException' allows that implementation detail to shine through. |
There is nothing wrong with this code and you can still use it with Dependency Injection frameworks like Spring and Guice.
Many developers see Spring's XML configuration file as an advantage over wiring dependencies within code as you can switch implementations without needing a compilation step. This benefit actua... |
There is nothing wrong with this code and you can still use it with Dependency Injection frameworks like Spring and Guice.
Many developers see Spring's XML configuration file as an advantage over wiring dependencies within code as you can switch implementations without needing a compilation step. This benefit actua... |
I've developed a site with IE8 compatibility as a requirement, and it wasn't a problem as long as I tested in IE8 from the beginning. IE8's standards are very close to most other standards compliant browsers at this point.
If you can't (or won't) do that, you can usually get your page or site working in IE8 with a s... |
I've developed a site with IE8 compatibility as a requirement, and it wasn't a problem as long as I tested in IE8 from the beginning. IE8's standards are very close to most other standards compliant browsers at this point.
If you can't (or won't) do that, you can usually get your page or site working in IE8 with a s... |
If it's a big project a framework might be in order. If not, create some template files and at the top of the page decide which template file to include.
for example
if ($_SESSION['logged_in'])
include(TPL_DIR . 'main_logged_in.tpl');
else
include(tPL_DIR . 'main.tpl');
just a sim... |
A couple years ago I used [FreeImage][1] in a program that needed to load some relatively big images (12-mega-pixel images). It performed really well (waaaay better than GDI+) and the API is quite simple to understand and start using. I even wrote a .NET wrapper and I think I still have it laying around somewhere, but ... |
Sounds like you should make <code>callFoo</code> a pure virtual function and create some subclasses of <code>A</code>.
Unless you really need the speed, have done extensive profiling and instrumenting, and determined that the calls to <code>callFoo</code> are really the bottleneck. Have you? |
The output of [this][1] is in GNU diff format. It might be what you're looking for.
[1]: http://www.holomind.de/phpnet/diff2.php |
I asked a similar question a while ago [Calendar in HTML][1] and everyone told me to use tables too. <p> If you have made an igoogle home page, just yoink their code.
I made a system of columns and sections within the columns for a page. Notice with google you can't have an infinite number of columns and that offend... |
Try:
set sw=2
set ts=2
set smartindent
|
Exchange drop support for SMTP? |
|exchange-server|smtp|port|25|telnet| |
I want to send email with Exchange by using telnet to port 25. Until two week ago I was able to, but now a "security fix" from Microsoft has removed this possibility.
When I try, I get this message:
421 4.3.2 Service not available, closing transmission channel
What can I do? |
|smtp|exchange-server|telnet| |
These two commands should do it:
:set autoindent
:set cindent
For bonus points put them in a file named .vimrc located in your home directory on linux |
Another interesting solution might be to do this:
<a href="#" itemid="<%itemid%>" itemname="<%itemname%>" onclick="SelectSurveyItem(this.itemid, this.itemname); return false;">Select</a>
Then you can use a standard HTML-encoding on both the variables, without having to worry about the extra complication of th... |
Found It. Not so easy to do apparently, there is no built in Stroke text in WPF (kind of a big missing feature if you ask me). First create the custom class:
using System;
using System.Windows.Media;
using System.Globalization;
using System.Windows;
using System.Windows.Markup;
names... |