instruction stringlengths 0 30k ⌀ |
|---|
Rhino Mocks: How can I mock out a method that transforms its input? |
|c#|.net|rhino-mocks| |
I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like for it to setting a transaction.IsSaved=true flag (this is a simplification the actual thing I'm trying to do is not quite so banal). So when mocking my TransactionDao with RhinoMocks how can I indicate that it sho... |
I have a Data Access Object TransactionDao. When you call TransactionDao.Save(transaction) I would like for it to setting a transaction.IsSaved=true flag (this is a simplification the actual thing I'm trying to do is not quite so banal). So when mocking my TransactionDao with RhinoMocks how can I indicate that it sho... |
As far as I know, the Google's one is the best that there is. It hasn't been broken by computer programs yet. What I know that the crackers have been doing is to copy the image and then send it to many phishing websites where humans solve them to enter those websites. |
If you're a small enough site, no one would bother.
If you're still looking for a CAPTCHA, I like [tEABAG_3D][1] by the [OCR Research Team][2]. It's complicated to break and uses your 3D vision. Plus, it being developed by people who break CAPTCHAs for fun.
[1]: http://ocr-research.org.ua/teabag.html
[2]: ... |
For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. Ctrl-L for a screen redraw can also fix it.
|
I don't think that this can be accomplished without using recursion. You can accomplish it with with a single stored procedure using mySQL, but recursion is not allowed in stored procedures by default. [This article][1] has information about how to enable recursion. I'm not certain about how much impact this would h... |
When writing an application for multilingual use, I use Microsoft's [Best Practices for Developing World-Ready Applications][1], which includes retrieving the current CultureInfo from the OS and using that as the default language pack.
[1]: http://msdn.microsoft.com/en-us/library/w7x1y988.aspx "Best Practices fo... |
Valgrind under linux is fairly good; I have no experience under Windows with this. |
I don't know what your needs are, but you might want to consider [Google Checkout](http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_NET.html). [Joe Audette](http://www.joeaudette.com/paypal-sandbox-doesnt-work.aspx) was having considerable difficulty integrating PayPal.
I've [used](http://ww... |
I've had minimal love for any memory leak detectors. Typically there are far too many false positives for them to be of any use. I would recommend these two as beiong the least intrusive:
[GlowCode][1]
[Debug heap][2]
[1]: http://www.glowcode.com/
[2]: http://msdn.microsoft.com/en-us/library/974tc9t1(VS... |
Message based authentication, which is WS-Security based, is what you're looking for and is definitely supported by basicHttpBinding and netTcpBinding. I think you are making the mistaken assumption that only WsHttpBinding will support WS-Security, which is inaccurate.
The WS bindings are for WS-* elements other ... |
I think you might look at:
[Autumn][1]
[Storm][2]
[1]: http://autumn-orm.org/
[2]: https://storm.canonical.com/ |
I usually debug this by going the the manager page and making sure that all of the contexts are deployed (http://localhost:8080/manager/html).
It sounds like app2 has not been deployed properly or is not starting up because of some other error.
I would look at the logs. There may be a bunch of information in the... |
second the [valgrind][1]... and I'll add [electric fence][2].
[1]: http://valgrind.org/
[2]: http://directory.fsf.org/project/ElectricFence/ |
I think it's a wise decision made by the Hibernate team. They could be less arrogante and make it clear why it was implemented this way, but that's just how Emmanuel, Chris and Gavin works. :)
Let's try to understand the problem. I think your concepts are "lying". Firts you say that many **Problem**s are associated ... |
|visual-studio|makefile| |
Can you clone the collection and then redirect to the page with the cloned (and modified) collection?
I know it's not much better than iterating... |
What work has been done on cross-platform mobile development? |
|iphone|mobile|android|blackberry| |
Have any well-documented or open source projects targeted iPhone, Blackberry, and Android? Are there other platforms which are better-suited to such an endeavor? Note that I am particularly asking about client-side software, not web apps, though any information about the difficulties of using web apps across multiple m... |
What's the state of play with "Visual Inheritance" |
|visual-studio|forms|visualinheritance|windowsforms| |
We have an application that has to be flexible in how it displays it's main form to the user - depending on the user, the form should be slightly different, maybe an extra button here or there, or some other nuance. In order to stop writing code to explicitly remove or add controls etc, I turned to visual inheritance ... |
|winforms|forms|visual-studio|visual-inheritance| |
|visual-studio|winforms|forms|visual-inheritance| |
I think that C# and VB.NET do a good job with generics. |
Assuming you have access to STL:
std::string filename("filename.conf");
std::string::size_type idx;
idx = filename.rfind('.');
if(idx != std::string::npos)
{
std::string extension = filename.substr(idx+1);
}
else
{
// No extension found
}
**Edit:**... |
The best way is to not write any code that does it but call existing methods. In windows, the [PathFindExtension][1] method is probably the simplest.
So why would you not write your own?
Well, take the strrchr example, what happens when you use that method on the following string "c:\program files\AppleGate.Net\... |
You'd have to reconstruct the url and then redirect. Something like this:
string url = Request.RawUrl;
NameValueCollection params = Request.QueryString;
for (int i=0; i<params.Count; i++)
{
if (params[i].GetKey(i).ToLower() == "foo")
{
url += string.Concat((i==... |
As I develop more with vim, I find myself wanting to copy in blocks of useful code, similar to "templates" in Eclipse.
I was thinking of making a separate file for each code chunk and just reading them in with
:r code-fornext
but that just seems kind of primitive. Googling around I find vim macros mention... |
<a href="http://ulf.wiger.net/weblog/2008/02/06/what-is-erlang-style-concurrency/">Ulf Wiger</a> had a great post recently on this topic - here are the properties he defines as required before you can call something "Erlang Style Concurrency":
<ul>
<li>Fast process creation/destruction</li>
<li>Ability to support ... |
I don't know of any documented "patterns" for processing.
I believe one of the oldest libraries/APIs for handling arguments is getopt. Googling "getopt" shows lots of man pages and links to implementations.
Generally, I have a preferences or settings service in my application that the argument processor knows ho... |
I find that if I wait until the end of writing some new feature to test, I forget many of the edge cases that I thought might break the feature. This is ok if you are doing things to learn for yourself, but in a professional environment, I find my flow to be the classic form of: Red, Green, Refactor.
**Red**: Write... |
|xml|syntax| |
For me **usable** means that:
- it's being used in real-wold
- it has tools support. (at least some simple editor)
- it has human readable syntax (no angle brackets please)
Also I want it to be as close to XML as possible, i.e. there must be support for attributes as well as for properties. So, no [YAML]... |
For me **usable** means that:
- it's being used in real-wold
- it has tools support. (at least some simple editor)
- it has human readable syntax (no angle brackets please)
Also I want it to be as close to XML as possible, i.e. there must be support for attributes as well as for properties. So, no [YAML]... |
For me **usable** means that:
- it's being used in real-wold
- it has tools support. (at least some simple editor)
- it has human readable syntax (no angle brackets please)
Also I want it to be as close to XML as possible, i.e. there must be support for attributes as well as for properties. So, no [YAML]... |
Some more information would be nice to have to be able to give you a decent answer. Do you have any existing code snippets you could publish here?
|
Some more information would be nice to have to be able to give you a decent answer. Do you have any existing code snippets you could publish here?
The general idea is to use the XmlDataSource.XPath property as a filter on the XmlDataSource.Data property. Did you try displaying the contents of the Data prop in your t... |
Improving Python readability? |
|python|readability| |
I've been really enjoying Python programming lately. I come from a background of a strong love for C-based coding, where everything is perhaps more complicated than it should be (but puts hair on your chest, at least). So switching from C to Python for more complex things that don't require tons of speed has been more ... |
Generally speaking if your application is single threaded, you're not going to get much use out of the lock statement. Not knowing your application exactly, I don't know if they're useful or not - but I suspect not. Further, if you're application is using lock everywhere I don't know that I would feel all that confiden... |
VBScript conditional short-circuiting workaround |
|vbscript|asp-classic| |
I have a large classic ASP app that I have to maintain, and I repeatedly find myself thwarted by the lack of short-circuit evaluation capability. E.g., VBScript won't let you get away with:
if not isNull(Rs("myField")) and Rs("myField") <> 0 then
...
...because if Rs("myField") is null, you get an error... |
I am not aware of any automated tools for making that conversion. Personally I would suggest you stick with Delphi, maybe just upgrade to a new version. I have seen a couple code DOM's that attempt to convert from Delphi to C#, but that doesn't address the library issue.
CodeGear (formally Borland) has a tool fo... |
yes, you can write a wrapper class around your connection pool, and a wraper around the connection
so lets say you have:
<pre>
OracleConnection conn=connectionPool.getConnection("java:scott@mydb");
</pre>
Change it to:
<pre>
public class LoggingConnectionPool extends ConnectionPool{
public OracleConnection get... |
When building a Handler, should it be .ashx or .axd? |
|asp.net| |
Say I'm building an ASP.Net class that inherits from IHttpHandler, should I wire this up to a URL ending in .ashx, or should I use the .axd extension?
Does it matter as long as there's no naming conflict? |
Ahh.. ScottGu says it doesn't matter, but .ashx is slightly better because there's less chance of a conflict with things like trace.axd and others. That's why the flag went up in my head that .ashx might be better.
http://forums.asp.net/t/964074.aspx
|
Out in "the wild", .ashx are definitely the most popular extension. |
In the end we have ended up building our own external tools to manage this. Our devs work in the english string table and every automated build sends our strings that have been added/changed and deleted to translation manager. He can also run a report at anytime from an old build to determine what is required for trans... |
Subversion Repository Redundancy |
|subversion|repository|redundancy| |
What is the best way to create redundant subversion repositories?
I have a subversion repository (linked through apache2 and WebDAV) and would like to create a mirror repository on a different server in the event of outages, but I am not certain of the best way to proceed.
I am thinking that post-commit scripts c... |
|svn|subversion|repository|redundancy| |
There is no point in having locks in the app if there is only one thread and yes, it is a performance hit although it does take a fair number of calls for that hit to stack up into something significant. |
You *can* have performance issues with locking variables, but normally, you'd construct your code to minimize the lengths of time that are spent inside a 'locked' block of code.
As far as removing the locks. It'll depend on what exactly the code is doing. Even though it's single threaded, if your object is implement... |
Yes, there will be some performance penalty when using lock but it is generally neglible enough to not matter.
Using locks (or any other mutual-exclusion statement or construct) is generally only needed in multi-threaded scenarios where multiple threads (either of your own making or from your caller) have the opport... |
Nested IFs (only slightly less verbose):
if not isNull(Rs("myField")) Then
if Rs("myField") <> 0 then |
Lock(token) is only used to mark one or more blocks of code that should not run simultaneously in multiple threads. If your application is single-threaded, it's protecting against a condition that can't exist.
And locking does invoke a performance hit, adding instructions to check for simultaneous access before code... |
Delphi Network programming |
|delphi|network-programming| |
I have a classic client/server (fat client and database) program written in Delphi 2006. When certain conditions are met in the client, I need to notify all the other clients very quickly. Up until now this has been done using UDP broadcasts, but this is no longer viable as clients now connect from outside the LAN and ... |
|delphi|network-programming|udp| |
Hmm.
I think its a wash and depends on your particular design model. Definitely factor out entities that have more than a few fields out into their own table, or entities whose makeup will likely change as your application's requirements changes (for instance - I'd factor out address anyways, since it has so many fi... |
I would recommend using a command line processor library. [Some Russian guy][1] created a decent one, but there are tons of them out there. Will save you some time so you can concentrate on the purpose of your app rather than parsing command line switches!
[1]: http://netcode.ru/dotnet/?lang=&katID=30&skatID=268... |
In order of preference
* [Neo Freerunner](http://en.wikipedia.org/wiki/Neo_FreeRunner)
* Maemo & the N800 (cheap)
* [Beagleboard](http://beagleboard.org/)
|
It can be done, it will just take some work.
You will need to create a class that inherits off of the ActiveDirectoryMemberhsipProvider and use it has your provider instead. That way you can maintain most of the functionality. Then setup a way to specify two connectionStringName properties, one for primary and one... |
You didn't mention the language, but for Java we've loved [Apache Commons CLI][1]. For C/C++, getopt.
[1]: http://commons.apache.org/cli/ |
One way is Theo's way with NSTask, NSPipe and NSFileHandle. You can start by looking at the code to CouchDBX http://couchprojects.googlecode.com/svn/trunk/unofficial-binary-releases/CouchDBX/
Ports are possible but not nice at all.
Is there some reason for why this communication can't simply be handled with moch... |
Do you want something exactly like the Delicious bookmarklet (as in, something the user actively clicks on to submit the URL)? If so, you could probably just copy their code and replace the target URL:
javascript:(function(){
location.href='http://example.com/your-script.php?url='+
encodeURICom... |
I remember reading that there was a client in development, and I believe they're still looking for beta testers. See this URL
[http://support.fogcreek.com/default.asp?fogbugz.4.24403.0][1]
[1]: http://support.fogcreek.com/default.asp?fogbugz.4.24403.0 |
Using the [IE Developer Toolbar](http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en) you can select an element (either by "Select element by click" or clicking on its node in the DOM tree view) and in the Current Style pane, right click on a row and select "Trac... |
|editor|tabs| |
Mac text/code editor |
|mac|editor| |
I searched for this and found [Maudite's][1] question about [text editors][2] but they were all for Windows.
As you have no doubt guessed, I am trying to find out if there are any text/code editors for the Mac besides what I know of. I'll edit my post to include editors listed.
**Free**
1. [Textwrangler][4]
... |
I searched for this and found [Maudite's][1] question about [text editors][2] but they were all for Windows.
As you have no doubt guessed, I am trying to find out if there are any text/code editors for the Mac besides what I know of. I'll edit my post to include editors listed.
**Free**
1. [Textwrangler][3]
... |
|mac|editor| |
I searched for this and found [Maudite's][1] question about [text editors][2] but they were all for Windows.
As you have no doubt guessed, I am trying to find out if there are any text/code editors for the Mac besides what I know of. I'll edit my post to include editors listed.
**Free**
1. [Textwrangler][3]
... |
Another option is to extend Canvas for the chart and extend Shape for the Pens. Then dynamically draw the shape based on the Color/Data properties. |
[InternalsVisibleTo][1] attribute to the rescue!
Just add:
[assembly:InternalsVisibleToAttribute("UnitTestAssemblyName")]
to your Core classes AssemblyInfo.cs file
[1]: http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(VS.80).aspx |
[InternalsVisibleTo][1] attribute to the rescue!
Just add:
[assembly:InternalsVisibleToAttribute("UnitTestAssemblyName")]
to your Core classes AssemblyInfo.cs file
See [Friend Assemblies (C# Programming Guide)][2] for best practices.
[1]: http://msdn.microsoft.com/en-us/library/system.runtime.c... |
Is this too simple of a solution?
#include <iostream>
#include<string>
int main()
{
std::string fn = "filename.conf";
if(fn.substr(fn.find_last_of(".") + 1) == "conf") {
std::cout << "Yes..." << std::endl;
} else {
std::cout << "No..." << std::endl;
... |
With InternalsVisible if your assemblies are strongly named you need to specify the public key (note: the full key **not** the public key token) for example...
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("BoardEx_BusinessObjects.Tests, PublicKey=002400000480000094000000060200000024000052534131000... |
With InternalsVisible if your assemblies are strongly named you need to specify the public key (note: the full key **not** the public key token) for example...
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("BoardEx_BusinessObjects.Tests, PublicKey=002400000480000094000000060200000024000052534131000... |
You might be able to pull this off. You can take a look at [this question][1], for a simpler example. The complexity comes, when you start comparing the dates. It may be easy to tell if the date is greater or not, but there are many situations to consider if you need to actually get the difference between two dates.
... |
Options for PivotTables in Excel |
|.net|excel|vsto|pivot-table| |
I need to design a small project for generating excel reports in .NET, which will be sent to users to use.
The excel reports will contain PivotTables.
I don't have much experience with them, but I can think of three implementation alternatives:
1. Set a query for it, populate it, send it disconnected. This way... |
|svn|repository|redundancy| |
Creating Redundancy for a Subversion Repository? |
|svn|repository|redundancy| |
Perl and map not working... I don't understand |
|perl|dictionary| |