instruction
stringlengths
0
30k
The above method calls for using the SavingChanges event which is called before the changes are persisted. If there is an error during the save, you have already cleared your dirty flag. I would think there would be a SavedChanges event exposed as well.
You can generate data plans with VSTS Database Edition (with the latest 2008 Power tools). It includes a Data Generation Wizard which allows automated data generation by pointing to an existing database so you get something that is realistic but contains entirely different data
AS far as I know, there is no way to localize a report (meaning automating the translation of string litterals)... Like you said,you basically have to use the User!Language global variable to catch the user's settings and then use that to retrieve the appropriate strings from the DB... However, you can adapt the ...
My solution was to put the form on a seperate page and pass a timestamp to it. On that page I only display the form if the timestamp is valid (not too fast, not too old). I found that bots would always hit the submission page directly and only humans would navigate there correctly. May not work for you since you h...
My solution was to put the form on a seperate page and pass a timestamp to it. On that page I only display the form if the timestamp is valid (not too fast, not too old). I found that bots would always hit the submission page directly and only humans would navigate there correctly. Won't work if you have the form ...
No I wish there was but the programming effort seems too much since there are multiple ways to reference a single element. The best that you can do is use a runtime like FireBug to find duplicates.
I've always gone the string.Format() route. Being able to store formats in variables like Nathan's example is a great advantage. In some cases I may append a variable but once more than 1 variable is being concatenated I refactor to use formatting.
Here`s one: <http://www.codeplex.com/ResourceRefactoring>
If they are *nearly* the same then here is some pseudo code: Make an ArrayList Copy the contents of the smaller array to the arraylist for each item I in the larger array FInd I in the ArrayList Append I to a new array Remove I from the arraylist
What you need to do is determine the ordering of B and then apply that ordering to A. One way to accomplish this is to undo the ordering of B and keep track of what happens along the way. Then you can do the reverse to A. Here's some sketchy C# (sorry, I haven't actually run this)... Take a copy of B: ...
From MSDN: "The CompareTo method was designed primarily for use in sorting or alphabetizing operations. It should not be used when the primary purpose of the method call is to determine whether two strings are equivalent. To determine whether two strings are equivalent, call the Equals method." T...
vEdit is great for this. I routinely open up 100+ meg files with it. It has regex support and loads of other features. 70 dollars is cheap for the amount you can do with it.
vEdit is great for this. I routinely open up 100+ meg (i know you said up to one gig, I think they advertise on their site it can handle twice that) files with it. It has regex support and loads of other features. 70 dollars is cheap for the amount you can do with it.
vEdit is great but don't forget you can always go back to "basics" check out [Cygwin][1] and start greping. Helpfull commands - grep - head - tail - of course perl! [1]: http://www.cygwin.com/
In the forms you listed here, there's not much difference between the two. <code>CompareTo</code> ends up calling a <code>CompareInfo</code> method that does a comparison using the current culture; <code>Equals</code> is called by the <code>==</code> operator. If you consider overloads, then things get different. ...
Put the code in a method and you save a temporary and a `break` (and you recycle code, as a bonus): T Find<T>(IEnumerable<T> items, Predicate<T> p) { foreach (T item in items) if (p(item)) return item; return null; } … but of course this method already ex...
Let `Y = 0.3*R + 0.59*G + 0.11*B` for each pixel in the image, then set them to be `((R1+Y)/2,(G1+Y)/2,(B1+Y)/2)` if `(R1,G1,B1)` is what you are colorizing with.
Maybe the .NET designers did it this way because JAVA did it this way... Embrace and extend. :) See: http://discuss.techinterview.org/default.asp?joel.3.349728.40
> @ Konrad: So how do you use it? Let's say I want to match mo.ID to magicNumber. In C# 2.0 you'd write: result = mObjList.Find(delegate(int x) { return x.ID == magicNumber; }); 3.0 knows lambdas: result = mObjList.Find(x => x.ID == magicNumber);
Using a Lambda expression: List<MyObject> list = new List<MyObject>(); // populate the list with objects.. return list.Find(o => o.Id == myCriteria);
Well I guess you have to be rather particular about it, but like people are saying, it makes more sense for String.Format to be static because of the implied semantics. Consider: "Hello {0}".Format("World"); // this makes it sound like Format *modifies* // the string, which is ...
Well I guess you have to be rather particular about it, but like people are saying, it makes more sense for String.Format to be static because of the implied semantics. Consider: "Hello {0}".Format("World"); // this makes it sound like Format *modifies* // the string, which is ...
How to handle including needed classes in PHP
|php|
I'm wondering what the best practice is for handling the problem with having to "include" so many files in my PHP scripts in order to ensure that all the classes I need to use are accessible to my script. Currently, I'm just using include_once to include the classes I access directly. Each of those would include_once...
Yes, I think using a [CDATA][1] block would protect the whitespace. Although some parser APIs allow you to preserve whitespace. [1]: http://en.wikipedia.org/wiki/CDATA
For a given integer, the fastest primality check I know is: > 1. Take a list of 2 to the square root of **the integer**. > 2. Loop through the list, taking the remainder of **the integer** / **current number** >> 1. If the remainder is zero for any number in the list, then the integer is not prime. >> 2. If the r...
[The Sieve of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) is a decent algorithm: > 1. Take the list of positive integers 2 to any given Ceiling. > 2. Take the next item in the list (2 in the first iteration) and remove all multiples of it (beyond the first) from the list. > 3. Repeat step two...
[The Sieve of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) is a decent algorithm: > 1. Take the list of positive integers 2 to any given Ceiling. > 2. Take the next item in the list (2 in the first iteration) and remove all multiples of it (beyond the first) from the list. > 3. Repeat step two...
I don't think that pointers themselves are confusing. Most people can understand the concept. Now how many pointers can you think about or how many levels of indirection are you comfortable with. It doesn't take too many to put people over the edge. The fact that they can be changed accidently by bugs in your progr...
What is Turing Complete?
|language|theory|
What does the expression Turing Complete means? Can you give a simple explanation, without going into too much theoretical details?
It depends on how you're reading and writing the XML. If XML is being generated automatically - if newlines or explicit **\n** flags are being parsed into **<br />** - then there's nothing to worry about. Your input likely doesn't have any other XML in it so it's just cleaner to not mess with XML at all. If tags...
Reasons for SQL differences
|sql|sql-server|postgresql|
First of all, I should point out that I'm not asking this question for any practical reason. I'm just asking out of sheer curiosity. Why is it that SQL distributions are so non-standard? I know there's an ANSI standard for SQL, but it just seems that developers of SQL databases go out of their way to find differen...
It's a form of "Stealth lock-in". Joel goes into great detail here: - http://www.joelonsoftware.com/articles/fog0000000056.html - http://www.joelonsoftware.com/articles/fog0000000052.html Companies end up tying their business functionality to non-standard or weird unsupported functionality in their implement...
Equivalent to StAX for C
|java|c|xml|
I've used the StAX API in Java quite a bit, and find it quite a clean way of dealing with XML files. Is there any equivalent library I could use for performing similar processing in C?
The primary problem you are going to run into is that you'll have two login forms, and two logout methods. What you need to do is pick one of the login forms as the default, and redirect the other one over to it. I've been able to [successfully integrate][1] bbPress + MediaWiki + WordPress + WordPress MU, but I wrot...
My favorites are Effective C++, More Effective C++, and Effective STL by Scott Meyers. Also C++ Coding Standards by Sutter and Alexandrescu.
[libxml](http://xmlsoft.org/) is a heavily used and documented XML library for C, which provides a SAX API. [Expat](http://expat.sourceforge.net/) is another, but in my experience is not as well documented.
The ANSI standard specifies only a limited set of commands and data types. Once you go beyond those, the implementors are on their own. And some very important concepts aren't specified at all, such as auto-incrementing columns. SQLite just pics the first non-null integer, MySQL requires `AUTO INCREMENT`, PostgreSQL us...
Here's one: <http://www.codeplex.com/ResourceRefactoring> It'a actually a Microsoft "open source" Visual Studio(2005 and up) tool that integrates with the IDE. You can easily replace every occurence of a string with a ressource reference with a few clicks.
Unless I am reading the documentation incorrectly I don't think you have to do anything. [GWT and Locale][1] > By making locale a client property, the standard startup process in gwt.js chooses the appropriate localized version of an application, providing ease of use (it's easier than it might sound!), optimize...
For your specific example, there is no need to worry about it. Web browsers perform typographical rendering and place the correct amount of space between periods and whatever character follows (and it's different depending on the next character, according to kerning rules.) If you want line breaks, &lt;br/&gt; isn't...
For your specific example, there is no need to worry about it. Web browsers perform typographical rendering and place the correct amount of space between periods and whatever character follows (and it's different depending on the next character, according to kerning rules.) If you want line breaks, &lt;br/&gt; isn't...
There are ways of doing this in optional parts of the standard, but a lot of databases. A really good site that talks about this and other things is <http://troels.arvin.dk/db/rdbms/#select-limit>. Basically PostgreSQL and MySQL supports SELECT... OFFSET x LIMIT y Oracle, DB2 and MSSQL supports the stand...
Is there any tool for merging CSS?
|css|
I have a couple CSS files with overlapping CSS selectors that I'd like to programmatically merge (as in not just appending one file to the end of the other). Is there any tool to do this online? or a Firefox extension perhaps?
Are there any tools for merging CSS?
I'd like to cast another vote for using stored procs (despite the hassle they can introduce when it comes to maintenance and versioning) as a way to restrict direct access to the underlying tables for better security.
SQL 2000 'TRY CATCH like' Error Handling
|sql-server|
This is a sql 2000 database that I am working with. I have a what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.) The way I was going to do this was to ite...
This is a sql 2000 database that I am working with. I have a what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.) The way I was going to do this was to ite...
This is a sql 2000 database that I am working with. I have a what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.) The way I was going to do this was to ite...
This is a sql 2000 database that I am working with. I have what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.) The way I was going to do this was to itera...
Compatibility mode - the mode that helps you create exports compabible with different versions of MYSQL or other databases. You see, some versions of MySQL had different commands that were used in various versions. So what compatibility mode allows you to do is take a database and export the SQL to be compatible wi...
`__autoload` works well if you have a consistent naming convention for your classes that tell the function where they're found inside the directory tree. MVC lends itself particularly well for this kind of thing because you can easily split the classes into models, views and controllers. Alternatively, keep an assoc...
__autoload will work, but only in PHP 5.
I think you should just use SSL and rely on an HTTP client library that does caching (Ex: WinInet on windows). It's hard to imagine that the benifits of enterprise wide caching is worth the pain of writing a custom security encryption scheme or certificate fun on the proxy. Worse, on the encyrption scheme you mention, ...
An option that might work for you is to use an svn:external reference to the library. When tagging the project, you can do one of two things: * Update the svn:external to refer to a specific revision of the library; OR * Update the svn:external to refer to a new tag that you make on the library. Since the svn:e...
There is another alternative, which is the approach utilized by the STL of C++: find(haystack.begin(), haystack.end(), needle) I think it's a great example of C++ shouting "in your face!" to OOP. The idea is that OOP is not a silver bullet of any kind; sometimes things are best described in terms of actions...
\[start\](.*?)\[end\]
\[start\](.*?)\[end\] which'll put the text in the middle within a capture
I don't know how accurate that hostip.info site is. I just visted that site, and it reported that my country is Canada. I'm in the US and the ISP that my office uses only operates from the US. It does allow you to correct it's guess, but if you are using this service to track web site vistors by country, you'll have...
<p>i found the answer. all you have to do is add #n after .ppt. e.g. http://www.whatever.com/hello.ppt#4 will take you straight to the 4th slide.</p>
All memory leaks are resolved by program termination. Leak enough memory and the Operating System may decide to resolve the problem on your behalf.
One of the many comparisons: [http://wiki.scummvm.org/index.php/CVS_vs_SVN][1] Now this is very specific to that project, but a lot of stuff apllies in general. Pro Subversion: > * Support for versioned renames/moves (impossible with CVS): Fingolfin, Ender > * Supports directories natively: It's possi...
I'll just post here since some of the other posts are slightly inaccurate in relation to C#. Correct: int is an alias for System.Int32. Wrong: float is not an alias for System.Float, but for System.Single Basically, int is a reserved keyword in the C# programming language, and is an alias for the System.Int32 ...
The ANSI standard specifies only a limited set of commands and data types. Once you go beyond those, the implementors are on their own. And some very important concepts aren't specified at all, such as auto-incrementing columns. SQLite just picks the first non-null integer, MySQL requires `AUTO INCREMENT`, PostgreSQL u...
Thanks for those links. Looks like GROK is dead - but it may work still for my purposes. 2 more links: * [http://classifier4j.sourceforge.net/][1] * [http://www.corporasoftware.com/products/summarize.aspx][2] The Attempto Controlled English is an interesting concept: as it's a completely reverse way of lookin...
I have used Expat pretty extensively - I like it for its simplicity and small footprint.
Almost all games have a need for the fast-reacting properties (and to a lesser extend, the connectionless properties) of UDP and the raliability of TCP. What they do is they build their own reliable protocol on top of UDP. This gives them the ability to just burst packets to whereever and optionally make them reliable,...
Almost all games have a need for the fast-reacting properties (and to a lesser extent, the connectionless properties) of UDP and the reliability of TCP. What they do is they build their own reliable protocol on top of UDP. This gives them the ability to just burst packets to whereever and optionally make them reliable,...
This is a sql 2000 database that I am working with. I have what I call a staging table that is a raw data dump of data, so everything is ntext or nvarchar(255). I need to cast/convert all of this data into the appropriate data types (ie int, decimal, nvarchar, etc.) The way I was going to do this was to itera...
To answer exactly: [yes][1]. There are s*-tons of info written on 'good' database design. Although youe example rule of thumb is certainly questionable. [1]: http://www.amazon.com/s/ref=nb_ss_b/102-6537774-4068964?url=search-alias%3Dstripbooks&field-keywords=database+design+patterns&x=0&y=0
Given that I have a hash of id(key) and countries(values) sorted alphabetically, what is the best way to bubble up an entry to the top of the stack?
|php|algorithm|
This is a php example, but an algorithm for any language would do. What I specifically want to do is bubble up the United States and Canada to the top of the list. Here is an example of the array shortened for brevity. array( 0 => '-- SELECT --', 1 => 'Afghanistan', 2 => 'Albania', 3...
|php|algorithm|hash|
This is a php example, but an algorithm for any language would do. What I specifically want to do is bubble up the United States and Canada to the top of the list. Here is an example of the array shortened for brevity. array( 0 => '-- SELECT --', 1 => 'Afghanistan', 2 => 'Albania', 3...
GVim can handle files that large for free if you are not attached to a true spreadsheet static field size view.
You can retrieve this information through WMI. See the [Win32_Process][1] class, in particular its command line property. This [Code Project article][2] provides pointers on how to do this, [1]: http://msdn.microsoft.com/en-us/library/aa394372.aspx [2]: http://www.codeproject.com/KB/cs/EverythingInWmi02.a...
Of the three, I prefer option #3. The [Single Responsibility Principle][1] makes me not want to put searching capabilities on my DTOs or models. Their responsibility is to be data, not to find themselves, nor should needles need to know about haystacks, nor haystacks know about needles. For what it's worth, I thi...
We use Programming Research's [QAC][1] for our C code. Works OK. Recently we have been talking about checking out some of the more advanced and static/dynamic code analyzers like Coverity's [Prevent][2] or the analysis tool by [GrammaTech][3]. They claim to not only do static analysis but also find runtime errors etc. ...
How do I search content, within audio files/streams?
|speech-recognition|audio|search|speech-to-text|
I have always wondered how many different search techniques existed, for searching text, for searching images and even for videos. However, I have never come across a solution that searched for content within audio files. <br> **For example:** Let us assume that I have about 200 podcasts downloaded to my PC in th...
|search|audio|speech-recognition|
You might find [piston](http://piston.rubyforge.org/) provides a solution It's primarily used for importing ruby on rails plugins, but I don't see why it shouldn't work for any subversion repositories. Basically what it does is this: * svn export latest revision of the remote path * commit these files into yo...
In MySQL: select * from thetable limit n, 1 That is why I love MySQL.
There is a page regarding this topic on [webtypography.net][1]. That site has many other interesting things about creating text for the web from the point of view of typography, things that web page designers often don't even think about. It's worth reading. [1]: http://www.webtypography.net/Rhythm_and_Proportio...
@Daniel Fone: The SVN docs recommend one project per repository, so that is definitely the way the creators intended it to go. As you can have one server (apache or svnserve) maintain multiple repositories, I've never run into a problem of too much overhead. With [VisualSVN Server](http://www.visualsvn.com/server/), in...
Your regular expression should follow Perl syntax, meaning it has to start and end with the same character (with some exceptions). Also, the back reference should start with a double slash, to get around PHPs double escaping. This should work (with a quick test): $str = "asdfasdf |123123 asdf iakds |302 asdf |11...
Here's what I've used in VB.NET. Essentially the same as presented, except I usually didn't want to create the folder immediately. The advantage to use [GetRandomFilename][1] is that it doesn't create a file, so you don't have to clean up if your using the name for something other than a file. Like using it...