instruction stringlengths 0 30k ⌀ |
|---|
That 100% coverage is a myth, which it is, does not mean that 80% coverage is useless. The goal, of course, is 100%, and between unit tests and then integration tests, you can approach it.<br><br>What is impossible in unit testing is predicting all the totally *strange* things your customers will do to the product. Onc... |
Anything that needs a very large and complicated setup. Ofcourse you can test ftp (client), but then you need to setup a ftp server. For unit test you need a reproducible test setup. If you can not provide it, you can not test it. |
These 2 questions might help you: [Utilizing machine.config][1] and [Managing app.config for large projects][2]
[1]: http://stackoverflow.com/questions/94053/how-are-you-using-the-machineconfig-or-are-you
[2]: http://stackoverflow.com/questions/89245/how-do-you-manage-net-appconfig-files-for-large-application... |
ResourceManager and Unit Testing |
|c#|asp.net|asp.net-mvc|resources| |
I was curious if anyone had any problems creating unit tests around using the ResourceManager. I am using Visual Studio test edition and it appears that the satellite assemblies don't get loaded during the test. When I try to get a resource for another culture, the test always fails and the resource manager always fa... |
I've had similar problems in the past with satellite assemblies. Try
adding the satellite assemblies to the unit projects dependecies. In Visual Studio
Test -- Edit Test Run configuration. Select Deployment and add the files
here.
On executing all applications, dlls, etc are copied to a special directory.
St... |
Grab the javascript [ext][1] library. It has functionality for overlays that are modal.
[1]: http://extjs.com/ |
Scalable socket event queue processing |
|c#|sockets|networking|tcp|stream| |
My C# class must be able to process a high volume of events received via a tcp stream style socket connection. The volume of event messages received from the tcp server by the class's socket is completely variable. For instance, sometimes it will only receive one event message in a period of ten seconds and at other ti... |
There are two sides to this story.
AJAX generally improves the performance from the client's perspective. Rather than loading an entire page, a smaller amount of data is requested from the server when it is needed. Given that a HTML page often references many dependent files (images, css, javascript,etc, each requir... |
I use subversion on my thumb drive, the official binaries will work right off the drive. The problem with this trick is you need to access a command line for this to work or be able to run batch files. Of course, I sync the files on my thumb drive to a server that I pay for. You could always host the repository on a de... |
How can I get that huge security icon on my secure site? |
|security| |
If I go to www.paypal.com, Firefox displays a huge icon in the location bar. Is it possible to get my web site to do this without paying $2700 to Verisign? Where is the best place to buy SSL certificates and not break the bank? |
Just run the standard NTP daemon.
It does have options to take input from several GPS devices as well as talking to network servers. |
Just run the standard NTP daemon.
It does have options to take input from several GPS devices as well as talking to network servers.
Edit: I was referring to <http://www.ntp.org/>, not the one that comes with Windows.
I don't have any suggestion as to what NTP clients are best for windows, but for Unix machine... |
They work equally well. Performance is about the same given a modern compiler.
I prefer if statements over case statements because they are more readable, and more flexible -- you can add other conditions not based on numeric equality, like " || max < min ". But for the simple case you posted here, it doesn't real... |
I think you'll find IDE's invaluable once you get into them. The code complete and navigation features, integrated running/debugging, and all the other little benefits really add up.
Some suggestions for starting out and easing transition:
- start by going through a tutorial or demonstration included with the IDE ... |
If you need you need the MAC address you are going to require JNI. I use a library called [JUG][1] to generate UUIDs based using the real MAC address of the machine. You can consult their [source code][2] to see how this is accomplished on Linux, Solaris, Windows and Mac platforms.
[1]: http://jug.safehaus.org/
... |
switch is definitely preferred. It's easier to look at a switch's list of cases & know for sure what it is doing than to read the long if condition.
The duplication in the `if` condition is hard on the eyes. Suppose one of the `==` was written `!=`; would you notice? Or if one instance of 'numError' was written... |
Encrypt/Decrypt across machines is a no-no |
|windows-vista|encryption|crypt| |
Registry key that contains the folder for the local user's Programs folder on Vista |
|registry|windows-vista| |
I'm troubleshooting a problem with creating Vista shortcuts.
I want to make sure that our Installer is reading the Programs folder from the right Registry entry.
It's reading it fromK
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Programs
And it's showing this director... |
|windows-vista|registry| |
I too would use HTTPS all the way. This doesn't have a big performance impact (since browser cache the negociated symmetric key after the first connection) and protects against sniffing.
Sniffing was once on its way out because of fully switched wired networks, where you would have to work extra hard to capture anyo... |
I'm using [tut-framework][1]
[1]: http://tut-framework.sourceforge.net/ |
I've previously done some experimenting with throughput on gigabit links on relatively standard pc hardware, albeit doing just transmits (via [tcpreplay][1]), rather than udp.
The biggest bottleneck that I found was in just getting packets to the NIC itself. This can be significantly improved by using a high speed b... |
How do you recursively unzip archives in a directory and its subdirectories from the Unix command-line? |
|unix|spaces|unzip|recursion| |
The <code>unzip</code> command doesn't have an option for recursively unzipping archives.
If I have the following directory structure and archives:
<pre>
/Mother/Loving.zip
/Scurvy/Sea Dogs.zip
/Scurvy/Cures/Limes.zip
</pre>
And I want to unzip all of the archives into directories with the same name as eac... |
Associating a ListView with a collection of objects |
|c#|listview|dictionary| |
How can you use a ListView to show the user a collection of objects, and to manage those objects? |
For the purpose of argument, here's our design goal: We've got a "monster" object, and that "monster" will have several "powers." The user interacts with the powers via a ListView item.
First, we create a Power object. Give the object the following method:
public ListViewItem makeKey()
{
return ... |
How exposed is CollectionBase from the inherited class?
Are there things that Generics could do better than CollectionBase?
I mean this class is heavily used, but it is only one class. Key to refactoring is not disturbing the program's status quo. The class should always maintain its contract with the outside wor... |
I don't think there is any specific UML notation for showing events that a Class can broadcast. To show events that a Class can receive, you want a Reception element. This has a similar notation to an Operation, with the signal keyword. |
I don't think there is any specific UML notation for showing events that a Class can broadcast. To show events that a Class can receive, you want a Reception element. This has a similar notation to an Operation, with the «signal» keyword. |
I would like to encrypt strings which could potentially only be about three or four characters but run to about twenty characters. A hashing function ([md5][1], [sha1][2], [crypt][3] etc) is not suitable as I would like to be able to decrypt the information as well. The [mcrypt][4] extension has a thoroughly daunting a... |
I'm using it on my work machine, but that's about it. It's been stable for me, and I like the barebones UI. I'll still switch to Firefox for the web developer extensions however. |
Caching Data Objects when using Repository/Service Pattern and MVC |
|asp.net-mvc|caching|design-patterns| |
I have an MVC-based site, which is using a Repository/Service pattern for data access.
The Services are written to be using in a majority of applications (console, winform, and web). Currently, the controllers communicate directly to the services. This has limited the ability to apply proper caching.
I see my op... |
you can use a PhaseListener to convert POST requests to GET requests or just to interpret GET requests so that they can be bookmarkable.
This page should explain in more detail:
http://balusc.blogspot.com/2007/03/post-redirect-get-pattern.html |
It may be easier to create a parallel table for deleted rows. A `DELETE` trigger (and `UPDATE` too if you want to undo changes as well) on the original table could copy the affected rows to the parallel table. Adding a datetime column to the parallel table to record the date & time of the change would let you permanent... |
Use a to_char(field,'YYYYMMDD HH24MISS').
A good list of date formats is available at http://www.ss64.com/orasyntax/fmt.html
|
I like to use GnuPG for anything that needs to be encrypted on a server and then possibly decrypted either on the server or on another server (which is usually my case). This allows for an extra level of security since in my scenario the encrypting server doesn't have the key to decrypt the data. It also allows for eas... |
|winforms|controls| |
- The GoDiagram object model has a GoDocument.
- GoViews have a reference to a GoDocument.
- If the user does any modification on the diagramming surface, a GoDocument.Changed event is raised with the relevant information in the event arguments.
I would like to be notified when some user-actions happen, so ... |
Everything you execute in the server happens in a transaction, either implicit or explicit.
You can not simply lock a row with no transaction (make the row read only). You can make the database read only, but not just one row.
Explain your purpose and it might be a better solution. Isolation levels and lock hint... |
Since VB.NET is not case-sensitive, I prefix my member variables with an underscore and camel case the rest of the name. I capitalize property names.
Dim _valueName As Integer
Public Property ValueName() As Integer
|
To answer the second part of your question, if you want to get a handle on how a simple 2D platformer works, take a read through the [tutorials for N][1]. Yes, N is a flash-based game but that doesn't mean it isn't constructed like a "real" game, so the collision detection (and response) tutorials are very much applica... |
You can use [RowLock or other hints][1] but you should be [careful][2]..
The HOLDLOCK hint will instruct SQL Server to hold the lock until you commit the transaction. The ROWLOCK hint will lock only this record and not issue a page or table lock.
The lock will also be released if you close your connection or it t... |
Breaking at 80 characters is something you do <b>while</b> coding, not afterwards. Same with comments, of course. Most editors can assist you in seeing where the 80-characters limit is.
(This may be a little OT, but in Eclipse there is an option which formats the code when you save it (according to whatever rules yo... |
The latter example probably doesn't work because of [CSS Specificity](http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html) ([A more serious explanation](http://www.htmldog.com/guides/cssadvanced/specificity/)). That is, YUI's base.css rule is:
ul li{ list-style: disc outside; }
Which is more ... |
In C#:
ArrayList list = ...;
// List<object> list = ...;
foreach (object o in list) {
if (o.GetType() == typeof(int)) {
HandleInt((int)o);
}
else if (o.GetType() == typeof(string)) {
HandleString((string)o);
}
...
}
In Java:... |
In C#:
ArrayList list = ...;
// List<object> list = ...;
foreach (object o in list) {
if (o.GetType() == typeof(int)) {
HandleInt((int)o);
}
else if (o.GetType() == typeof(string)) {
HandleString((string)o);
}
...
}
In Java:... |
In C#:<br/>Fixed with recommendation from [Mike](http://stackoverflow.com/users/14359/mike-brown)
ArrayList list = ...;
// List<object> list = ...;
foreach (object o in list) {
if (o is int) {
HandleInt((int)o);
}
else if (o is string) {
HandleString... |
Here's one solution that involves the find command and a while loop:
find . -name "*.zip" | while read filename; do unzip -o -d "`basename -s .zip "$filename"`" "$filename"; done; |
Optimal multiplayer maze generation algorithm |
|language-agnostic|algorithm|maze| |
I'm working on a simple multiplayer game in which 2-4 players are placed at separate entrypoints in a maze and need to reach a goal point. Generating a maze in general is very easy, but in this case the goal of the game is to reach the goal before everyone else and I don't want the generation algorithm to drastically ... |
I have had great luck with [GeoTrust][1]. No options that I know of are what I would call "cheap", but you can do better than Verisign pricing and GeoTrust is one place where that is true.
[1]: http://www.geotrust.com |
If you're talking about the database password, as opposed to the password coming from a browser, the standard practice seems to be to put the database password in a PHP config file on the server.
You just need to be sure that the php file containing the password has appropriate permissions on it. I.e. it should be r... |
[HubSpot][1] does this for you. It costs money but they do a lot of useful things like this.
[1]: http://www.hubspot.com/ |
What is the simplest way to interact between a SAP OMS and Websphere Commerce?? |
|sap|webmethods|websphere-commerce|adaptor|wcs| |
Would it be using a Websphere Adaptor for SAP or webmethods or something else?? Does something else need to be considered while opting for one of these??? The final system needs to be synchronous between SAP and the WCS front end.No ques..no delays.... |
Just putting it into a config file somewhere is the way it's usually done. Just make sure you A) disallow database access from any servers outside your network, B) take care not to accidentally show the password to users (in an error message, or through PHP files accidentally being served as HTML, etcetera.) |
Your choices are kind of limited as as you say you need the password to access the database. One general approach is to store the username and password in a seperate configuration file rather than the main script. Then be sure to store that outside the main web tree. That was if there is a web configuration problem tha... |
I'd consider experimenting with sprints that are shorter then one month.
Personally I find one-two week iterations more effective at getting effective feedback quickly. It also prevents any issues that may be causing problems at the iteration level building up to levels that become harder to manage.
Even for the... |
In addition to encrypting the passwords as described above put any passwords in separate properties file and on deployment try to give this file the most locked down permissions possible.
For example, if your Application Server runs on Linux/Unix as `root` then make the password properties file owned by `root` with ... |
The way to do it is to use `bindSetter`. That is also how it is done behind the scenes when the MXML in your example is transformed to ActionScript before being compiled.
// assuming the itemName property is defined on this:
BindingUtils.bindSetter(itemNameChanged, this, ["itemName"]);
// ...
... |
The other option would be to create a delete trigger on each table. When anything is deleted, it would insert that "to be deleted" record into another table, ideally named TABLENAME_deleted.
The downside would be that the db would have twice as many tables.
I don't recommend triggers in general, but it might... |
It's really tough to handle a 4G file as such. I used to handle larger text files, but I never used to load them in to my editor. I mostly used UltraEdit in my previous company, now I use Notepad++, but I would get just those parts which i needed to edit. (Most of the cases, the files never needed an edit).
Why do u... |
What OS and CPU are you using? If you are using a 32-bit OS, then a process on your system physically cannot address more than 4GB of memory. Since most text editors try to load the entire file into memory, I doubt you'll find one that will do what you want. It would have to be a very fancy text editor, that can do ... |
How is AJAX implemented, and how does it help web dev? |
|ajax|resources| |
From http://en.wikipedia.org/wiki/AJAX, I get a fairly good grasp of what AJAX is. However, it looks like in order to learn it, I'd have to delve into multiple technologies at the same time to get any benefit out of it. So two questions:
- What are resources that can help me understand/use AJAX?
- What sort of webs... |
Maybe pull all the color information into one part of your stylesheet. For example change this:
p .frog tr.mango {
color: blue;
margin: 1px 3em 2.5em 4px;
position: static;
}
#eta .beta span.pi {
background: green;
color: red;
font-size: small;
... |
I've had success pulling in dlls of vb projects with [Reflector][1](it's free) and viewing the code as C#. Local variables don't always translate but you can compare the translation and refactor things as you go.
[1]: http://www.red-gate.com/products/reflector/ |
If you can't wait for the delivery of RubyEncoder, then I think ZenObfuscate is the most promising. Though it may require some modifications to your source code, they do say this on their site:
> ZenObfuscate costs $2500 for a site license or is individually negotiable for other licensing schemes. Yes, that is expe... |
Just add an «event» stereotype to a classifier attribute. |
I'm not sure I understand the question. Let me try:
The service you mention, is it yours? If so, you can add code to it to imitate Windows: from your service, examine the RunOnce value and launch the executable it specifies. You can use the CreateProcessAsUser() API to launch it in the context of an arbitrary user. ... |
I'm not sure I understand the question. Let me try:
The service you mention, is it yours? If so, you can add code to it to imitate Windows: from your service, examine the RunOnce value and launch the executable it specifies. You can use the CreateProcessAsUser() API to launch it in the context of an arbitrary user. ... |
This is such an important concept and it saddens me that so few web developers understand it.
Basically, start by building a site/framework in Plain Old HTML -- structural elements, links and forms. Then add on some style and then shiny stuff (Ajax or what have you).
It's not very difficult. Like [palehorse][1] s... |
I cover this in one of my large apps by just making sure that the tables/models are conceptually grouped by name (with almost 1:1 table-model relationship). Example:
events
event_types
event_groups
event_attendees
etc...
That way when I'm using TextMate or whatever, the model files are ni... |
Try Zend_Config and Zend Framework in general.
I imagine it would be a 2 step process: array to Zend\_Config, Zend_Config to XML. |
Something like gunzip using the -r flag?....
Travel the directory structure recursively. If any of the file names specified on the command line are directories, gzip will descend into the directory and compress all the files it finds there (or decompress them in the case of gunzip ).
http://www.computerhope.com/u... |
Previously I was use WM for different versions of IE, but I find out some new tool for testing layout, and UI as well with this tool, [link][1] for FF use fire bug extension, those tools are for manually testing.
[1]: http://www.my-debugbar.com/wiki/IETester/HomePage |
How can I get the filetype icon that Windows Explorer shows? |
|c#|winforms| |
first question here. I'm developing a program in C# (.NET 3.5) that displays files in a listview. I'd like to have the "large icon" view display the icon that Windows Explorer uses for that filetype, otherwise I'll have to use some existing code like this:
private int getFileTypeIconIndex(string fileName... |
The easiest solution I can come up with is to randomly generate an entire maze like normal, then randomly pick the goal point and player startpoints. Once this is done, calculate the shortest path from each startpoint to the goal. Find the average and start 'smoothing' (remove/move barriers -- don't know how this wil... |
<p>Well, after lots of further work, I decided I didn't need to access my diagram **from within** a custom DirectiveProcessor.</p>
<p>I've still got a custom DirectiveProcessor because the standard generated one doesn't load the existing diagram when it loads the domain model.</p>
<p>Getting a custom DirectiveProcess... |
Web interface tool for debian repository? |
|web-applications|debian|packaging| |