instruction
stringlengths
0
30k
This is a question I asked on another forum which received some decent answers, but I wanted to see if anyone here has more insight. The problem is that you have one of your pages in a web application timing out when it gets to a stored procedure call, so you use Sql Profiler, or your application trace logs, to find...
|sql|sql-server|
ADO.NET Connection Pooling & MS SQL
|mssql|performance|ado.net|
<ul> <li>What is it?</li> <li>How do I implement connection pooling with MS SQL?</li> <li>What are the performance ramifications when</li> <ul> <li>Executing many queries one-after-the other (i.e. using a loop with 30K+ iterations calling a stored procedure)?</li> <li>Executing a few queries...
I have three type of conditions that I catch. 1. Bad or missing input should not be an exception. Use both client side js and server side regex to detect, set attributes and forward back to the same page with messages. 2. The AppException. This is usually an exception that you detect and throw with in your co...
If the original data came from a char column or variable (before being inserted into this table), then the original data had the spaces appended before becoming a varchar. DECLARE @Name char(10), @Name2 varchar(10) SELECT @Name = 'Bob', @Name2 = 'Bob' SELECT CASE WHEN @Name2 ...
You are trying to pass an int to a function that accepts a string, so it's being converted to a string for you. This will write what you want: fwrite($fpr, "\x63");
Getting java and flash to talk to each other
|java|flash|
I have an application written in java, and I want to add a flash front end to it. The flash front end will run on the same computer as the java app in the stand alone flash player. I need two way communication between the two parts, and have no idea how to even start going about this. I suppose I could open a socket b...
It's bad to name any variable after a built in function. One of the reasons is because it can be confusing to a reader that doesn't know the name is overridden.
Define your temp table like this - declare @databases table ( RowID not null int identity(1,1) primary key, DatabaseID int, Name varchar(15), Server varchar(15) ) -- insert a bunch rows into @databases Then do this - declare @i ...
Performance Testing
|.net|vmware|nunit|regressiontesting|
We are developing automated regression tests using VMWare and NUnit. We have divided tests into steps and now I would like to see each step be examined for performance regression. Simply timing the tests, as NUnit does, does not seem reliable. I have figured in a acceptance factor of about 15% but our steps can differ ...
How about taking a page from the [Data Warehouse][1] guys and make a table. In DW terms, this would be a date dimension. A [standard date dimension][2] would have things like various names for a date ("MON", "Monday", "August 22, 1998"), or indicators like end-of-month and start-of-month. However, you can also have co...
For "appear x times" queries it is best to use HAVING clause. In your case, query can be like: SELECT Date FROM table GROUP BY Date HAVING COUNT(*)<k or, in you need to select other columns except Data: SELECT * FROM Table WHERE Date IN ( SELECT Date FROM table GROUP BY Date HAVING COUNT(*)<k) ...
For "appears x times" queries it is best to use HAVING clause. In your case, query can be like: SELECT Date FROM table GROUP BY Date HAVING COUNT(*)<k or, in you need to select other columns except Date: SELECT * FROM Table WHERE Date IN ( SELECT Date FROM table GROUP BY Date HAVING COUNT(*)<k) ...
You could use WMI. Found a snippit. Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colComputer = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") For Each objComputer in colComputer ...
I've had Oracle create a corrupt database when the disk ran out of space. It's hard to debug, uses loads of resources and is difficult to work with without seriously skilled DBA's holding your hand. Oracle even replaced system binaries (e.g. gcc) in /usr/bin/ when I installed in on an occation. Working with Postgr...
It should be noted that google analytics is not an accurate representation of web site usage. This is because the web beacon (web bug) used on the page does not always load for these reasons: 1. Google analytics servers are called by millions of pages every second and can not always process the requests in a timely...
Yes, comparing hashes should work fine in this case.
Do all the tables have the same format? If not, then if you have to have a report that can display the n different types of rows. If you are only interested in the same columns then it is easier. Most databases have some form of dynamic sql. In that case you can do the following create temporary table from se...
Do you want the end user to know the ID? For example I could in theory derive that your database has x number of customers if you show me an id that represents a standard integer seed. If you encrypt the value (as the viewstate does) I would find it much hadrer to decypher the key. The alternative is to store it in...
Do you want the end user to know the ID? For example if the id value is a standard 1,1 seed from the database I could look at the number and see how many customers you have. If you encrypt the value (as the viewstate can) I would find it much harder to decypher the key (but not impossible). The alternative is to st...
The simplest option would be creating a table with a row per list item, a column for the item position, and columns for other data in the item. Then you can use ORDER BY on the position column to retrieve in the desired order. create table linked_list ( list_id integer not null , position integ...
Apply stroke to a textblock in WPF
|wpf|fonts|xaml|
How do you apply stroke (outline around text) to a textblock in xaml in WPF?
|.net|wpf|xaml|
What specifically are you testing for? Cross browser compliance? Performance? Usability? That's a pretty broad question - can you define it a little more?
Another alternative to consider is to use probabalistic prime generation. There is an example of this in Joe's book (the "prime server") which uses Miller-Rabin I think...
* Shared Ownership * boost::shared_ptr When a resource is shared between multiple objects. The boost shared_ptr uses reference counting to make sure the resource is de-allocated when everybody is finsihed.
Use singletons with care (or not at all if you want easy tests!) - [Singletons are Pathological Liars][2] - [Where Have All the Singletons Gone][1] - [Root Cause of Singletons][3] [1]: http://googletesting.blogspot.com/2008/08/where-have-all-singletons-gone.html [2]: http://googletesti...
Problems with accessing FlashVars via parameters in AS3
|flash|flashvars|actionscript-3|as3|parameters|
I keep getting compiler errors when I try to access flashVars in an AS3 class. Here's a stripped version of the code: package myPackage { import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; public class myClass { public function CTrafficHandler()...
I keep getting compiler errors when I try to access flashVars in an AS3 class. Here's a stripped version of the code: package myPackage { import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; public class myClass { public function CTrafficHandler()...
|flash|actionscript-3|parameters|flashvars|
AMFPHP service new service error
|actionscript-3|as3|flash|amfphp|
I am trying to add a new hello world service to amfphp, I am developing locally <?php /** * First tutorial class */ class HelloWorld { /** * first simple method * @returns a string saying 'Hello World!' */ function sayHello() { return "Hello W...
|flash|actionscript-3|amfphp|
I'm a big fan of jQuery (as evidenced by my having written both a [plug-in][1] and a [Dashboard widget][2] for it). One thing to be aware of is [which browsers jQuery supports][3]. The docs site appears to be having issues at the moment. That's another thing to be aware of... ;-) [1]: http://code.google.com/p...
There is no 64-bit Jet OLEDB provider, so you can't access Excel files from 64-bit SSIS. However, you can use 32-bit SSIS even on 64-bit server. It is already installed when you installed 64-bit version, and all you need to do is run the 32-bit DTEXEC.EXE - the one installed **Program Files (x86)\Microsoft Sql Serve...
Some would call this a matter of taste, but: aWizz = wizz || "default"; // same as: if (wizz) { aWizz = wizz; } else { aWizz = "default"; } barredWiz = (foo && bar(foo)) || "barred foo"; // same as: if (foo) { barredWiz = bar(foo) } else { barredWiz = "barred foo" } The trinary...
C# Regex index in matching string where the match failed
|regex|c#|regular-expressions|
I am wondering if it is possible to extract the index position in a given string where a Regex failed when trying to match it? For example, if my regex was "abc" and I tried to match that with "abd" the match would fail at index 2. Thanks
|c#|regex|regular-expressions|
I am wondering if it is possible to extract the index position in a given string where a Regex failed when trying to match it? For example, if my regex was "abc" and I tried to match that with "abd" the match would fail at index 2. Thanks Edit for clarification. The reason I need this is to allow me to simp...
|c#|regex|
You should use SQL's built in COUNT function: $result = mysql_query("SELECT COUNT(id) FROM table");
You should use <a href="http://dev.mysql.com/doc/refman/5.0/en/counting-rows.html">SQL's built in COUNT function</a>: $result = mysql_query("SELECT COUNT(id) FROM table");
How do you set directory permissions in NSIS?
For those of you with VB.NET experience, (type) is the same as DirectCast and "as type" is the same as TryCast.
'id' is a built-in method in Python. Assigning a value to 'id' will overwrite the method. It is best to use either an identifier before as in "some_id" or use it in a different capitalization method. The built in method takes a single parameter and returns an integer for the memory address of the object that you pas...
SimpleXML and DOM work seamlessly together, so you can use the same XML interacting with it as SimpleXML or DOM. For example: $simplexml = simplexml_load_string("<xml></xml>"); $simplexml->simple = "it is simple."; $domxml = dom_import_simplexml($simplexml); $node = $domxml->ownerDocument->cr...
I've been using TextWrangler, it's pretty decent. But I REALLY miss the Search and Replace and other capabilities of UltraEdit... enough that it's usually worth firing up Parallels to use it instead (UltraEdit runs poorly under Wine at the moment).
I would make it a three step process with a slight temporary modification to your SpeciesFoundInCountry table. I would add a column to that table to store the Country name. Then the steps would be as follows. 1) Create/Run a script that walks columns in the source table and creates a record in SpeciesFoundInCountr...
I use it to invoke **Intellisense** just like [JohnMcG](http://stackoverflow.com/questions/23250/when-do-you-use-the-this-keyword#27246), but I'll go back and erase "this->" when I'm done. I follow the Microsoft convention of prefixing member variables with "m_", so leaving it as documentation would just be redundant.
I kind of feel compelled to test private functions as I am following more and more one of our latest QA recommendation in our project: > No more than 10 in [cyclomatic complexity][1] per function. Now the side effect of the enforcing of this policy is that many of my very large public functions get divided in man...
Block elements will typically stack vertically whereas inline elements will line up horizontally. Two Divs will stack on top of each other, but if you set them to display:inline, they will be next to each other horizontally. Vise-versa with Span tags.
The reports aren't going to be available until after the data has been copied to the data warehouse. This can typically take up to one hour to do. See [http://msdn.microsoft.com/en-us/library/ms404692(VS.80).aspx][1] [1]: http://msdn.microsoft.com/en-us/library/ms404692(VS.80).aspx
display: block <br />will cause the object to force other objects within a container on to a new line. display: inline <br />tries to display the object on the same line as other objects. display:block <pre> Item 1 Item 2 Item 3 </pre> display:inline <pre> Item 1 Item 2 Item 3 </pre>
Based on the pattern in C#/WPF the ICommand Interface (System.Windows.Input.ICommand) is defined to take an object as a parameter on the Execute, as well as the CanExecute method. interface ICommand { bool CanExecute(object parameter); void Execute(...
Based on the pattern in C#/WPF the ICommand Interface (System.Windows.Input.ICommand) is defined to take an object as a parameter on the Execute, as well as the CanExecute method. interface ICommand { bool CanExecute(object parameter); void Execute(...
This depends on your MTA and how you've configured it. Ultimately there is only one thing you must do to prevent relaying. Restrict relaying to authenticated users and/or restrict relaying to specific IPs. I prefer to restrict all IPs except localhost on my mail server and require authentication from everyone else. ...
NDepend CQL Count Query
|ndepend|cql|aggregate|query|
I want to get query a table of public methods of a specific class and a count of each methods usage in NDepend CQL. Currently query looks like this: > SELECT METHODS FROM TYPES > "AE.DataAccess.DBHelper" WHERE > IsPublic Is it possible to aggregate queries in CQL?
|query|aggregate|ndepend|cql|
I want to query a table of public methods of a specific class and a count of each methods usage in NDepend CQL. Currently query looks like this: > SELECT METHODS FROM TYPES > "AE.DataAccess.DBHelper" WHERE > IsPublic Is it possible to aggregate queries in CQL?
Microsoft has UI Automation built into the .Net Framework. You may be able to use this to simulate a user utilising your software in the normal way. There is an MSDN article &quot;<a href="http://msdn.microsoft.com/en-us/library/aa348551.aspx" title="MSDN - Using UI Automation for Automated Testing">Using UI Automa...
The order of evaluation for arguments to a function is undefined. In this case it appears that it did them right-to-left. (Modifying variables between sequence points basically allows a compiler to do anything it wants.)
What's the difference between a "script" and an "application"?
|terminology|
I'm referring to distinctions such as in [this answer](http://stackoverflow.com/questions/17231/why-shouldnt-i-bet-the-future-of-the-company-on-shell-scripts#92305). As programmer who's worked in many languages, this seems to be C, Java and other compiled language snobbery. I'm not looking for reenforcement of my opi...
[Here][1] is some code I wrote for handling images. It is in c++ ( not c ) but you should be able to easily extract the BMP and GIF load code. It's licensed LGPL. I use the libpng and jpeglib for decompressing those formats. [1]: http://code.google.com/p/kgui/source/browse/trunk/kguiimage.cpp
To prepare or handle a spike (or peak) performance, I would first determine whether you are ready through some simple performance testing with something like [jmeter][1]. It is easy to setup and get started and will give you early metrics whether you will handle an expected peak load. However given your time cons...
In terms of User Acceptance? Bug hunting? Load testing? For the first one, get other people to use it and comment on it. For the second one you should use your test plans and test cases that you wrote beforehand to test the UI, in terms of data validation (server-side as well as javascript), range checking and al...
AspUnit which can be found on SourceForge.net. However the project is no longer actively developed but it will work on .Net 1.1 and 2.0.
updating to an older rev will not delete your newer revs. so you could do `svn up -r2 file`, then `svn up -r4 file`. also, you wouldn't be able to commit the r2 file this way, because you'd have to update before committing, and you'd end up with r4 again.
Add something like this to Makefile.am scriptsdir = $(prefix)/bin scripts_DATA = awkscript1 awkscript2 In this case it will install awkscript in $(prefix)/bin (you can also use $(bindir)). Note: Dont forget that the first should be named name + dir (scripts -> scriptsdir) and the second should be name...
What is your target system? Is it multi-core? If so you could consider multithreading this algorithm
I think if you set a default size to a element like a container or the body, then any relative font-sizes in the children are based on the parent elements. Only if you don't specify a font-size anywhere does it just default to the browser (which they all have different sizes at that).
`std::tr1::shared_ptr<Blah>` is quite often your best bet.
&lt;TextBlock&gt; has no decorative attributes itself. I would put it on a &lt;Canvas&gt; with a &lt;Rectangle&gt; and apply the stroke there.
Unfortunately, no. Identifying the user just from the database connection AND sharing database connections between users are mutually exclusive.
If you're going to use a List<int>, use the BinarySearch: // initailize to a size if you know your set size List<int> FoundKeys = new List<int>( 64000 ); Dictionary<int,int> FoundDuplicates = new Dictionary<int,int>(); foreach ( int Key in MyKeys ) { // this is an O(log N) oper...
ScArcher2 has the simplest sollution. If you wanted something as compact as possible, you could create a tag library with a "sum" function in it. Something like: class MySum { public double sum(List list) {...} } In your TLD: <function> <name>sum</name> <function-class>my.MySum</function-class> <function-si...
I'm with jjnguy. Try one of the scripting languages. Plus as a bonus, when you learn Ruby/PythonPearl, etc...it's a gateway drug...err language to developing for other environments.
I use python for prototyping, since there's almost no turn around time between edits and actually running the new version of the code. I may even end up using it for a real project - the more I use it, the more I like it. It will take some getting used to as a C# programmer, though - the indentation-defines-structur...
Extend the JDialog class (for example name it MyDialog) and set the icon in constructor. Then all dialogs should extend your implementation (MyDialog).
New in the latest version! <<<Math.INT_MAX>>>; Answer from Kassen on the [chuck-users mailing list][1]. [1]: https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
New in the latest version! <<<Math.INT_MAX>>>; For reference though, it uses the "`long`" keyword in C++ to represent integers. So on 32-bit computers the max should be `0x7FFFFFFF`, or `2147483647`. On 64-bit computers it will be `0x7FFFFFFFFFFFFFFFFF`, or `9223372036854775807`. Answer from Kassen and S...
Here is an article, [Advanced JavaScript Debugging Techniques][1], that describes the use of several tools. One new tool I learned about that I hadn't heard of before is [JSLint][2]. Sometimes [JSLint][3] just immediately shows you your dodgy code that is causing the issue. [1]: http://www.sitepen.com/blog/200...
A salted hash should work just fine. Having a salt-per-user system should be plenty of security.
Comparing hashes is a good solution. Make sure that you don't just salt all the credit card numbers with the same constant salt, though. Use a different salt (like the expiration date) on each card. This should make you fairly impervious to dictionary attacks. From [this Coding Horror article][1]: > Add a long, u...