instruction stringlengths 0 30k ⌀ |
|---|
I use it whenever [StyleCop][1] tells me to. [StyleCop][2] must be obeyed. Oh yes.
[1]: http://code.msdn.microsoft.com/sourceanalysis
[2]: http://code.msdn.microsoft.com/sourceanalysis |
Okay, I feel like I'm taking crazy pills here, looking at some of these answers. Well, maybe I am.
**String.Format has to be a static method because strings are immutable.** Making it an instance method would imply you could use it to "format" or modify the value of an existing string. This you can't do, and making ... |
Is this any use?
http://msdn.microsoft.com/en-us/library/bb774085(VS.85).aspx |
Is this any use?
Oops:
http://msdn.microsoft.com/en-us/library/bb774096(VS.85).aspx |
Is this any use?
Oops:
http://msdn.microsoft.com/en-us/library/bb774096(VS.85).aspx |
Cool - I'll try those options, as they're probably better defaults given my intentions. Unfortunately, I know my device is there and I'll eventually need read/write access later on (once I inspect the descriptors and have verifed it is infact my device).
Which means that my real goal IS to know what's using it, so ... |
Cool - I'll try those options, as they're probably better defaults given my intentions. Unfortunately, I know my device is there and I'll eventually need read/write access later on (once I inspect the descriptors and have verifed it is infact my device).
Which means that my real goal IS to know what's using it, so ... |
Tag-based web sites often suffer from the delicacy of language such as synonyms, homonyms, etc. For programmers looking for information, say on SO, concrete examples are:
- Subversion or SVN (or svn, with case-sensitive tags)
- .NET or Mono
- [Will add more]
The problem is that we *do* want to preserve ou... |
|stackoverflow|tags|del.icio.us|folksonomy| |
After some research I came up with the following:
string pmt = dr["Payment"].ToString();
double dblPmt = System.Convert.ToDouble(pmt);
this.txtPayment.Text = dblPmt.ToString("c",CultureInfo.CurrentCulture.NumberFormat);
I am going to test all code samples given. If I can solve this with one line of ... |
As always, it depends on their implementation. If they decide to mess with the rendering engine, we could be looking at a whole new list of browser "quirks" which will mean WebDev's will be uber-pissed.
If they stay standards-compliant (which TBH, I expect they will) it could be a really good thing to heat up the co... |
You should be able to use the IN clause (assuming your database supports it):
`UPDATE foo
SET flag=true
WHERE id in (1, 2, 3, 5, 6)` |
Beta Testing |
|beta|testing| |
I have a project that I would like to start beta testing soon, it is a PHP/MySQL site for programmers.<br />
I have beta tested sites before however it was always in-house, and I have never done betas that could/should be seen by someone other then those associated with the project.<br /><br />So, how should I go abou... |
I have a project that I would like to start beta testing soon, it is a PHP/MySQL site for programmers.<br />
I have beta tested sites before however it was always in-house, and I have never done betas that could/should be seen by someone other then those associated with the project.<br /><br />So, how should I go abou... |
DateFormat.parse(String) |
In brief...
DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
Date date = (Date)formatter.parse("01/29/02");
See [http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html][1] for more.
[1]: http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html |
Which jstl url should I reference in my jsps? |
|java|jsp|web-applications|jstl| |
I'm getting the following error when trying to run a jsp.
I'm using Tomcat 6.0.18, and I'd like to use the latest version of jstl.
What version of jstl should I use, and which URL goes with which version of jstl?
I'm getting this error
"According to TLD or attribute directive in tag file, attribute key does n... |
This should help
[DefaultValue(typeof(Color),"InactiveBorder")] |
This should help
[DefaultValue(typeof(Color),"InactiveBorder")]
You need to replace SystemColors with Color.
It seems that there is no type converter for SystemColors type, only for Color type. |
You need to change first argument from SystemColors to Color.
It seems that there is no type converter for SystemColors type, only for Color type.
[DefaultValue(typeof(Color),"InactiveBorder")]
|
This page shows some examples of open-source rules engines in C#: [http://csharp-source.net/open-source/rule-engines][1]
[1]: http://csharp-source.net/open-source/rule-engines |
There is the Microsoft Business Rules Engine: <http://msdn.microsoft.com/en-us/library/aa561216.aspx>. Not sure if it can only be used inside Biztalk - it does says it is a .Net Class Library. |
I believe that it is a matter of preference at this point. The words that you mention are basically synonyms in today's languages and for the most part people will understand what you mean if you say either "method" or "function". If you use "message", which is only used really in OOP, then you may confuse what you are... |
ZedGraph is not WinForms only, there's a web control too. It's very good. |
How do I best populate an HTML table in ASP.NET? |
|asp.net|vb.net|html| |
|asp.net|html|vb.net| |
Kokos,
Couple of things wrong there. First, doing it that way means I have to construct the Foos first, then feed their values to the mock reader which does nothing to *reduce* the amount of code I'm writing. Second, if the values pass through the reader, the Foos won't be the *same* Foos (reference equality). They ... |
If you don't/can't keep the connection open you could use [screen][1], if you have the rights to install it.
[1]: http://www.gnu.org/software/screen/ |
The Version class does not support versions with commas in it, so the solution presented by [Darren Kopp](http://stackoverflow.com/questions/30494#30510) is not sufficient.
Here is a version that is as simple as possible (but no simpler).
It uses System.Version but achieves compatibility with version numbers like... |
The [System.Version](http://msdn.microsoft.com/en-us/library/system.version.aspx) class does not support versions with commas in it, so the solution presented by [Darren Kopp](http://stackoverflow.com/questions/30494#30510) is not sufficient.
Here is a version that is as simple as possible (but no simpler).
It us... |
This CSS snippet should remove the vertical scrollbar:
body {
overflow-x: hidden;
overflow-y: hidden;
}
I'm not sure yet about having it take up as much vertical space as it needs, but I'll see if I can't figure it out. |
I don't think either of these answers are definitive. The 4guysfromrolla reference is helpful.
Deploying .NET 3.5 to 100+ sites will be a pain. You can't just upgrade the server to the new framework, you have to upgrade the web.config of each site. As far as I can tell, there is no command line tool to do it. |
How to keep a "things done" count in a recursive algorithm in Java? |
|java|coding-style|recursion|integer|final| |
I have a recursive algorithm which steps through a string, character by character, and parses it to create a tree-like structure. I want to be able to keep track of the character index the parser is currently at (for error messages as much as anything else) but am not keen on implementing something like a tuple to han... |
The previous answers point out the XML syntax perfectly. I just wanted to throw in my recommendation for the [free (and open-source) nDoc help library generator][1] that parses all comments in a project.
[1]: http://ndoc.sourceforge.net/ |
It's kind of a hack, but sometimes I use an AtomicInteger, which is mutable, to do things like this. I've also seen cases where an int[] of size 1 is passed in. |
The _float:left;_ doesn't work in IE7. You still lose the bullet. I'm not really keen on using a background image either. |
The _float:left;_ doesn't work in IE7. You still lose the bullet. I'm not really keen on using a background image either.
At the moment I think I'm just gonna go with &bull; |
That's why you have to avoid:
catch (Exception ex)
{
throw ex;
}
As that basically cloaks your exception in a new one.
If you use:
catch (Exception ex)
{
throw; //note: no ex
}
It keeps the original exception and stack trace. |
As far as I've seen, there isn't a significant performance difference between the two. I'm reasonably certain that in most cases it will be 'compiled' down to the same code.
If you're not sure, try writing a test application that does each method a million times or so, all the while timing how long it takes. That's ... |
The current solution I am using is:
int[] counter = {0};
and then pass it to the recursive algorithm:
public List<Thing> doIt (String aString, int[] counter) { ... }
and when I want to increment it:
counter[0]++;
Not super elegant, but it works...
|
|.net|exception|c#| |
|c#|.net|exception| |
I'm maintaining a .NET 1.1 application, and one of the things I've been tasked with is making sure the user doesn't see any unfriendly error notifications.
I've added handlers to Application.ThreadException and AppDomain.CurrentDomain.UnhandledException, which do get called. My problem is that the standard CLR error... |
There's not really enough information to go on here.
svn merge -r 67212:67213 https://my.svn.repository/trunk .
will merge any files changed in the revision 67212 in the folder /trunk on the repository and merge them into your current working directory. If you do:
svn log -r 67212
What files does it... |
When I was first learning Java we had to make Yahtzee (yawn) and I thought it would be cool to create custom Swing components and containers instead of just drawing everything on one JPanel. The benefit of extending Swing components, of course, is to have the ability to add support for keyboard shortcuts and other acc... |
Cool - I'll try those options, as they're probably better defaults given my intentions. Unfortunately, I know my device is there and I'll eventually need read/write access later on (once I inspect the descriptors and have verifed it is infact my device).
Which means that my real goal IS to know what's using it, so ... |
Anything but Visual Source Safe; preferably one which supports the concepts of branching and merging. As others have said, Subversion is a great choice, especially with the TortoiseSVN client.
Be sure to check out (pardon the pun) [Eric Sink's classic series of Source Control HOWTO articles][1].
[1]: http://w... |
The integrated debuggers where you can watch the values of variable change as you step through code are really cool. They do, however, require software setup on the server and a certain amount of configuration on the client. Both of which require periodic maintenance to keep in good working order.
A print_r is easy ... |
[@mercutio](http://stackoverflow.com/questions/23217/whats-the-purpose-if-any-of-javascript-in-event-handler-tags#23242)
>>That's ridiculous.
No, it's not ridiculous, javascript: is a pseudo protocol that can indeed only be used as the subject of a link, so he's quite right. Your suggestion is indeed better, but ... |
x = number_of_dimensions_left;
while (x > 1)
{
switch (x)
{
case 20:
reduce20DimensionTable();
x--;
break;
case 19:
.....
}
}
(Sorry, couldn't resist.) |
x = number_of_dimensions;
while (x > 1)
{
switch (x)
{
case 20:
reduce20DimensionArray();
x--;
break;
case 19:
.....
}
}
(Sorry, couldn't resist.) |
You definitely want to test physically pulling the cable out. Lots of networking code will throw different exceptions in that scenario vs when the connection has just been lost. |
Tomcat is primarily an application server, which serves requests to custom-built Java servlets or JSP files on your server. It is usually used in conjunction with the Apache HTTP server (at least in my experience). Use it to manually process incoming requests.
The HTTP server, by itself, is best for serving up stati... |
I do development on 64 bit machines for 32 bit Windows. It's not a problem. You should make sure that your projects are set to compile in x86 mode in order to be conservative. You'll want to go through each project in the solution and double check this. You could also use the AnyCPU setting but that's a little riski... |
[Many][1] [have][2] [asked][3], but to date there remains no cold fusion code coverage tool.
The latest Cold Fusion features .NET integration in addition to J2EE integration, so if you require code coverage metrics (ie, customer requirements) then (aside from choosing something other than coldfusion) you might defin... |
Divide your services by resource requirements at the very least. For example, if you are running a photo album site, separate your image download server from your image upload server. The download server will have many more requests, and because most people have a lower upload speed the upload server will have longer l... |
What is wrong with native Delphi enums? They are type safe.
type
TMyEnum = (Item1, Item2, Item3);
if MyEnum <> Item1 then...
Since Delphi 2005 you can have consts in a class, but Delphi 5 can not.
type
TMyEnum = sealed class
public
const Item1 = 0;
cons... |
|testing|beta| |
I haven't ever seen a way to do that other than your foreach loop.
But, if $list is in any way gotten from the user, you should stick to using the prepared statement and just updating a row at a time (assuming someone doesn't have a way to update several rows with a prepared statement). Otherwise, you are wide open... |
Use join/implode to make a comma-delimited list to end up with:
UPDATE foo SET flag=true WHERE id IN (1,2,3,4) |
No, you can't use passwords, but you could use password hashes. However, Google Docs are all about sharing, so such a method would require storing a copy of the document for each user. |
This would achieve the same thing, but probably won't yield much of a speed increase, but looks nicer.
mysql_query("UPDATE foo SET flag=true WHERE id IN (".implode(', ',$list).")"); |
you can jam you update with case statements but you will have to build the query on your own.
UPDATE foo
SET flag=CASE ID WHEN 5 THEN true ELSE flag END
,flag=CASE ID WHEN 6 THEN false ELSE flag END
WHERE id in (5,6)
The where can be omitted but saves you from a full table update. |
**VB.NET code:**
dim delimitedIdList as string = arrayToString(listOfIds)
dim SQL as string = " UPDATE foo SET flag=true WHERE id in (" + delimitedIdList + ")"
runSql(SQL) |
Use IN statement. Provide comma separated list of key values. You can easily do so using `implode` function.
UPDATE foo SET flag = true WHERE id IN (1, 2, 3, 4, 5, ...)
Alternatively you can use condition:
UPDATE foo SET flag = true WHERE flag = false
or subquery:
UPDATE foo SET flag = true W... |
I think Carl, nailed it on the head, but I wanted to say that with any website, if you are providing it any confidential/personal/privileged information then you have to have a certain level of trust, and it is the responsibility of the service provider to establish this trust. This is one of those questions that has ... |
I'd stay away from the SQL Query. Instead, I'd either use the API or Web Services. Here's an example API call to retrieve and edit a work item:
<a href="http://msdn.microsoft.com/en-us/library/bb130323.aspx">http://msdn.microsoft.com/en-us/library/bb130323.aspx</a>
You could modify that to add the links. Would be... |
Well, I'd consider a process similar to Amazons AWS. You authenticate with a private password that is not saved remotely. Just a hash is used to validate the user. Then you generate a certificate with one of the main and long-tested algorithms and provide this from a secure page. Then a public/private key algorithm can... |
When I was first learning Java we had to make Yahtzee (yawn) and I thought it would be cool to create custom Swing components and containers instead of just drawing everything on one JPanel. The benefit of extending Swing components, of course, is to have the ability to add support for keyboard shortcuts and other acc... |
If you are talking about MS SQL Server tables, I like the diagram support in SQL Server Management Studio. You just drag the tables from the explorer onto the canvas, and they are laid out for you along with lines for relationships. You'll have to do some adjusting by hand for the best looking diagrams, but it is a d... |
The simple answer is, do you like Undo buttons? The answer is of course yes, because we as human being make mistakes all the time.
As programmers, its often the case though that it can take several hours of testing, code changes, overwrites, deletions, file moves and renames before we work out the method we are tryi... |
Going all the way down to the basics for Map and Reduce.
----------
**Map** is a function which "transforms" items in some kind of list to another kind of item and put them back in the same kind of list.
suppose I have a list of numbers: [1,2,3] and I want to double every number, in this case, the function to ... |
It's important to keep in mind that MVC and WebForms are not competing, and one is not better than the other. They are simply different tools. Most people seem to approach MVC vs WebForms as "one must be a better hammer than the other". That is wrong. One is a hammer, the other is a screwdriver. Both are used in the pr... |
This is what I've got. It works. But, is there a simpler or better way?
ASPX Page…
<asp:Repeater ID="RepeaterBooks" runat="server">
<HeaderTemplate>
<table class="report">
<tr>
<th>Published</th>
<th>Title</th>
... |
This is what I've got. It works. But, is there a simpler or better way?
ASPX Page…
<asp:Repeater ID="RepeaterBooks" runat="server">
<HeaderTemplate>
<table class="report">
<tr>
<th>Published</th>
<th>Title</th>
... |
My group at work is using Git, and it has been all the difference in the world. We were using SCCS and a steaming pile of csh scripts to manage quite large and complicated projects that shared code between them (attempted to, anyway).
With Git, submodule support makes a lot of this stuff easy, and only a minimum of... |
Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat.
So basically Apache is an HTTP Server. It servers HTTP. Tomcat is a Servelt and JSP server that servers Java technologies. |
Apache Tomcat is used to deploy your Java Servlets and JSPs. So in your Java project you can build your WAR (short for Web ARchive) file, and just drop it in the deploy directory in Tomcat.
So basically Apache is an HTTP Server, serving HTTP. Tomcat is a Servelt and JSP Server serving Java technologies. |
Please take a look at [this page][1] (section "Dependency Version Ranges"). What you might want to do is something like
<version>[1.2.3,)</version>
HTH
**Edit:** Just saw the note that the ideas expressed in the linked document may not be implemented yet...
[1]: http://docs.codehaus.org/display/M... |
Please take a look at [this page][1] (section "Dependency Version Ranges"). What you might want to do is something like
<version>[1.2.3,)</version>
HTH
**Edit:** Just saw the note that the ideas expressed in the linked document may not be implemented yet...
**Edit 2:** The version ranges are implem... |
MySQL Binary Log Replication: Can it be set to ignore errors? |
|mysql|replication|binlog| |
I'm running a master-slave MySQL binary log replication system (phew!) that, for some data, is not in sync (meaning, the master holds more data than the slave). But the slave stops very frequently on the slightest MySQL error, can this be disabled? (perhaps a my.cnf setting for the replicating slave ignore-replicating-... |
Lets make it the best way to shift `N` bits in the array of 8 bit integers.
N - Total number of bits to shift
F = (N / 8) - Full 8 bit integers shifted
R = (N % 8) - Remaining bits that need to be shifted
I guess from here you would have to find the most optimal way to make use of this dat... |
Lets make it the best way to shift `N` bits in the array of 8 bit integers.
N - Total number of bits to shift
F = (N / 8) - Full 8 bit integers shifted
R = (N % 8) - Remaining bits that need to be shifted
I guess from here you would have to find the most optimal way to make use of this da... |
How do you troubleshoot character encoding problems? |
|encoding|localization| |
If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong?
(The specific scenario I'm facing is no-char boxes within a <select> when it should be showing Japanese chars.) |
The [FlashWindowEx][1] function which controls the flashing takes a [FLASHWINFO][2] struct which has a uCount field to control how many times it flashes. Also, a possible value for the dwFlags field is FLASHW_STOP to cause the flashing to stop.
[1]: http://msdn.microsoft.com/en-us/library/ms679347%28VS.85%29.as... |
In addition to what Nick has said you can find out more at [Streamed Lines: Branching Patterns for Parallel Software Development](http://www.cmcrossroads.com/bradapp/acme/branching/)
![Example][1]
[1]: http://www.cmcrossroads.com/bradapp/acme/branching/vtree.gif
In this figure main is the trunk, rel1-maint... |
GROUP BY is similar to DISTINCT in that it groups multiple records into one.
This example, borrowed from [http://www.devguru.com/technologies/t-sql/7080.asp][1], lists distinct products in the Products table.
SELECT Product FROM Products GROUP BY Product
Product
-------------
Desktop
La... |
I'm going to make some enemies with this, but I actually use -- *gasp* -- a non-monospace font! I occasionally switch back to a monospace to disambiguate something, but mostly find that a good clean sans-serif font is easiest to read and doesn't waste screen estate.
An IDE with good syntax colouring helps. |
I prefer using jQuery for AJAXy stuff like that. It also has a lot of very good plugins that make writing client-side code very easy.
Here is the plugin page specifically for Drag-n-Drop.
[http://plugins.jquery.com/project/Plugins/category/45][1]
[1]: http://plugins.jquery.com/project/Plugins/category/45
... |