instruction stringlengths 0 30k ⌀ |
|---|
In Ruby 1.9:
weights.zip(data).map{|a,b| a*b}.reduce(:+)
In Ruby 1.8:
weights.zip(data).inject(0) {|sum,(w,d)| sum + w*d } |
SQL Server 2005 index recommendations |
|sql-server| |
We're in the process of upgrading one of our SQL Server instances from 2000 to 2005. I installed the performance dashboard (<http://www.microsoft.com/downloads/details.aspx?FamilyId=1d3a4a0d-7e0c-4730-8204-e419218c1efc&displaylang=en>) for access to some high level reporting. One of the reports shows missing (recommend... |
How do I know which SQL Server 2005 index recommendations to implement, if any? |
I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder.
What I am doing now is looking up the "date modified" in the shared fol... |
I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder.
What I am doing now is looking up the "date modified" in the shared fol... |
@[PJ][1]: you know, I had considered that, but dismissed it because I thought I wouldn't be able to later chain on a *third* named scope, like so:
Foo.ab(x, y).c(z)
But since `ab(x, y)` returns whatever `b(y)` would return, I think the chain would work. Way to make me rethink the obvious!
[1]: http://... |
The proxy server you describe would deal mostly with string data and I think its reasonable to implement in C#. In your example,
if header x == y, do z
the slowest part might actually be doing whatever 'z' is and you'll have to do that work regardless of the language. |
Why do you expect a much higher performance from the C++ application?
There is no inherent slowdown added by a C# application when you are doing it right. (not too many dropped references, frequent object creation/dropping per call, etc.)
The only time a C++ application really outperforms an equivalent C# applica... |
[Link To Resource][1]
[1]: http://blogs.msdn.com/sharepoint/archive/2007/07/25/scaling-large-lists.aspx |
How do you build a ratings implementation? |
|algorithm|data-structures|database-design| |
We have need for a "rating" system in a project we are working on, similar to the one in SO. However, in ours there are multiple entities that need to be "tagged" with a vote up (only up, never down, like an increment). Sometimes we will need to show all of the entities in order of what is rated highest, regardless of ... |
|algorithm|architecture|database-design|data-structures| |
I agree with Konrad, but I will add the "-C" option which demangle the symbols. If it's a C++ library, it's more readable demangled.
nm -gC yourLib.so |
I think cmd.exe hangs if the parameters are incorrect.
If the batch executes correctly then I would just shell execute it like this instead.
ProcessStartInfo psi = new ProcessStartInfo();
Process p = new Process();
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.WorkingDirectory = @"c:\build";... |
How to Format Numbers in WinForms 1.1 DataGrid? |
|winforms| |
Is there a simple way to format numbers in a Winforms 1.1 datagrid? The Format property of the DataGridTextBoxColumn seems to be completely ignored. I know there are [ugly solutions](http://support.microsoft.com/kb/318581), but was hoping there might be simpler solutions, or perhaps some trick to making the Format pr... |
Is there a simple way to format numbers in a Winforms 1.1 datagrid? The Format property of the DataGridTextBoxColumn seems to be completely ignored. I know there is a [solution](http://support.microsoft.com/kb/318581) that involves subclassing a Column control, and it's fairly simple, but was hoping there might be so... |
Is there a simple way to format numbers in a Winforms 1.1 datagrid? The Format property of the DataGridTextBoxColumn seems to be completely ignored. I know there is a [solution](http://support.microsoft.com/kb/318581) that involves subclassing a Column control, and it's fairly simple, but was hoping there might be so... |
ValidationRule To Enforce Unique Name |
|wpf|validation|data-binding| |
Another note on exception handling performance: simple tests don't take caching into account. The try-code and the catch-code are both so small that everything fits in the instruction and data caches. But compilers may try to move the catch-code far away from the try-code, which reduces the amount of code to keep in ca... |
I know you mentioned that you don't want to, but I actually think that using the `disabled` attribute is a better solution:
<select multiple="multiple">
<option value="volvo" selected="true" disabled="disabled">Volvo</option>
<option value="saab" disabled="disabled">Saab</option>
<opti... |
The [ListView][1] control introduced with framework 3.5 might be a little bit better solution. Your markup would look like this:
<asp:ListView runat="server" ID="ListView1"
DataSourceID="SqlDataSource1">
<LayoutTemplate>
<table runat="server" id="table1" runat="server" >
<tr ... |
$(".container .component").each(function() {
if ($(".container", this).css('width') === "auto")
$(".container", this).css('border', '1px solid #f00');
}); |
you will also need to have a asp:ScriptManager control on every page that you want to use ajax controls on. you should be able to just drag the scriptmanager over from your toolbox one the toolkit is installed following Zack's instructions. |
$(".container .component").each(function()
{
$(".container", this).each(function() {
if($(this).css('width') == 'auto')
{
$(this).css('border', '1px solid #f00');
}
});
});
Similar to the other answer but since components can als... |
Read ScuttGu's post about [VS 2008 Multi-Targeting Support][1]
>
> One of the big changes we are making
> starting with the VS 2008 release is
> to support what we call
> "Multi-Targeting" - which means that
> Visual Studio will now support
> targeting multiple versions of the
> .NET Framework, and developer... |
In my experience, the design and implementation has much more to do with performance than do the choice of language/framework (however, the usual caveats apply: eg, don't write a device driver in C# or java).
I wouldn't think twice about writing the type of program you describe in a managed language (be it Java, C#,... |
Options you have:
- Write a script that will wipe out database before you start unit tests, then populate db with predefined set of data and run the tests. You can also do that before every test – it'll be slow, but less error prone.
- Inject the database. (Example in pseudo-Java, but applies to all OO-la... |
I always start with the most readable version I can think of. If performance is a problem, I refactor. If the readable version makes it hard to generalize, I refactor.
The key is to have good tests so that refactoring is easy.
I view readability as the #1 most important issue in code, though working correctly i... |
Choose readability over performance unless you can prove that you need the performance.
|
Understanding Interfaces |
|interface| |
I have class method that returns a list of employees that I can iterate through. What's the best way to return the list? Typically I just return an ArrayList. However, as I understand, interfaces are better suited for this type of action. Which would be the best interface to use? Also, why is it better to return an i... |
I would say that you should only sacrifice readability for performance if there's a proven performance problem that's significant. Of course "significant" is the catch there, and what's significant and what isn't should be specific to the code you're working on. |
Readability is most important. With modern computers, only the most intensive routines of the most demanding applications need to worry too much about performance. |
Actually, with group policies, there's the ZAP file alternative, but I would recommend regardless that you learn MSI. It's not that hard, and very flexible. |
@Chris.Lively
You know you can pass a message in your exception, or even the "status codes". You are reinventing the wheel here.
|
I'm unclear as to what your actual problem is, so I'll throw out a few thoughts.
- Do you want restartable copies (with such small file sizes, that doesn't seem like it'd be that big of a deal)? If so, look at [CopyFileEx with COPY_FILE_RESTARTABLE][1]
- Do you want verifiable copies? Sounds like you already ... |
I'm unclear as to what your actual problem is, so I'll throw out a few thoughts.
- Do you want restartable copies (with such small file sizes, that doesn't seem like it'd be that big of a deal)? If so, look at [CopyFileEx with COPYFILERESTARTABLE][1]
- Do you want verifiable copies? Sounds like you already ha... |
@Michiel de Mare
Your Ruby 1.9 example can be shortened a bit further:
weights.zip(data).map(:*).reduce(:+)
Also note that in Ruby 1.8, if you require ActiveSupport (from Rails) you can use:
weights.zip(data).map(&:*).reduce(&:+) |
If you're running SQL 2005 you could do this in a CLR integration assembly and use the FTP classes in the System.Net namespace to build a simple FTP client.
You'd benefit from being able to trap and handle exceptions and reduce the security risk of having to use xp_cmdshell.
Just some thoughts. |
Autoboxing and unboxing occurs at runtime, and your compiler still views myInt as a primitive. |
Some features of autoboxing and unboxing occur at runtime, and your compiler still views <code>myInt</code> as a primitive. There's a lot of information about the details at [jcp.org][1].
So unfortunately, you would have to do it like this:
<pre><code>
((Integer)myInt).toString();
</code></pre>
[1]: ht... |
Some features of autoboxing and unboxing occur at runtime, and your compiler still views <code>myInt</code> as a primitive. There's a lot of information about the details at [jcp.org][1].
So unfortunately, you would have to do it like this: (kudos Patrick, I switched to your way)
<pre><code>
Integer.toString(m... |
Java autoboxing/unboxing doesn't go to the extent to allow you to dereference a primitive, so your compiler prevents it. Your compiler still knows <code>myInt</code> as a primitive. There's a paper about this issue at [jcp.org][1].
Autoboxing is mainly useful during assignment or parameter passing -- allowign you t... |
Why not use a map of primitives (triangles, squares), distribute the starting points for the countries (the "capitals"), and then randomly expanding the countries by adding a random adjacent primitive to the country. |
[Expression Engine][1] is fantastic. It's free to download and try but you must purchase a license if you are making a profit with it.
[1]: http://expressionengine.com/ |
The best reference I've seen on them is [Computational Geometry: Algorithms and Applications][1], which covers Voronoi diagrams, Delaunay triangulations (similar to Voronoi diagrams and each can be converted into the other), and other similar data structures.
They talk about all the data structures you need but the... |
What I would like to do is create a clean virtual machine image as the output of a build of an application.
So a new virtual machine would be created (from a template is fine, with the OS installed, and some base software installed) --- a new web site would be created in IIS, and the web app build output copied to a... |
You use the [Haversine formula][1].
[1]: http://en.wikipedia.org/wiki/Haversine_formula |
editing the web.config or updating a dll in the bin folder just recycles the worker process for that application, not the whole pool |
IISReset restarts the entire webserver (including all associated sites). If you're just looking to reset a single ASP.NET website, you should just recycle that AppDomain.
The most common way to reset an ASP.NET website is to edit the web.config file, but you can also create an admin page with the following:
p... |
It operates on the whole IIS process tree, as opposed to just your application pools.
C:\>iisreset /?
IISRESET.EXE (c) Microsoft Corp. 1998-1999
Usage:
iisreset [computername]
/RESTART Stop and then restart all Internet services.
/START S... |
I've run into this before also. There is no built-in aggregate function to concatenate strings. It seems like this would be needed all the time, but it's just not part of the default set.
I Googled and found [the same example][1]:
CREATE AGGREGATE textcat_all(
basetype = text,
sfunc = t... |
Im not sure if this is correct, but i'd try to compile it for the lowest version, the higher versions should be able to run the lower versions exe's. |
@Jack & @17 of 26, good point but the end user will be expecting the select box to be disabled so that confusion shouldn't be an issue.
I should have been clearer about why I couldn't just disable the control.
The application that will be using this will need to disable the selection of the options and there is... |
This isn't really the same, but you might want to look at something like [JChronic][1], which can do natural language processing on dates. So, the input date could be something like "tomorrow", or "two weeks from next tuesday".
This may not help at all for your application, but then again, it might.
[1]: h... |
Along side multi targeting, the frameworks are backwards compatible, so something compiled to 1.0 will run on 1.1 and 2. Somthing compiled on 1.1 will run on 2 ... etc. |
I know [@John Boker](http://stackoverflow.com/questions/43939/targeting-multiple-versions-of-net-framework#43946) is correct when it comes to .Net class libraries. You can compile a class library against .Net 1.1 and then use it in a .Net 2.0 or higher project.
I suspect the same is also true for executables. |
with 2005 & 2008, yes (on CLR 2.0)
With 2003, no.. because it compiles down to CLR 1.1
You could theorectically write some code using #if (DOTNET35) and such so that you don't use features outside the compilers knowledge and then run the desired compiler on the app... I question the usefulness of this though. |
Changing the default title of confirm() in javascript |
|javascript| |
Is it possible to modify the title of the message box the confirm() function opens in javascript? I could create a modal popup box, but I would like to do this as minimalistic as possible.
I would like to do something like this:
confirm("This is the content of the message box", "Modified title");
The d... |
I'm unclear as to what your actual problem is, so I'll throw out a few thoughts.
- Do you want restartable copies (with such small file sizes, that doesn't seem like it'd be that big of a deal)? If so, look at [CopyFileEx with COPYFILERESTARTABLE][1]
- Do you want verifiable copies? Sounds like you already ha... |
Eric,
You are dead on. For any really scalable / easily maintained / robust application the only real answer is to dispense with all the garbage and stick to the basics.
I've followed a similiar trajectory with my career and have come to the same conclusions. Of course, we're considered heretics and looked at fun... |
My solution just for kicks (this was a fun exercise)
-- Setup test table
DECLARE @names TABLE (
id INT IDENTITY(1,1),
name NVARCHAR(25) NOT NULL,
grp UNIQUEIDENTIFIER NULL
... |
There's also [gitx](http://github.com/pieter/gitx/tree/master), it's progressing well and under active development (multiple commits per day). |
I've used singletons a bunch of times in conjunction with [Spring][1] and didn't consider it a crutch or lazy.
What this pattern allowed me to do was create a single class for a bunch of configuration-type values and then share the single (non-mutable) instance of that specific configuration instance between several... |
Two questions to think about:
1. How many columns could be nominated for the query?
2. Does the data change frequently? A lot of it?
If you have a *small* number of candidate columns, and the data doesn't change *a lot*, then you might want to consider adding a permanent index on any or even all candidate column... |
Two questions to think about:
1. How many columns could be nominated for the query?
2. Does the data change frequently? A lot of it?
If you have a *small* number of candidate columns, and the data doesn't change *a lot*, then you might want to consider adding a permanent index on any or even all candidate column... |
Two questions to think about:
1. How many columns could be nominated for the query?
2. Does the data change frequently? A lot of it?
If you have a *small* number of candidate columns, and the data doesn't change *a lot*, then you might want to consider adding a permanent index on any or even all candidate column... |
According to the *Pro\*C/C++ Programmer's Guide* (chapter 5 "Advanced Topics"), Pro*C silently ignores a number of preprocessor directives including #error and #pragma, but sadly not #warning. Since your warning directives are included in a header file, you might be able to use the ORA_PROC macro:
#ifndef ORA_... |
In all my life, I have had maybe one application where I had to put an assembly in the GAC, simply because these assemblies were part of a framework that a number of applications would use it, and it seemed right to put them into the GAC. |
I think one of the biggest advantages of using the GAC is that you can have multiple versions of the same assembly registered and available to your applications. Personally, i don't like how it restricts movement from machine to machine (i don't like having to say, check out source on a new VPC and go through a bunch ... |
You ca use the <a href="http://en.wikipedia.org/wiki/A*_search_algorithm">A*</a> algorithm to find the shortest path between those two cities and this way you'll have the distance. |
if you need a code example I think I have one I could dig up at home, but like many of the previous answers, you need a long / lat db to do the calculation |
The GAC runs with Full Trust and can be used by applications outside of your Web App. For example, Timer Jobs in Sharepoint HAVE to be in the GAC because the sptimer service is a separate process.
The "Full Trust" Part is also a possible source for security issues. Sure, you can work with Code Access Security, but I... |
Here what's technet has to say about [iisreset][1]
> You might need to restart Internet Information Services (IIS) before certain configuration changes take effect or when applications become unavailable. Restarting IIS is the same as first stopping IIS, and then starting it again, except it is accomplished with a s... |
I know this is my own question but I came across this text editor [Sublime Text][1] and thought it was pretty sweet. There are a few features in it that i have never seen before. It has multiple line select ( lines that are not continuous ) and a birds eye view navigation. It's a little pricey but I am having fun playi... |
Reporting Systems for ASP.NET |
|asp.net|report| |
What are the best open source (open source and commercial) reporting tools for ASP.NET similar to Crystal Reports for ASP.NET? |
My solution just for kicks (this was a fun exercise)
-- Setup test table
DECLARE @names TABLE (
id INT IDENTITY(1,1),
name NVARCHAR(25) NOT NULL,
grp UNIQUEIDENTIFIER NULL
... |
My solution just for kicks (this was a fun exercise), no cursors, no iterations, but i do have a helper field
-- Setup test table
DECLARE @names TABLE (
id INT IDENTITY(1,1),
name NVARCHAR(25) NOT NULL,
... |
I don't know of any free SMS services, you usually buy bulk sms'seses and use an API to send them out.
[Whitepages.com][1] has an API that will allow developers to reverse lookup a phone number. It reports the carrier on mobile number, however a lot of the time it's some non-existent-anymore carrier like Powertel o... |
Where I work we've been using <http://www.clickatell.com> for sending out SMS - it looks like its about 6 or 7 cents a message. They just take http POST requests to send out a message. I don't know if you'll be able to find any good free gateways. We used to send out emails, but found they were unreliable. |
How Do You Determine The PID of the Parent of a Process |
|erlang| |
I have a process in erlang that is supposed to do something immediately after spawn, then send the result back to the parent when it is finished. How do I figure out the PID of the process that spawned it? |
Supporting [Angus][1], I can vouch for [http://www.clickatell.com][2]. It was used at a company I used to work at. It was a very easy solution to setup and use and worked great. You just need to anticipate how many messages you intend to send out and bulk order messages. They're pretty cheap, overall.
[1]: http:... |
I would say mbUnit also, I like being able to run a single test many times just by specifying inputs and result right above the test function. Horrible description of what I mean so [here is a link that shows you what I mean.][1]
[1]: http://www.hanselman.com/blog/MbUnitUnitTestingOnCrack.aspx |
LinqDataSource - Can you limit the amount of records returned? |
|asp.net|c#|linq|linq-to-sql| |
I'd like to use a LinqDataSource control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:
IEnumerable<int> values = Enumerable.Range(0, 10);
IEnumerable<int> take3 = values.Take(3);
Does anyone know if something like this is possible with a ... |
I'd like to use a LinqDataSource control on a page and limit the amount of records returned. I know if I use code behind I could do something like this:
IEnumerable<int> values = Enumerable.Range(0, 10);
IEnumerable<int> take3 = values.Take(3);
Does anyone know if something like this is possible with a ... |