instruction stringlengths 0 30k ⌀ |
|---|
Best mock framework that can do both WebForms and MVC? |
|c#|asp.net|asp.net-mvc|testing| |
I'm getting into more of a TDD workflow, and have a mix of MVC and asp.net Web Forms apps.
MOQ is recommended for MVC.
I've used Rhino for Web Forms.
Does anyone have a best practice for having 1 framework mock for both? |
What's wrong is mixing standards.
What's right is making sure that everyone does the same thing.
int Box = iBottom * nVerticleSide |
Given this XML, is there an xpath that will give me the 'test' and 'name' values? |
|xml|xslt| |
I need to get the value of the 'test' attribute in the xsl:when tag, and the 'name' attribute in the xsl:call-template tag. This xpath gets me pretty close:
..../xsl:template/xsl:choose/xsl:when
But that just returns the 'when' elements, not the exact attribute values I need.
Here is a snippet of my XM... |
If you define the first week to be days 1-7 of the month, the second week days 8-14, ... then the following code will work.
int week_of_month( const time_t *my_time)
{
struct tm *timeinfo;
timeinfo =localtime(my_time);
return 1 + (timeinfo->tm_mday-1) / 7;
}... |
How many users and how much data?
I don't know if there are general guidelines on how many users is "too much" for SQL Express 2005 but there is a hard data limit of 2GB. My guess would be you wouldn't hit that what with the Access heritage but it would be a good thing to know.
You can have SQL Express' installat... |
How many users and how much data?
I don't know if there are general guidelines on how many users is "too much" for SQL Express 2005 but there is a hard data limit of 4GB. My guess would be you wouldn't hit that what with the Access heritage but it would be a good thing to know.
You can have SQL Express' installat... |
Would this work?
\s*(,|\s+and)\s+ |
A good option is to use the overflow CSS property. The default value is visible but you can set it to hidden, scroll or auto. I would use auto in your case. If your content gets too big it will look like you have an iframe but it is still right on the page.
see: [overflow property][1]
[1]: http://www.w3school... |
If the targets should only be run when TFS is running the build and not on your local development machines, you can put your targets file in the folder for the build itself and reference it with:
<Import Project="$(MSBuildProjectDirectory)\my.team.build.targets.proj" />
However, if you want the targets to run... |
Due to all the compiler sugar that exists in the .NET platform, you can't decompile a binary into the original code without extremely sophisticated decompilers. For instance, the compiler creates classes in the background to handle enclosures. Automating this kind of thing seems like it would be a daunting task. How... |
I almost always advocate more than 1 language in a solution space (actually, more than 2 since SQL is part of so many projects). Even if the client likes a language with explicit typing and a large pool of talent, I advocate the use of scripting languages for administrative, testing, data scrubbing, etc.
The advant... |
I almost always advocate more than 1 language in a solution space (actually, more than 2 since SQL is part of so many projects). Even if the client likes a language with explicit typing and a large pool of talent, I advocate the use of scripting languages for administrative, testing, data scrubbing, etc.
The advant... |
You can set up some **insert/update triggers**. Just check if these fields are *null* or *notnull*, and reject insert/update operation if needed. This is a good solution if you want to store all the data in the same table.
You can create also create a **unique table for each classes** as well. |
You can use the [AppDomain.CreateInstance][1] method to do this. You'll need to call the Unwrap method of the ObjectHandle that is returned to get at the actual object.
[1]: http://msdn.microsoft.com/en-us/library/44s54yc4.aspx |
just use the ToString("C2") property of a decimal value. Set your globalization in the web.config - keep it simple. |
You could pass the hashtable in a SOAP Extension. That way, you can serialize it whichever way you would like. Although there is custom code for this that has to be on the client and server. |
Avoid exception specifications in C++. The reasons you give in your question are a pretty good start for why.
See Herb Sutter's discussions starting [here][1] and follow the links for more gory details.
[1]: http://herbsutter.spaces.live.com/blog/cns!2D4327CC297151BB!149.entry |
Avoid exception specifications in C++. The reasons you give in your question are a pretty good start for why.
See Herb Sutter's discussions starting [here][1] and follow the links for more gory details.
edit: Sutter's ["A Pragmatic Look at Exception Specifications"][2] is a better link.
[1]: http://herbsu... |
Like the earlier folks mention that suffix tree is the best tool for the job. My favorite site for suffix trees is http://www.allisons.org/ll/AlgDS/Tree/Suffix/ .. it enumerates all the nifty uses of a suffix trees on one page and has test js app embedded to test strings and work through examples. |
If you're targeting 3.5, you can take advantage of the new [managed extensibility framework][1] to handle all the heavy lifting for you.
[1]: http://code.msdn.microsoft.com/mef |
Create a new Appdomain with AppDomain.Create( ... ).
After creating the AppDomain load the DLLs into that AppDomain.
Look into all the methods that Appdomain has with Create*. There are certain things like CreateInstanceAndUnwrap, etc.
|
I'd definitely advocate both client and server-side validation (or validating at the various layers). This is especially important when communicating across physical tiers or processes, as the cost of throw exceptions becomes increasingly expensive. Also, the further down the chain you wait for validation, the more t... |
How can I report to users what is consuming the process address space of a windows application while they're running it? |
|memory|memory-management|windows-api|memory-dump| |
I'm writing the memory manager for an application, as part of a team of twenty-odd coders. We're running out of memory quota and we need to be able to see what's going on, since we only appear to be using about 700Mb. I need to be able to report where it's all going - fragmentation etc. Any ideas? |
Drawing with GDI+ is considerably slower in Debug mode. |
If you're doing anything for the web, or any front-facing software application for that matter, you really owe it to yourself to read...
[Don't make me think - Steve Krug][1]
[1]: http://www.amazon.com/Dont-Make-Me-Think-Usability/dp/0321344758/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1221726383&sr=8-1 |
I was able to produce useful output with the following command:
$ wget --spider -r -nv -nd -np http://localhost:3209/ 2>&1 | ack -o '(?<=URL:)\S+'
http://localhost:3209/
http://localhost:3209/robots.txt
http://localhost:3209/agenda/2008/08
http://localhost:3209/agenda/2008/10
http://loca... |
I was able to produce useful output with the following command:
$ wget --spider -r -nv -nd -np http://localhost:3209/ 2>&1 | ack -o '(?<=URL:)\S+'
http://localhost:3209/
http://localhost:3209/robots.txt
http://localhost:3209/agenda/2008/08
http://localhost:3209/agenda/2008/10
http://loca... |
Check just `IntPtr.Size` . You need to have target platform as AnyCPU.
[from here][1]
[1]: http://channel9.msdn.com/forums/TechOff/410567-C-Detect-32-bit-or-64-bit-OS/ |
Depends on your programming language.
* On .net, the built-in support for .net 3.5 is obvious, although this is mainly project templates. However, SP1 adds .net Client Framework support, which is not possible within VS2005 to my knowledge.
* This also means support for WPF with a XAML Designer, although most people... |
Usually you'll use an [HTTP Handler](http://www.google.com/search?q=HTTPHandler+ASP.NET&spell=1) for this. Given a request for...
> http://www.yoursite.com/sitemap.axd
...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other method is ... |
Is your test env the same really as live?
i.e
2 separate vm instances on 2 physical servers - with the network connection and account types?
Is there any other instances on the Database?
Is there any other web applications in IIS?
Is the .Net Config right?
Is the App Pool Config right for service account... |
This is interesting stuff. I was looking at [LinqBridge][1] yesterday after someone on this forum suggested it to me and they are doing a similar thing.
I find it strange that Microsoft named the frameworks 2.0, 3.0 and 3.5 when they all compile down to produce the same IL required by the 2.0 CLR. I would have thoug... |
Two things I like are Automatic properties so you can collapse your code down even further:
private string _name;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
becomes
public string Name... |
We have a BizTalk 2006 with Web Application and Several WebServices that need to go from Dev to UAT to Live.
We use MSBuild right from within VS to build, run tests, dependent on test result, complie, zip and ship to servers.
Small MSBuild script on server to unzip, move the files, install clean web app, unlist b... |
I searched around and I don't think Google Chrome registers itself as a Windows COM+ component. I think you're out of luck. |
Depending on the rights granted to your application, whether [shadow copying][1] is in effect or not and other invocation and deployment options, different methods may work or yield different results so you will have to choose your weapon wisely. Having said that,
all of the following will yield the same result for a ... |
Consider this pseudo-code, since I am writing it in mostly C syntax but pretending I can borrow functionality from other languages (string->int assignment, string->time conversion). Adapt or expand for your language of choice.
int week_num_in_month(time_t timestamp) {
int first_weekday_of_month, day_of_m... |
At my company we use it a lot. Had some problems with slow startup times on slower machines.
Out install experience is not perfect - there is a utility that will restore database that the application uses as a database template. |
Bash:
find -type f -printf "%T@ %p \n" \
| sort \
| tail -n 1 \
| sed -r "s/^\S+\s//;s/\s*$//" \
| xargs -iSTR cp STR newestfile
where "newestfile" will become the newestfile
alternatively, you could do newdir/STR or just newdir
Breakdown:
1. list all fi... |
Bash:
find -type f -printf "%T@ %p \n" \
| sort \
| tail -n 1 \
| sed -r "s/^\S+\s//;s/\s*$//" \
| xargs -iSTR cp STR newestfile
where "newestfile" will become the newestfile
alternatively, you could do newdir/STR or just newdir
Breakdown:
1. list all fi... |
do you want `.../xsl:template/xsl:choose/xsl:when/@test`
If you want to actually get the value 'First Name' out of the test attribute, you're out of luck -- the content inside the attribute is just a string, and not a piece of xml, so you can't xpath it. If you need to get that, you must use string manipulation (Eg,... |
css frameworks certainly help, although they can easily be heavy due to a heap of styles that you won't need or use.
check out
[Targeting IE Using Conditional Comments and Just One Stylesheet][1] over at Position is Everything for a great technique to feed IE version-specific styles without using CSS hacks; this a... |
Using a XmlValidatingReader will prevent the exceptions, if you provide your own ValidationEventHandler. |
If its too hard to test, your design is too complicated. That's the first metric I use. |
You could give this a try:
When you click on the cell...
1. Check to see if the process with the current row identifier is running from a class-level list; if so, exit the cell click event.
2. Store the row identifier in the class-level list of running processes.
3. Change the button text to "Running..." or ... |
How much success is there working on ASP.NET decompiled by Reflector? |
|asp.net|decompiling| |
I just finished a small project where changes were required to a pre-compiled, but no longer supported, ASP.NET web site. The code was ugly, but it was ugly before it was even compiled, and I'm quite impressed that everything still seems to work fine.
It took some editing, e.g. to remove control declarations, as th... |
|asp.net|decompiling|reflector| |
I'm curious what kind of logging/caching statements you have? If you have some class that is doing WriteLog or StoreCahce or whatever... why not just put the if(logging) in the WriteLog method. It seems like if you put all of your logging caching related methods into once class and that class knew whether logging/cach... |
I would suggest taking a look at AutoHotKey to create a small script which can do that for you. |
I have used the [SlickEdit][1] tools in the past to help keep XML comments inline.
[1]: http://www.slickedit.com/index.php?option=com_content&task=view&id=389&Itemid=57 |
It is inevitable once you have been a programmer that this will happen. If you seriously have unestimated the effort or hit a problem where your solution just doesn't work then stop coding and get talking to your project manager. I always like to take the solutions with me to the meeting, problem is A, you can do x whi... |
I have had great luck with [Viux.com][1] - their customer service is top-notch and they were quick to implement asp.net 3.5. I moved all my sites (5) to Viux now and couldn't be happier. Very reliable and I can't say enough about their super fast and friendly service! MySQL comes free with all of their plans and MSSQL ... |
How do I use the TranslateBehavior in CakePHP? |
|cakephp|behavior| |
There is no documentation on cakephp.org and I am unable to find one on google. Please link me some documentation or supply one! |
Well, it supports .NET 3.5, which offers a lot of new features - it depends on whether you need them.
Other than that, they improved (also with SP1) the refactoring tool, compile speed, IntelliSense now works great with C# too, and you get the new C# compiler even when writing .NET 2.0 code. Also, ASP.NET designer p... |
Actually, `script/destroy` works for any generator - generators work by reading a script of sorts on what files to create; `script/destroy` just reads that script in reverse and removes all the files created, as long as you give it the same arguments you passed to `script/generate`.
To sum up: `script/destroy authen... |
To add controls dynamically, you can use a panel as a place holder, say
<asp:Panel ID="ControlPlaceholder" runat="server" />
Then, on the server side, you can add objects to it like so:
int controlCount = 0;
...
TextBox newTextBox = TextBox();
newTextBox.ID = "ctl_" + controlCount++;... |
You can't detect the codepage, you need to be told it. You can analyse the bytes and guess it, but that can give some bizarre (sometimes amusing) results. I can't find it now, but I'm sure Notepad can be tricked into displaying English text in Chinese.
Anyway, this is what you need to read:
[The Absolute Minimum ... |
As of Java 6, java.net.NetworkInterface class now has the method getHardwareAddress()
<http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress()>
If that's too new, there are UUID packages which try various methods per OS to ask for it. Try e.g. <http://johannburkard.de/blog/progr... |
Not necessarily, as long as the content within the iframe is predictable. |
Binding a null value to a property of a web user control |
|c#|.net|asp.net| |
Working on a somewhat complex page for configuring customers at work. The setup is that there's a main page, which contains various "panels" for various groups of settings.
In one case, there's an email address field on the main table and an "export" configuration that controls how emails are sent out. I created... |
Probably the most common one is to load assemblies that contain plug-in code from untrusted parties. The code runs in its own AppDomain, isolating the application. |
Probably the most common one is to load assemblies that contain plug-in code from untrusted parties. The code runs in its own AppDomain, isolating the application.
Also, it's not possible to unload a particular assembly, but you can unload AppDomains.
For the full rundown, Chris Brumme had a massive blog entry o... |
What libraries can I use to build a GUI with Erlang? |
|user-interface|erlang| |
Which libraries can I use to build a GUI for a Erlang application? Please one option per answer. |
For querying the DB directly (such as at a sqlplus prompt or through a db administration tool), select * is generally fine--it saves you the trouble of writing out all the columns.
On the other hand, in application code it is best to enumerate the columns. This has several benefits:
- The code is clearer
- Y... |
The target shell and kernel shell are the same. They refer to a shell that runs on the target. You can connect to the shell using either a serial port, or a telnet session.
A task runs on the target and parses all the commands received and acts on them, outputting data back to the port.
The host shell is a process... |
I don't think that Access continuous forms should be condemned at all, but I definitely believe that they should be avoided for EDITING DATA. They work great for lists, and give you substantially more formatting capabilities than a mere listbox (and are much easier to work with, too, though they don't allow multi-selec... |
Flatten XML to HTML table using XSLT |
|xml|xslt|xpath| |
There must be a generic way to transform some hierachical XML such as:
<element1 A="AValue" B="BValue">
<element2 C="DValue" D="CValue">
<element3 E="EValue1" F="FValue1"/>
<element3 E="EValue2" F="FValue2"/>
</element2>
...
</element1>
into the flattened XML... |
I believe that because the UnmodifiableList wrapper stores the ArrayList to a final field, any read methods on the wrapper will see the list as it was when the wrapper was constructed as long as the list isn't modified after the wrapper is created, and as long as the mutable ArrayLists inside the wrapper aren't modifie... |
Hacky answer would be to grab the IE Developer Toolbar, find the tag that has the scrollbar, and alter your CSS file to add the overflow:hidden property to it. |
Ended up using the Date class, problem then became making that work with the rails select helper - which didn't happen, just generated the html myself. |
How do you mean "Test the database"?
If you are testing foreign keys, a simply script to insert invalid data is all you should need.
Testing a database could imply a great number of issues. Does it have all the tables? Are the tables correct? Are the indexes in place? Did the latest updates get applied? Ha... |
Wireshark is great.. but another option would be via PowerShell. I've used the [Get-Packet][1] script from Jeff Hicks at Sapien Technologies as a really lightweight packet sniffer. You get custom objects representing your packets and can do whatever filtering you need to via PowerShell. The other script in the pair ... |
Let me start off saying that I don't recommend doing this in a service on a server, but I'll do my best to answer the questions.
Running as a service makes it difficult to clean up. For example will what you have running as a service survive killing a hung word or excel. You may be in a position to have to kill th... |
Let me start off saying that I don't recommend doing this in a service on a server, but I'll do my best to answer the questions.
Running as a service makes it difficult to clean up. For example with what you have running as a service survive killing a hung word or excel. You may be in a position to have to kill th... |
You can use [`@UniqueConstraint`][1] something like this :
@Entity
@Table(name = "dm_action_plan"
uniqueConstraints={@UniqueConstraint(columnNames={"command","model")})
public class ActionPlan {
@Id
private int pk;
@Column(name = "command", nullable = fal... |
One big feature is it lets you target different versions of the .NET runtime, depending on the project. |
CLR stored procedure support |
If you're using The Microsoft Unit Testing framework, it's far better in 2008. i.e. it's usable. |
Look at this [PDF][1], on page 20 you have a diagram showing you were to place or modify your exif information. What is the difference with a file on disk ?
[1]: http://www.exif.org/Exif2-1.PDF |
Look at this [PDF][1], on page 20 you have a diagram showing you were to place or modify your exif information. What is the difference with a file on disk ?
Does the JPEG buffer of your camera contain an EXIF section already ?
[1]: http://www.exif.org/Exif2-1.PDF |
Try to think about what your user wants to achieve instead of what the requirements are.
The user will enter your system and use it to achieve a goal. When you open up calc you need to make a simple fast calculation 90% of the time so that's why by default it is set to simple mode.
So don't think about what the ... |
Better clustering/replication facilities |
Use @GeneratedValue to indicate that the key will be generated and @UniqueConstraint to express unicity
@Entity
@Table(name = "dm_action_plan"
uniqueConstraint = @UniqueConstraint({"command", "model"})
)
public class ActionPlan {
@Id
@GeneratedValue
private i... |
The minimum of testing shows that this should do it:
grep -Ev "^\$.*\*[0-9A-Fa-f]{2}$" a.txt
- -E use extended regexp
- -v Show lines that do not match
- ^ starts with
- .* anything
- \* an asterisk
- [0-9A-Fa-f] hexadecimal digit
- {2} exactly two of the previous
HTH, Motti. |