instruction stringlengths 0 30k ⌀ |
|---|
|unit-testing|wcf| |
We have a whole bunch of DLLs that give us access to our database and other applications and services.
We've wrapped these DLLs with a thin WCF service layer which our clients then consume.
I'm a little unsure on how to write unit tests that only test the WCF service layer. Should I just write unit tests for the ... |
The maintainability index is not as much a fixed value you look at, it's more of an indication that code is hard to understand, test and/or debug. I usually try to keep high level code (basically anything except for the real plumbing code) above 80, where 90+ would be good. It adds a competitive element to programming ... |
C# Linq Grouping |
|c#|linq| |
I'm experimenting with Linq and am having trouble figuring out grouping I've gone through several tutorials but for some reason can't figure this out.
As an example, say I have a table (SiteStats) with multiple website IDs that stores a count of how many visitors by type have accessed each site in total and for the... |
How do you use XML::Parser with Style => 'Objects' |
|xml|perl| |
The manual page for XML::Parser::Style::Objects is horrible. A simple hello world style program would really be helpful.
I really wanted to do something like this: (not real code of course)
use XML::Parser;
my $p = XML::Parser->new(Style => 'Objects', Pkg => 'MyNode');
my $tree = $p->parsefile('foo... |
Hibernate has a [filter mechanism][1] that may work for you. The filters will rewrite the queries hibernate generates to include an additional clause to limit the rows returned. I'm not aware of anything in hibernate to mask/hide columns.
Your database may also have support for this functionality. Oracle, for exa... |
|c#|asp.net|session|hacking|yui| |
I'm using the Yahoo Uploader, part of the Yahoo UI Library, on my ASP.Net website to allow users to upload files. For those unfamiliar, the uploader works by using a Flash applet to give me more control over the FileOpen dialog. I can specify a filter for file types, allow multiple files to be selected, etc. It's grea... |
I'm using the Yahoo Uploader, part of the Yahoo UI Library, on my ASP.Net website to allow users to upload files. For those unfamiliar, the uploader works by using a Flash applet to give me more control over the FileOpen dialog. I can specify a filter for file types, allow multiple files to be selected, etc. It's grea... |
You can BASE64 encode the content of the image directly into the SRC attribute, however, I believe only Firefox will parse this back into an image.
What I typically do is a create a very lightweight HTTPHandler to serve the images:
using System;
using System.Web;
namespace Example
{
public... |
You can BASE64 encode the content of the image directly into the SRC attribute, however, I believe only Firefox will parse this back into an image.
What I typically do is a create a very lightweight HTTPHandler to serve the images:
using System;
using System.Web;
namespace Example
{
... |
This is relatively easy:
git checkout -b fake_master master # fake_master now points to the same commit as master
git branch -D master # get rid of incorrect master
git checkout -b master real_master # master now points to your actual master
git checkout master # optio... |
Generally, no.
The stream format for Java serialization is defined [in this document][1], but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into something approaching the original objects. For example, classes may define writeObject() and readOb... |
Generally, no.
The stream format for Java serialization is defined [in this document][1], but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into something approaching the original objects. For example, classes may define writeObject() and readOb... |
Generally, no.
The stream format for Java serialization is defined [in this document][1], but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into something approaching the original objects. For example, classes may define writeObject() and readOb... |
You'll need a command line tool to zip up the files. I recommend [7-Zip][1] which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice.
Here's a two-line batch file that would zip the log files and delete them afterwards:
7za.exe a -tzip ex%1-logs.zip %2\ex%1*... |
logrotate is probably the best solution. Use the file '/etc/logrotate.conf' to change the settings for all your logs. You van change 'weekly' to 'daily' so the logs are rotated every day. Also, you might want to add 'compress' so the archives are compressed. If you don't care about the old logs, you can set rotate 'rot... |
If you are a one man show and strictly a Microsoft shop, then [SourceGear Vault][1] is definitely a prime candidate for switching too.
Features:
- Free for Single User, great for you
- It uses SQL Server for it's backend, therefore data reliability is huge
- It has atomic check-ins, all files checked-in at the ... |
Because Subversion (at least version 1.4 and below) doesn't keep track of what have been merged. For Subversion, merging is basically the same as any commit while on other version control like Git, what have been merged are remembered. |
For any CSS3-enabled browser you should be able to get away with
input:checked + label {
color: white;
}
for styling your labels. Unfortunately that probably of rules out some of the more popular browsers... |
According to the link Matt posted, the DefaultValue attribute doesn't set the default value of the property, it just lets the form designer know that the property *has* a default value. If you change a property from the default value it is shown as bold in the properties window.
You can't set a default value using a... |
Use of parameterized SQL has other benefits, it reduces CPU overhead (as well as other resources) in Oracle by reducing the amount of work Oracle requires in order to parse the statement. If you do not use parameters (we call them bind variables in Oracle) then "select * from foo where bar='cat'" and "select * from foo... |
ASP.NET Merge: Virtual path 'obal.asax' is not allowed |
Reading [this question][1] I found this as (note the quotation marks) "code" to solve the problem (that's perl by the way).
100,{)..3%!'Fizz'*\5%!'Buzz'*+\or}%n*
Obviously this is an intellectual example without real (I hope to never see that in real code in my life) implications but, when you have to make t... |
|code-style|performance| |
|performance|fix-typo| |
|performance| |
Reading [this question][1] I found this as (note the quotation marks) "code" to solve the problem (that's perl by the way).
100,{)..3%!'Fizz'*\5%!'Buzz'*+\or}%n*
Obviously this is an intelectual example without real (I hope to never see that in real code in my life) implications but, when you have to make th... |
Reading [this question][1] I found this as (note the quotation marks) "code" to solve the problem (that's perl by the way).
100,{)..3%!'Fizz'*\5%!'Buzz'*+\or}%n*
Obviously this is an intellectual example without real (I hope to never see that in real code in my life) implications but, when you have to make t... |
Check out the [Dynamic Linq Library][1] from ScottGu's blog.
[1]: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx |
It would probably be more work than it's worth, but you can use static C#/VB variables in a SQL CLR UDF, so I think you'd be able to do what you want to do by simply incrementing this variable every time the UDF is called. The static variable would be lost whenever the appdomain unloaded, of course. So if you need co... |
To answer a non-pointed question, my answer would be
"probably NUnit just stays out of your face."
**Disclaimer**: I've no actual experience with MS version of xUnit, however I hear problems like 'You need to install the gigantic idea just to run your tests on a separate machine' - which is a complete No-No.
Othe... |
Check [getrusage][1], I think that should solve your problem.
[1]: http://linux.die.net/man/2/getrusage |
If you are a one-man team, then your only option is really WiiWare. At $2000 for the kit, you picked the right console. That's a tiny fraction of the cost of a 360 or PS3 dev kit.
You do have to have your own business. You also have to get your game rated by the [ESRB](http://www.esrb.org/) which will put you back ... |
Try:
#include <unistd.h>
int main(){
nice(-10);
}
Note that you must be running as superuser for this to work.
(for more info, type 'man 2 nice' at a prompt. |
Try:
#include <sys/time.h>
#include <sys/resource.h>
int main(){
setpriority(PRIO_PROCESS, 0, -20);
}
Note that you must be running as superuser for this to work.
(for more info, type 'man setpriority' at a prompt.) |
Cannot access a disposed object - How to fix? |
|.net|winforms|vb.net| |
In a VB.NET WinForms project I get an exception "Cannot access a disposed object" when closing a form. It occurs very rarely and I cannot recreate it on demand. The stack trace looks like this: <br><br>`Cannot access a disposed object. Object name: 'dbiSchedule'. at System.Windows.Forms.Control.CreateHandle() at Syste... |
Start on `master`, create a branch called `in-progress`, then reset `master` to an earlier commit.
$ git branch in-progress
$ git reset --hard HEAD^ |
Kieron's answer is the best one so far. If you have problems because the first program is buffering its out you can use the unbuffer program:
unbuffer <command> | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; }'
It's installed by default on most linux systems. If you need to build it yourself it is part o... |
"Silent" Printing in a Web Application |
|printing|internet| |
I'm working on a web application that needs to prints silently -- that is without user involvement. What's the best way to accomplish this? It doesn't like it can be done with strictly with Javascript, nor Flash and/or AIR. The closest I've seen involves a Java applet.
I can understand why it would a Bad Idea for... |
The best way I have found is to use the VB function `FileSystem.DeleteFile`.
Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(file.FullName,
Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
It requires adding `Microsoft.V... |
The best way I have found is to use the VB function `FileSystem.DeleteFile`.
Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(file.FullName,
Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,
Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
It requires adding `Microsoft.V... |
[annotate][1], available via that link or as `annotate-output` in the Debian `devscripts` package.
$ echo -e "a\nb\nc" > lines
$ annotate-output cat lines
17:00:47 I: Started cat lines
17:00:47 O: a
17:00:47 O: b
17:00:47 O: c
17:00:47 I: Finished with exitcode 0
[1]: http://... |
Is the dialog shown using ShowModal or just Show? You should probably set the PopupMode property correct of the your dialog. pmAuto would probably your best choice. Also see if you need to set the PopupParent property. |
|asp.net|msbuild|merge| |
I am doing a Web Deployment of my website and I have the merge assemblies property set to true.
For some reason I get the following error.
aspnet_merge : error occurred: An error occurred when merging assemblies: The relative virtual path 'obal.asax' is not allowed here.
It seems to have something to do with ... |
Yes, it is possible. The [manual](http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc207785549) has this example:
> List.map (fun x -> x % 2 = 0) [1 .. 5];;
val it : bool list
= [false; true; false; true; false]
|
I would use a GridView (or DataGrid, if you are using an older version of ASP.NET).
<asp:GridView ID="gvBooks" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="Published" DataField="Published" />
<asp:BoundField HeaderText="Title" DataField="Tit... |
Try the kind of recurrences that can give variously simple or chaotic series based on the part of their phase spaces you explore: the simplest I can think of is the logistic map x(n+1) = r * x(n) * ( 1 - x(n) ). With r approx. 3.57 you get chaotic results that depend on the initial point.
If you graph this versus ... |
how about
<[^a](.|\n)+?> |
Pass functions in F# |
|f#| |
Is it possible to pass a reference to a function to another function in F#? Specifically, I'd like to pass lambda functions like
foo(fun x -> x ** 3) |
Check out the [Dynamic Linq Library][1] from ScottGu's blog:
> For example, below is a standard
> type-safe LINQ to SQL VB query that
> retrieves data from a Northwind
> database and displays it in a ASP.NET
> GridView control:![alt text][2]
>
> Using the LINQ DynamicQuery library I
> could re-write the abov... |
See the documentation for [XMLReader.setContentHandler()](http://www.saxproject.org/apidoc/org/xml/sax/XMLReader.html#setContentHandler(org.xml.sax.ContentHandler)), it says:
> Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediate... |
See the documentation for <a href="http://www.saxproject.org/apidoc/org/xml/sax/XMLReader.html#setContentHandler(org.xml.sax.ContentHandler)">XMLReader.setContentHandler\()</a>, it says:
> Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handl... |
We are currently in the process of doing this at my day job. We are actually making the switch over in about a month. I am a main part of the migration and a big part of why we are getting off of SourceSafe. To help in the migration, I used the [Visual Studio® Team System 2008 Team Foundation Server and Team Suite V... |
Assume all users are malicious.
Sanitize all input as soon as possible.
Full stop. |
As far as I can see [Changing the error message][1] has no way of changing the message of a specific error. Plus the manual makes it look like like this is a function belonging to Zend_Form, but I get method not found when using it on an instance of Zend_Form.
And example of the useage would be really great.
... |
Perhaps the community can come up with some good text-based CAPTCHAs?
We can then come up with a good list based on those with the most votes.
[What is a good text-based CAPTCHA?][1]
[1]: http://beta.stackoverflow.com/questions/34873/what-is-a-good-text-based-captcha |
Perhaps the community can come up with some good text-based CAPTCHAs?
We can then come up with a good list based on those with the most votes.
|
I sanitize my data right before I do any processing on it. I may need to take the First and Last name fields and concatenate them into a third field that gets inserted to the database. I'm going to sanitize the input before I even do the concatenation so I don't get any kind of processing or insertion errors. The soone... |
Random data in Unit Tests? |
|unit-testing| |
I have a coworker who writes unit tests for objects which fill their fields with random data. His reason is that it gives a wider range of testing, since it will test a lot of different values, whereas a normal test only uses a single static value.
I've given him a number of different reasons against this, the main ... |
|sql|mysql|performance| |
i am having serious performance problems (queries up to 55 seconds) while running a mysql query since i added a group_concat clause.
my query looks like:
select ... group_concat(distinct category.name) .... from page where
left outer join page_category on page.id = page_category.page_id
left out... |
You should not use "this" unless you absolutely must.
There IS a penalty associated with unnecessary verbosity. You should strive for code that is exactly as long as it needs to be, and no longer.
|
I was missing an index in the *page_category.page_id* field. That solve the problem. |
Improving performance with OPC tags |
|performance|automation| |
I am working with a PC based automation software package called Think'n'Do created by <a href="http://www.phoenixcontact.com">Phoenix Contact</a> It does real time processing, read inputs/ control logic / write outputs all done in a maximum of 50ms. We have an OPC server that is reading/writing tags from a PLC every 10... |
@palmsey
Pretty much, but the variation on that pattern that I've seen most often gets rid of `ObjectAID` et al. `ParentID` becomes both the PK and the FK to `Parents`. That gets you something like:
* `Parents`
* `ParentID`
* `ObjectA`
* `ParentID` (FK and PK)
* `ColumnFromA NOT NULL`
* `ObjectB... |
To expand on what stjohnroe has said it looks like the reason you are getting different results is because two different tables with the same name exist on different schemas.
By adding the myDB username to the front of the query you now access the table with the data you are expecting. (Since you say the data doesn'... |
AFAIK there is no elegant way to do what you are looking to.. VS will always end up copying it.
I think to be honest it may not be a great idea.. Obviously you want to share the lowest common code, but a whole MasterPage?.. Sounds like you could be asking for trouble since one minor change could have such an impact ... |
Add the following code to the `<head>`
<!--[if lte IE 6]>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
.ie6fixed {
position: absolute;
}
</style>
<![endif]-->
Add the `ie6fixed` CSS class to whatever you want to be `position... |
[Dynamically Composing Expression Predicates][1]
[1]: http://www.albahari.com/nutshell/predicatebuilder.html |
I've been working on a similar script here: <http://github.com/ghewgill/vim-scmdiff> (in fact, they may have the same ancestry). I haven't used scmdiff with cvs, but it should do a diff against the branch you have checked out. You can also specify that you want to diff against a particular revision (with :D _revision_ ... |
I've been working on a similar script here: <http://github.com/ghewgill/vim-scmdiff> (in fact, they may have the same ancestry). I haven't used scmdiff with cvs, but it should do a diff against the branch you have checked out. You can also specify that you want to diff against a particular revision (with :D _revision_ ... |
1) in linux this is a function of your desktop environment rather than the os itself.
2) GNOME and KDE have different methods to accomplish this.
3) There's nothing stopping you from doing it both ways. |
I would suggest mocking out your calls to the database. Mocks are basically objects that look like the object you are trying to call a method on, in the sense that they have the same properties, methods, etc. available to caller. But instead of performing whatever action they are programmed to do when a particular me... |
|unit-testing|tdd|mocks| |
|unit-testing|tdd|mocking| |
I prefer PHPUnit now, but when I started out I used SimpleTest as I didn't always have access to the command line. SimpleTest is nice, but the only thing it really has over PHPUnit, in my opinion, is the web runner.
The reasons I like PHPUnit are that it integrates with other PHP developer tools such as phing, phpU... |
I prefer PHPUnit now, but when I started out I used SimpleTest as I didn't always have access to the command line. SimpleTest is nice, but the only thing it really has over PHPUnit, in my opinion, is the web runner.
The reasons I like PHPUnit are that it integrates with other PHP developer tools such as [phing][1],... |
Use the [flock](http://perldoc.perl.org/functions/flock.html) Luke.
**Edit:** [This](http://www.perlmonks.org/?node_id=7058) is a good explanation. |
flock creates Unix-style file locks, and is available on most OS's Perl runs on. However flock's locks are advisory only.
edit: emphasized that flock is portable |
Thanks for the feedback Nick. I've pretty much gotten the profile and connection management working. The trick is figuring out which parts of the Native Wifi API are **not** supported on XP. Fortunately, the [Managed Wifi API][1] has connect/disconnect notification events that do work on XP ([NetworkChange][2] also gi... |
Running SVN under apache really isn't that hard. And you can use [mod_auth_sspi][1] to integrate with active directory.
[1]: http://www.deadbeef.com/index.php/mod_auth_sspi |
@Martin
That works for local forms that open in InfoPath. Nathan was asking about web-enabled forms. ActiveX controls are disabled for web forms, as evidenced by the informational label at the bottom of the design controls when the form compatability has been set to the web.
Now, I will admit that I know nothin... |
I have to be honest, I am kinda thinking out loud here.. But could it not be done with an applet or some sort (be it Java or whatever) that is given trusted permissions (such as that within the Intranet zone) or something?
May be worth investigating what permissions can be given to each zone?
Following a Google,... |
We use Firebugs console.log, console.time and console.timeEnd (I think) a lot.
Firebug also has a built in profiler. |