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 display of currency/numeric/date fields according to the user locale. Also possible is changing the interface of the Report Viewer to match your user's langage. Here are a few links giving tips on how to adapt the locale: <http://www.ssw.com.au/Ssw/Standards/Rules/RulesToBetterSQLReportingServices.aspx#LanguageSetting> Langage pack for Report Viewer: <http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=e3d3071b-d919-4ff9-9696-c11d312a36a0>
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 have the form on the content page itself.
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 on the content page itself like you do now, but you could show/hide the link to the special submission page based on noscript. A minor inconvienience for such a small percentage of users.
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: List<int> B2 = new List<int>(B); Now sort it, using a sort function that records the swaps: List<KeyValuePair<int,int>> swaps = new List<KeyValuePair<int,int>>(); B2.Sort( delegate( int x, int y ) { if( x<y ) return -1; if( x==y ) return 0; // x and y must be transposed, so assume they will be: swaps.Add( new KeyValuePair<int,int>(x,y) ); return 1; }); Now apply the swaps, in reverse order, to A: swaps.Reverse(); foreach( KeyValuePair<int,int> x in swaps ) { int t = A[x.key]; A[x.key] = A[x.value]; A[x.value] = t; } Depending how the built-in sort algorithm works, you might need to roll your own. Something nondestructive like a merge sort should give you the correct results.
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." They suggest using .Equals instead of .ComapreTo when looking solely for equality. I am not sure if there is a difference between .Equals and == for the string class. I will sometimes use .Equals or Object.ReferenceEquals instead of == for my own classes in case someone comes along at a later time and redefines the == operator for that class.
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. <code>Compare</code> and <code>==</code> can only use the current culture to compare a string. <code>Equals</code> and <code>String.Compare</code> can take a <code>StringComparison</code> enumeration argument that let you specify culture-insensitive or case-insensitive comparisons. Only <code>String.Compare</code> allows you to specify a <code>CultureInfo</code> and perform comparisons using a culture other than the default culture. Because of its versatility, I find I use <code>String.Compare</code> more than any other comparison method; it lets me specify exactly what I want.
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 exists anyway for Lists, even in .NET 2.0.
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 not possible as // strings are immutable. string[ parts = "Hello World".Split(' '); // this however sounds right, // because it implies that you // split an existing string into // two *new* strings.
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 not possible as // strings are immutable. string[] parts = "Hello World".Split(' '); // this however sounds right, // because it implies that you // split an existing string into // two *new* strings.
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 the classes that they access. I've looked into using the __autoload function, but hat doesn't seem to work well if you plan to have your class files organized in a directory tree. If you did this, it seems like you'd end up walking the directory tree until you found the class you were looking for. Also, I'm not sure how this effects classes with the same name in different namespaces. Is there an easier way to handle this? Or is PHP just not suited to "enterprisey" type applications with lots of different objects all located in separate files that can be in many different directories.
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 remainder was non-zero for all numbers in the list, then the integer is prime. It uses significantly less memory than [The Sieve of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) and is generally faster for individual numbers.
[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 until you reach the given Ceiling. > 4. Your list is now composed purely of primes.
[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 until you reach the given Ceiling. > 4. Your list is now composed purely of primes. There is a functional limit to this algorithm in that it exchanges speed for memory. When generating very large lists of primes the memory capacity needed skyrockets.
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 program can also make them very difficult to debug when things go wrong in your code.
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 are being worked with manually, it's still cleaner to just have a line break, if you ask me. The exception is if you're using DOM to get some structure out of the XML. In that case line breaks are obviously evil because they don't represent the heirarchy properly. It sounds like the heirarchy is irrelevant for your application, though, so line breaks sound sufficient. If the XML just looks bad (especially when automatically generated), [Tidy](http://tidy.sourceforge.net/) can help, although it works better with HTML than with XML.
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 different ways to do things. First of all I should ask: am I getting the point? Are there really that many meaningful differences in the way SQL databases work or is it just the two databases I've been working with (MS-SQL and Postgresql)? Next, why are there so many differences? I should say that I'm a beginner of this, so I haven't gotten to any of the bigger issues that I may be missing.
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 implementation, this restricts their ability to move away from their vendor to a competitor. On the other hand, it's pretty short-sighted because anyone with half a brain will tend to abstract away the proprietary pieces, or avoid the lock-in altogether, if it gets too egregious.
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 wrote a lot of custom code to do it. I'm using the bbPress login page as the default (and .htaccess rewrite to /login/), and then I created my own MediaWiki authentication plugin (which looks a lot like the one you are using), except my plugin checks the WordPress/bbPress cookie for the login information and automatically logs the user in. I created a customized /logout/ link that runs the bbPress logout, and also kills the MediaWiki cookies at the same time. Then the last step was to redirect all of the other logout / login links for bbpress, mediawiki, etc, over to my consolidated one. I used .htaccess rewrites for this rather than mess with core code. Still a work in progress, but it works fairly well. [1]: http://www.howtogeek.com
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 uses sequences, etc. It's a mess, and that's only among the OSS databases! Try getting Oracle, Microsoft, and IBM to collectively decide on a tricky bit of functionality.
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!), optimized performance, and minimum script size. The way I read it, as long as your module has added all the locale choices to it, it should be automatic? [1]: http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.Internationalization.html#SpecifyingLocale
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 really a big deal, is it?
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 really a big deal, is it? ---- Not sure what's worthy of a downmod here... You should not be forcing two spaces after a period, unless you're using a monospace font. For proportional fonts, the rederer kerns the right amount of space after a period. See [here][1] and [here][2] for detailed discussions. [1]: http://www.webword.com/reports/period.html [2]: http://everything2.com/node/540926
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 standard windowing functions; SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY key ASC) AS rownumber, columns FROM tablename ) AS foo WHERE rownumber <= n (which I just copied from the site linked above since I never use those DBs)
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 iterate through all records using a while loop and attempt a CAST on each column on a single record during each iteration, after I visit a particular record I flag it as processed (bit field). But how can I log the error when/if it occurs but allow the while loop to continue. At first I implemented this using a TRY CATCH in a local SQL 2005 instance and all was working well, but i learned today that the production database is a SQL 2000 database so I have to conform.
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 iterate through all records using a while loop and attempt a CAST on each column on a single record during each iteration, after I visit a particular record I flag it as processed (bit field). But how can I log the error when/if it occurs but allow the while loop to continue. At first I implemented this using a TRY CATCH in a local SQL 2005 instance (to get the project going) and all was working well, but i learned today that the dev & production database that the international DBA's have set up is a SQL 2000 instance so I have to conform.
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 iterate through all records using a while loop and attempt a CAST on each column on a single record during each iteration, after I visit a particular record I flag it as processed (bit field). But how can I log the error when/if it occurs but allow the while loop to continue. At first I implemented this using a TRY CATCH in a local SQL 2005 instance (to get the project going) and all was working well, but i learned today that the dev & production database that the international DBA's have set up is a SQL 2000 instance so I have to conform. **EDIT**: I am using a SSIS package to populate the staging table. I see that now I must revisit that package and implement a script component to handle the conversions. Thanks guys **EDIT**: I _am_ doing this on a record by record basis, not a batch insert, so the transaction idea seems like it would be feasible but I'm not sure how to trap @@ERROR and allow the stored procedure to continue.
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 iterate through all records using a while loop and attempt a CAST on each column on a single record during each iteration, after I visit a particular record I flag it as processed (bit field). But how can I log the error when/if it occurs but allow the while loop to continue. At first I implemented this using a TRY CATCH in a local SQL 2005 instance (to get the project going) and all was working well, but i learned today that the dev & production database that the international DBA's have set up is a SQL 2000 instance so I have to conform. **EDIT**: I am using a SSIS package to populate the staging table. I see that now I must revisit that package and implement a script component to handle the conversions. Thanks guys **EDIT**: I _am_ doing this on a record by record basis, not a batch insert, so the transaction idea seems like it would be feasible but I'm not sure how to trap @@ERROR and allow the stored procedure to continue.
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 with another version of MySQL. Thus, you may want to upgrade your MySQL 3 server to 4 - this compatibility mode allows for the export your database or individual tables to create a SQL file that can import into a MySQL 4 version server (should work in 5 also). I use webmin, also, and run MySQL 5. I use compatibility mode for MySQL 4.... I steer clear of any of the other ones, because I'm not running those other databases. As far as the MySQL commands that were different between MySQL 3.x and 4.x, I believe there were changes in regards to how CURRENT_TIMESTAMP is translated from MySQL 3 to 4, and also MySQL 3 doesn't support charsets, according to this forum post here: http://www.phpbuilder.com/board/showthread.php?t=10330692 Hope this helps clear up your question.
`__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 associative array of names to file locations for your class and let `__autoload` query this array.
__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, doing asynmetric ciphers on the entity body sounds like a huge perf hit on the server side of your application; there is a reason that SSL uses symmetric ciphers for the actual payload of the connection.
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:external metadata will be part of the main project's commit history, you can always get the tag on the main project and it will refer to the correct version of the library. We do it and it works very well. It also comes in handy when you want to freeze the version of the library code that you depend on in preparation for a release.
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, sometimes in terms of objects, sometimes neither and sometimes both. Bjarne Stroustrup said in TC++PL that when you design a system you should strive to reflect reality under the constraints of effective and efficient code. For me, this means you should never follow anything blindly. Think about the things at hand (haystack, needle) and the context we're in (searching, that's what the expression is about). If the emphasis is about the searching, then using an algorithm (action) that emphasizes searching (i.e. is flexibly to fit haystacks, oceans, deserts, linked lists). If the emphasis is about the haystack, encapsulate the find method inside the haystack object, and so on. That said, sometimes you're in doubt and have hard times making a choice. In this case, be object oriented. If you change your mind later, I think it is easier to extract an action from an object then to split an action to objects and classes. Follow these guidelines, and your code will be clearer and, well, more beautiful.
\[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 no way of knowing if the data is correct. Of course, I'm just one data point. I downloaded the GeoLite Country database, which is just a .csv file, and my IP address was correctly identified as US. Another benefit of the MaxMind product line (paid or free) is that you have the data, you don't incur the performance hit of making a web service call to another system.
<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 possible to remove them, and they are versioned: Fingolfin, Ender > * File properties are versioned; no more "executable bit" hell: Fingolfin > * Overall revision number makes build versioning and regression testing much easier: Ender, Fingolfin > * Atomic commits: Fingolfin > * Intuitive (directory-based) branching and tagging: Fingolfin > * Easier hook scripts (pre/post commit, etc): SumthinWicked (I use it for Doxygen after commits) > * Prevents accidental committing of conflicted files: Salty-horse, Fingolfin > * Support for custom 'diff' command: Fingolfin > * Offline diffs, and they're instant: sev [1]: http://wiki.scummvm.org/index.php/CVS_vs_SVN
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 value type. float and Float is not the same however, as the right system type for ''float'' is System.Single. There are some types like this that has reserved keywords that doesn't seem to match the type names directly. In C# there is no difference between ''int'' and ''System.Int32'', or any of the other pairs or keywords/system types, except for when defining enums. With enums you can specify the storage size to use and in this case you can only use the reserved keyword, and not the system runtime type name. Wether the value in the int will be stored on the stack, in memory, or as a referenced heap object depends on the context and how you use it. This declaration in a method: int i; defines a variable *i* of type System.Int32, living in a register or on the stack, depending on optimizations. The same declaration in a type (struct or class) defines a member field. The same declaration in a method argument list defines a parameter, with the same storage options as for a local variable. (note that this paragraph is not valid if you start pulling iterator methods into the mix, these are different beasts altogether) To get a heap object, you can use boxing: object o = i; this will create a boxed copy of the contents of *i* on the heap. In IL you can access methods on the heap object directly, but in C# you need to cast it back to an int, which will create another copy. Thus, the object on the heap cannot easily be changed in C# without creating a new boxed copy of a new int value. (Ugh, this paragraph doesn't read all that easily.)
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 uses sequences, etc. It's a mess, and that's only among the OSS databases! Try getting Oracle, Microsoft, and IBM to collectively decide on a tricky bit of functionality.
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 looking at the problem. Not really practical for what I am trying to do. @mmattax As for the suggestion of taking a few sentences - I'm not trying to present a summary: otherwise that would be a nice [judo][2] solution. I'm looking to actually summarize the content to use for other evaluation purposes. [1]: http://classifier4j.sourceforge.net/ [2]: http://www.corporasoftware.com/products/summarize.aspx [3]: http://www.37signals.com/svn/posts/312-lingo-judo
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, as well. The reliable packet system is usually a simple retry-until-acknowledged system simpler than TCP but there are protocols which go way beyond what TCP can offer. Your situation sounds very simple. You'll probably be able to make the cleanest solution yourself - just make every client send back an "I head you" response and have the server keep trying until it gets it (or gives up). If you want something more, most custom protocol libraries are in C++, so I am not sure how much use they'll be to you. However, my knowledge here is a few years old - perhaps some protocols have been ported over by now. Hmm... RakNet and enet are two C/C++ libraries that come to mind.
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, as well. The reliable packet system is usually a simple retry-until-acknowledged system simpler than TCP but there are protocols which go way beyond what TCP can offer. Your situation sounds very simple. You'll probably be able to make the cleanest solution yourself - just make every client send back an "I heard you" response and have the server keep trying until it gets it (or gives up). If you want something more, most custom protocol libraries are in C++, so I am not sure how much use they'll be to you. However, my knowledge here is a few years old - perhaps some protocols have been ported over by now. Hmm... RakNet and enet are two C/C++ libraries that come to mind.
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 iterate through all records using a while loop and attempt a CAST on each column on a single record during each iteration, after I visit a particular record I flag it as processed (bit field). But how can I log the error when/if it occurs but allow the while loop to continue. At first I implemented this using a TRY CATCH in a local SQL 2005 instance (to get the project going) and all was working well, but i learned today that the dev & production database that the international DBA's have set up is a SQL 2000 instance so I have to conform. **EDIT**: I am using a SSIS package to populate the staging table. I see that now I must revisit that package and implement a script component to handle the conversions. Thanks guys **EDIT**: I _am_ doing this on a record by record basis, not a batch insert, so the transaction idea seems like it would be feasible but I'm not sure how to trap @@ERROR and allow the stored procedure to continue. **EDIT**: I really like [Guy's approach](http://stackoverflow.com/questions/33685/sql-2000-try-catch-like-error-handling#39161), I am going to implement it this way.
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 => 'Algeria', 4 => 'American Samoa', 5 => 'Andorra',)
|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 => 'Algeria', 4 => 'American Samoa', 5 => 'Andorra',) **Edit:** @Leigh The id's need to be intact. So making them -1 or -2 will unfortunately not work.
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.aspx
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 think it takes most OO practitioners a LONG time to understand why #3 is the best choice. I did OO for a decade, probably, before I really grokked it. @wilhelmtell, C++ is one of the very few languages with template specialization that make such a system actually work. For most languages, a general purpose "find" method would be a HORRIBLE idea. [1]: http://en.wikipedia.org/wiki/Single_responsibility_principle
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. One major selling point is supposed to be fewer false positives. Has anybody used any of these? [1]: http://www.programmingresearch.com/QAC_MAIN.html [2]: http://www.coverity.com/html/coverity-prevent.html [3]: http://www.grammatech.com/
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 the form of mp3, wav and ogg files. They are all named generically say podcast1.mp3, podcast2.mp3, etc. So, it is not possible to know what the content is, without actually hearing them. Lets say that, I am interested in finding out, which the podcasts talk about 'game programming'. I want the results to be shown as: * Podcast1.mp3 - 3 result(s) at time index(es) - 0:16:21, 0:43:45, 1:12:31 * Podcast21.ogg - 1 result(s) at time index(es) - 0:12:01 **So my questions:** * How could one approach this problem? * Are there are suitable algorithms developed to do something like this? One idea the cropped up in my mind was that, one could use a 'speech-to-text' software to get transcripts along with time indexes for each of the audio files, then parse the transcript to get the output. I was considering this as one of my hobby projects. Thanks!
|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 your local svn as if they were local files * attach metadata in the form of svn properties about the remote path and revision This means you can keep a reference to a particular version of a remote repo without having to have it constantly updated like with an svn external. if you want to update your local copy of the library to the latest remote version, you just do `piston update` You should also be able to look at the history of updates, by simply looking at the metadata - svn properties are versioned just like files and everything else
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_Proportion/Horizontal_Motion/2.1.4/
@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/), installing an apache server and configuring multiple repositories is a snap.
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"; $str = preg_replace("/([|]\d*)/", "\\1;", $str); echo $str; // prints "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 for folder name. Private Function GetTempFolder() As String Dim folder As String = Path.Combine(Path.GetTempPath, Path.GetRandomFileName) Do While Directory.Exists(folder) folder = Path.Combine(Path.GetTempPath, Path.GetRandomFileName) Loop Return folder End Function **Random** Filename Example: C:\Documents and Settings\username\Local Settings\Temp\u3z5e0co.tvq ---------- Here's a variation using a Guid to get the temp folder name. Private Function GetTempFolderGuid() As String Dim folder As String = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString) Do While Directory.Exists(folder) folder = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString) Loop Return folder End Function **guid** Example: C:\Documents and Settings\username\Local Settings\Temp\2dbc6db7-2d45-4b75-b27f-0bd492c60496 [1]: http://msdn.microsoft.com/en-us/library/system.io.path.getrandomfilename.aspx