instruction stringlengths 0 30k ⌀ |
|---|
this happens to me all the time.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// populate text boxes from database
}
} |
Start with unit testing. Specifically, check out TDD, Test Driven Development. The concept behind TDD is you write the unit tests first, then write your code. If the test fails, you go back and re-work your code. If it passes, you move on to the next one.
I take a hybrid approach to TDD. I don't like to write tests ... |
I set up a task to do this. I'm not aware of any way to make CruiseControl be that specific. I usually just chain a batch file to do the copy to the CC.net task. |
My experience is that 90% of queries and/or stored procedures should not be written at all (at least by hand).
Data access should be generated somehow automaticly. You can decide if you'd like to staticly generate procedures in compile time or dynamically at run time but when you want add column to the table (proper... |
Well, if you want to follow the TDD guys, **before you start to code** ;)
I am very much in the same position as you. I want to get more into testing, but I am currently in a position where we are working to "get the code out" rather than "get the code out right" which scares the crap out of me. So I am slowly tryin... |
Well, if you want to follow the TDD guys, **before you start to code** ;)
I am very much in the same position as you. I want to get more into testing, but I am currently in a position where we are working to "get the code out" rather than "get the code out right" which scares the crap out of me. So I am slowly tryin... |
R# has a feature called Highlight current line, which you have to enable in the ReSharper options. This looks like crap on dark background, high contrast themes, so if you use one I'd suggest going into the Visual Studio options, under Fonts & Colors and going to "ReSharper - current Line" and making the background co... |
Yes, 32 bit ubuntu has the same memory limitations.
There are exceptions to the 4GB limitation, but they are application specific... As in, Microsoft Sql Server can use 16 gigabytes with "Physical address Extensions" [PAE] configured and supported and... ugh
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=... |
Yes, 32 bit ubuntu has the same memory limitations.
There are exceptions to the 4GB limitation, but they are application specific... As in, Microsoft Sql Server can use 16 gigabytes with "Physical address Extensions" [PAE] configured and supported and... ugh
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=... |
Linux supports a technology called PAE that lets you use more than 4GB of memory, however I don't know whether Ubuntu has it on by default. You may need to compile a new kernel. |
Linux supports a technology called PAE that lets you use more than 4GB of memory, however I don't know whether Ubuntu has it on by default. You may need to compile a new kernel.
Edit: Some threads on the Ubuntu forums suggest that the server kernel has PAE on by default, you could try installing that. |
Choosing a desktop database |
|oracle-database|sql-server-ce| |
I'm looking for a desktop/embedded database. The two candidates I'm looking at are
Microsoft SQL Server CE and Oracle Lite. If anyone's used both of these products, it'd be great if you could compare them. I haven't been able to find any comparisons online.
The backend DB is Oracle10g.
Thanks! |
I'm looking for a desktop/embedded database. The two candidates I'm looking at are
Microsoft SQL Server CE and Oracle Lite. If anyone's used both of these products, it'd be great if you could compare them. I haven't been able to find any comparisons online.
The backend DB is Oracle10g.
Thanks!
Update: Clarifi... |
|database|oracle-database|sql-server-ce| |
If you have shell access you can run the command
$ du -h
or perhaps use this, if PHP is configured to allow execution:
<?php $d = escapeshellcmd(dirname(__FILE__)); echo nl2br(`du -h $d`) ?>
|
[http://code.google.com/p/geckofx/](http://code.google.com/p/geckofx/)
This is a nice .NET-wrapped version of Gecko |
Use encryption to protect information on the way.
Use obfuscation to protect information while your program still has it. |
Timeout not being honoured in connection string |
|sql-server|timeout| |
I have a long running SQL statement that I want to run, and no matter what I put in the "timeout=" clause of my connection string, it always seems to end after 30 seconds. I'm just using SqlHelper.ExecuteNonQuery() to execute it, and letting it take care of opening connections, etc.
Is there something else that coul... |
|sql-server|database|timeout| |
I think if you still want/need the data to be accessible, then partitioning some of your biggest or most-used tables could be an option. |
Why does Visual Studio create a new .vsmdi file? |
|visual-studio-2008| |
If I open a solution in Visual Studio 2008 and run a unit test then VS creates a new .vsmdi file in the Solution Items folder and gives it the next number available e.g. My Solution2.vsmdi.
Any idea why VS is doing this and how I can get it to stop doing this? |
|visual-studio-2008|visualstudioteamsystem|mstest| |
|visual-studio|visual-studio-2008|mstest| |
Using VLOOKUP in an array formula on Google Spreadsheets |
|google|spreadsheet|excel|formula| |
Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the `LOOKUP` function into an array formula works:
{=SUM(LOOKUP(grades, scoringarray))}
With the `VLOOKUP` function this does not work (only gets the score for the first grade). Google Spreadsheets does not appear t... |
|excel|google|spreadsheet| |
There is a site called [Softies on Rails][1] that is written by a couple of ex-.NET developers that may be of some use. They have a book called [Rails for .NET Developers][2] coming out in the next few months...
I started out on a Windows box using the [RadRails][3] plugin for Eclipse and the [RubyWeaver][4] extensi... |
If you are targeting .NET 2.0 or later, the class System.Security.Principal.SecurityIdentifier wraps a SID and allows you to avoid the error-prone Win32 APIs.
Not exactly an answer to your question, but who knows it may be useful. |
Cursors do have their place, however I think it's mainly because they are often used when a single select statement would suffice to provide aggregation and filtering of results.
Avoiding cursors allows SQL Server to more fully optimize the performance of the query, very important in larger systems. |
Sometimes the nature of the processing you need to perform requires cursors, though for performance reasons it's always better to write the operation(s) using set-based logic if possible.
I wouldn't call it "bad practice" to use cursors, but they do consume more resources on the server (than an equivalent set-based ... |
A couple questions:
- Does the user that executes your app (you?) have permission to write to the file?
- Is the file read-only?
- What is your connection string?
If you're using ASP, you'll need to add the IUSER_* user as in [this example][1].
[1]: http://support.microsoft.com/kb/195951/ |
There are very, very few cases where the use of a cursor is justified. There are almost no cases where it will outperform a relational, set-based query. Sometimes it is easier for a programmer to think in terms of loops, but the use of set logic, for example to update a large number of rows in a table, will result in... |
I'm no XML expert, but I find Option B to be more human readable, and I think it's just as machine readable as Option A. I believe that XML is designed to be both human and machine readable, so I would go for Option B myself.
----------
I just realized something else after Ryan Farley's post. If the Students or... |
First and often.
If I'm creating some new functionality for the system I'll be looking to initially define the interfaces and then write unit tests for those interfaces. To work out what tests to write consider the API of the interface and the functionality it provides, get out a pen and paper and think for a while ab... |
If you are using SQL Server 2005. Fire up the Management Studio and look at the Maintenance Plan section.
See [http://msdn.microsoft.com/en-us/library/ms187658.aspx][1] for an overview and [http://msdn.microsoft.com/en-us/library/ms189036.aspx][2] for details on the Maintenance plan wizard.
Finally, [http://msdn... |
In Excel, you would likely just write code to open the other worksheet, modify it and then save the data.
See [this tutorial][1] for more info.
I'll have to edit my VBA later, so pretend this is pseudocode, but it should look something like:
Dim xl: Set xl = CreateObject("Excel.Application")
xl.Open "... |
One expression per line.
There is no reason to obfuscate your code. The extra time you take typing the few extra terms, you save in debug time. |
What's the best way to detect if an IDataReader is empty? |
|c#|ado.net| |
It seems like IDataReader.Read() is always true at least one time (If I'm wrong about this let me know.) So how do you tell if it has no records without just wrapping it in a try/catch? |
As @Nir mentioned, it's better to have homogeneous environment. However if you decide to not use Oracle Light, I would highly recommend you to take a look at [Firebird][1]. It's one of best choices for desktop database scenarios.
[1]: http://www.firebirdsql.org/ |
Plugin for R# similar to CodeRush "statement highlight" |
|resharper|codehighlighter| |
See here [http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx][1] - for want of a better description - the statement block highlighting. I understand this is a feature of CodeRush - does R# have either anything similar, or a plugin to do the same?
[1]: http://www.hanselman... |
See here [http://www.hanselman.com/blog/InSearchOfThePerfectMonospacedProgrammersFontInconsolata.aspx][1] - for want of a better description - the statement block highlighting - eg in the pics on the link the "statement blocks" are grouped with a vertical line. I understand this is a feature of CodeRush - does R# have ... |
If you can't use the fileinfo extension, and you don't want to use mime_content_type, your options are limited.
Most likely you'll need to do a lookup based on the file extension. mime_content_type did something a bit more intelligent and actually looked for special data in the file to determine the mime type. |
You can leverage MySql in a number of ORMs, one of which is NHibernate. For the most part you can treat it as if you were running on SQL Server or Oracle. And with Linq2NHibernate, you can get nice LINQ syntax.
You'd lose the SqlDataSource control, but some would argue that it would actually be a blessing :)
An... |
The inherited call has to be made explicitly.
It is easy to forget to make the inherited call in a class constructor. In such a situation if a base class needs to initialize any data you have an access violation waiting to happen.
Perhaps you could override DoCreate and DoDestory in your TBaseForm class so you c... |
The inherited call has to be made explicitly. In general no language automatically calls the inherited function in equivalent situations (class constructors not included).
It is easy to forget to make the inherited call in a class constructor. In such a situation if a base class needs to initialize any data you hav... |
Unlike Java, where there are exceptions that must be declared to be raised (and some that don't have to be, but that's another story), any Python code may raise any exception at any time.
There are a list of [built-in exceptions][1], which generally has some description of when these exceptions might be raised. Its... |
Reintroducing functions in Delphi |
|delphi| |
Does anyone know what the motivation was for having the reintroduce keyword in Delphi?
If you have a child class that contains a function with the same name as a virtual function in the parent class and it is not declared with the override modifier then it is a compile error. Adding the reintroduce modifier in such... |
|delphi|oop|polymorphism| |
You mean... you want some sort of tree view?
You can actually get the treeview control to work... but you have to wrap it in server side form tag to function. You'll get the usual nastiness that that brings (like generated ids and viewstate) but it will work from a rendering perspective.
If you want to just crea... |
How to implement password protection for individual files? |
|ruby|gems| |
|ruby|rubygems| |
What are differences generic in C++ and Java? |
|c++|java|generic| |
Java has generic keyword and C++ provides very strong programming model with generic.
Then what is difference between C++ and Java generic?
|
|c++|java|generic|templates|language-features| |
|java|c++|generics|templates|language-features| |
Print out the keys and Data of a Hashtable in C# .NET 1.1 |
|c#|.net|hashtable| |
I need debug some old code that uses a Hashtable to store response from various threads.
I need a way to go through the entire Hashtable and print out both keys and the data in the Hastable.
How can this be done? |
|c#|.net-1.1|hashtable| |
|c#|.net-1.1|hashtable| |
I wrote some C# code to scan the cipher and give me some stats back. Here are some interesting results:
With a chunk size of 3,
- There are 236 chunks.
- There are 172 duplicates.
- The 323 code shows up a whopping
total of 29 times!
- The 333 code shows up 11 times.
- All othe... |
I wrote some C# code to scan the cipher and give me some stats back. Here are some interesting results:
With a chunk size of 3,
- There are 236 chunks.
- There are 172 duplicates.
- The 323 code shows up a whopping
total of 29 times!
- The 333 code shows up 11 times.
- All othe... |
I went to a presentation on unit testing at FoxForward 2007 and was told never to unit test anything that works with data. After all, if you test on live data, the results are unpredictable, and if you don't test on live data, you're not actually testing the code you wrote. Unfortunately, that's most of the coding I do... |
**Definitely - Option B.**
I wouldn't mix students and classes in the XML just the same way that I wouldn't mix students and classes in the same table in a database. |
I haven't found any compelling argument for using ad-hoc queries. Especially those mixed up with your C#/Java/PHP code. |
yeah everything you described (except maybe perf monitoring) can be done with database maintenance plans, back ups, shrinking log files etc. |
Being the author of cfix, I might be a little biased here -- but as a matter of fact, I am currently not aware of any other unit-testing framework for NT kernel mode.
If you should experience any problems with cfix, feel free to contact me. |
Option B, absolutely. When there's a logical grouping of similar items, it should have a parent item. That way, my parser won't have to step through all 500 student records checking to see if there are class records mixed in. |
Another compelling reason to use option B is error checking. If the original file is modified outside an XML application, or if no XSD schema is applied, there could be the case where you have an uneven number of students and classes.
At least if you have the students and classes grouped together, you will easily b... |
It sounds like you are trying to allow the "special content creators" save files in TFS Source Control without having to buy them a license to a Visual Studio Team Edition -- correct me if I'm wrong.
If that's the case, unfortunately I believe that you can't quite do that. Your users still need a Client Access Licen... |
I don't know about this control, but TinyMCE is:
http://tinymce.moxiecode.com/
It's what wordpress etc use. |
How do you represent your graph in memory?
Basically you have two (good) options:
- [an adjacency list representation][1]
- [an adjacency matrix representation][2]
in which the adjacency list representation is best used for a sparse graph, and a matrix representation for the dense graphs.
If you used s... |
One other thing that an RDBMS generally does for you is to provide concurrency by protecting you from simultaneous access by another process. This is done by placing locks, and there's some overhead from that.
If you're dealing with entirely static data that never changes, and especially if you're in a basically "s... |
What you want to get its the instant CPU usage (kind of)...
Actually, the instant CPU usage for a process does not exists. Instead you have to make two measurements and calculate the average CPU usage, the formula is quite simple:
AvgCpuUsed = [TotalCPUTime(process,time2) - TotalCPUTime(process,time1)] / [time2-t... |
|encryption|cryptography|password| |
I'm writing a little desktop app that should be able to encrypt a data file and protect it with a password (i.e. one must enter the correct password to decrypt). I want the encrypted data file to be self-contained and portable, so the authentication has to be embedded in the file (or so I assume).
I have a strategy... |
|encryption|passwords|cryptography| |
I'm writing a little desktop app that should be able to encrypt a data file and protect it with a password (i.e. one must enter the correct password to decrypt). I want the encrypted data file to be self-contained and portable, so the authentication has to be embedded in the file (or so I assume).
I have a strategy... |
if(dr.Read())
{
//do stuff
}
else
{
//it's empty
}
usually you'll do this though:
while(dr.Read())
{
}
|
Yes, if you want to use the interface then Read until false is the only way to test. If you are looking for a generic IDataReader implementation, you could try DbDataReader and use the HasRows property. |
Get MIME type of a local file in PHP5 without a PECL extension? |
|mime|php5| |
mime_content_type() is deprecated.
How can I find the MIME type of a local file using PHP5 but without using this deprecated method or the PECL fileinfo extension? |
mime_content_type() is deprecated.
How can I find the MIME type of a local file using PHP5 but without using this deprecated method or the PECL fileinfo extension?
Edit: That's what I was afraid of. It's unfortunate that they deprecated a built-in function in favour of one that requires an extension that isn't a... |
How do you Modify TextBox Control Tab Stops |