instruction stringlengths 0 30k ⌀ |
|---|
i have three tables *tag*, *page*, *pagetag*
With the next data
***page***
ID NAME
1 page 1
2 page 2
3 page 3
4 page 4
***tag***
ID NAME
1 tag 1
2 tag 2
3 tag 3
4 tag 4
***pagetag***
ID PAGEID TAGID
1 2 1
2 2 3
3 3 4
4 1 1
5 1 2
6 1 3
I would like to get a string containing the correspondent tag names for each page with SQL in a single query. This is my desired output.
ID NAME TAGS
1 page 1 tag 1, tag 2, tag 3
2 page 2 tag 1, tag 3
3 page 3 tag 4
4 page 4
Is this possible with SQL? |
if (typeof(T).IsValueType || typeof(T) == typeof(String))
{
return default(T);
}
else
{
return Activator.CreateInstance<T>();
}
Untested, but the first thing that came to mind. |
Keep in mind that default(string) is null, not string.Empty. You may want a special case in your code:
if (typeof(T) == typeof(String)) return String.Empty; |
The following blog post gives quite a few good ideas for instrumenting a WPF application:
[Techniques for UI Auditing on WPF apps][1].
[1]: http://blog.pixelingene.com/?p=257 |
You can compare the names with the [Levenshtein distance][1]. If the names are the same, the distance is 0, else it is given by the minimum number of operations needed to transform one string into the other.
[1]: http://en.wikipedia.org/wiki/Levenshtein_distance |
This may or may not be related but, minor misspellings might be detected by a [Soundex search][1], e.g., this will allow you to consider Britney Spears, Britanny Spares, and Britny Spears as duplicates.
Nickname contractions, however, are difficult to consider as duplicates and I doubt if it is wise. There are bound to be multiple people named Bill Smith and William Smith, and you would have to iterate that with Charles->Chuck, Robert->Bob, etc.
Also, if you are considering, say, Muslim users, the problems become more difficult (there are too many Muslims, for example, that are named Mohammed/Mohammad).
[1]: http://en.wikipedia.org/wiki/Soundex |
I imagine that this problem is well understood but what occurs to me on first reading is:
- compare fields individually
- count those that match (for a possibly loose definition of match)
- present for human intervention any cases which pass some threshold
Use you existing database to get a good first guess for the threshold, and correct as you accumulate experience.
You may prefer a fairly strong bias toward false positives, at least at first.
|
I imagine that this problem is well understood but what occurs to me on first reading is:
- compare fields individually
- count those that match (for a possibly loose definition of match, and possibly weighing the fields differently)
- present for human intervention any cases which pass some threshold
Use your existing database to get a good first guess for the threshold, and correct as you accumulate experience.
You may prefer a fairly strong bias toward false positives, at least at first.
|
Yeah, that's right. If your employee table has 10,000 records, and only 5 records have employeetypeID in (1,2,3), then it will most likely use the index to fetch the records. However, if it finds that 9,000 records have the employeeIDType in (1,2,3), then it would most likely just do a table scan to get the corresponding EmployeeIDs, as it's faster just to run through the whole table than to go to each branch of the index tree and look at the records individually.
SQL Server does a lot of stuff to try and optimize how the queries run. However, sometimes it doesn't get the right answer. If you know that SQL Server isn't using the index, by looking at the execution plan in query analyzer, you can tell the query engine to use a specific index with the following change to your query.
Select EmployeeId From Employee WITH (Index(Index_EmployeeTypeId )) Where EmployeeTypeId IN (1,2,3)
Assuming the index you have on the EmployeeTypeId field is named Index_EmployeeTypeId. |
How do I tell Maven to use the latest version of a dependency? |
|java|maven-2|dependencies| |
In Maven, dependencies are usually set up like this:
<pre>
<dependency>
<groupId>wonderful-inc</groupId>
<artifactId>dream-library</artifactId>
<version>1.2.3</version>
</dependency>
</pre>
Now, if you are working with libraries that have frequent releases, constantly updating the <code><version> tag can be somewhat annoying. Is there any way to tell Maven to always use the latest available version (from the repository)? |
Is there a way to include a fragment identifier when using Asp.Net MVC ActionLink, RedirectToAction, etc. ? |
|aspnetmvc| |
I want some links to include a fragment identifier. Like some of the URLs on this site:
http://stackoverflow.com/questions/5619/ie6-ssl-ajax-post-form-404-error**#5626**
Is there a way to do this with any of the builtin methods in MVC? Or would I have to roll my own HTML helpers?
Thanks |
|aspnetmvc|asp.netmvc| |
|asp.net|mvc| |
|asp.net|asp.net-mvc|mvc| |
We're looking at including support for this in our next release. |
You may have come across [this posting][1], but it appears that a flash security update changed the behaviour of the crossdomain.xml, requiring you to specify a security policy to allow arbitrary headers to be sent from a remote domain. The Adobe knowledge base article (also referenced in the original post) is [here][2].
[1]: http://willperone.net/Code/as3error.php
[2]: http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403185&sliceId=2 |
**C++**
- [Thinking in C++][2] by Bruce Eckel
- [C++ Coding Standards][1] by Herb Sutter & Andrei Alexandrescu
The first one is good for beginners and the second one requires more advanced level in C++.
[1]: http://www.amazon.com/Coding-Standards-Guidelines-Practices-Depth/dp/0321113586
[2]: http://mindview.net/Books/TICPP/ThinkingInCPP2e.html |
yeah, like adam was saying. There's 3 options: MSIL (default), x64, and x86. You can target x64 and it will generate dll's specifically for 64-bit systems, or you can do x86 which will run on 32-bit and 64-bit, but will have the same restrictions as 32-bit on a 64-bit system.
MSIL will basically let the JITer issue the platform specific instruction (at a slight performance penalty compared to a native image) |
yeah, like adam was saying. There's 3 options: MSIL (default), x64, and x86. You can target x64 and it will generate dll's specifically for 64-bit systems, or you can do x86 which will run on 32-bit and 64-bit, but will have the same restrictions as 32-bit on a 64-bit system.
MSIL will basically let the JITer issue the platform specific instruction (at a slight performance penalty compared to a native image)
**EDIT**: no language, so i'm talking about .net framework languages like vb.net and c#, c++ is a completely different animal. |
<a href="http://stackoverflow.com/questions/50618/what-is-the-point-of-the-finally-block#50624">@Ed</a>, you might be thinking of something like a <code>catch(...)</code> that catches a non-specified exception in C++.
But <code>finally</code> is code that will get executed no matter what happens in the <code>catch</code> blocks.
Microsoft has a help page on <a href="http://msdn.microsoft.com/en-us/library/zwc8s4fz.aspx">try-finally for C#</a> |
Are you using InDesign or InDesign Server? How many pages is your document (or what other information can you tell us about your document/ID setup)?
I do a lot of InDesign Server development. You could be seeing slow-downs for a couple of reasons that aren't necessarily code related.
Right now, I'm generating 100-300 page documents almost completely from script/xml in about 100 seconds (you may be doing something much larger). |
Global/session scoped values in PHP |
|php|memcached|apc| |
Is there a standard way of dealing with globally scoped variables in PHP? Session scoped? From the research I've done, it looks like the options are mostly addons or external. APC might work, but would be limited to a single PHP instance and not so useful for a farm of servers. Memcached seems like it would work, but I was hoping to find something within PHP. Does its stateless approach keep there from being a standard method for handling this?
--Tim |
When converting from signed to unsigned there are two possibilities. Numbers that were originally positive remain (or are interpreted as) the same value. Number that were originally negative will now be interpreted as larger positive numbers.
|
You could try [SWFUpload][1] as well - it would fit in your Flash Uploader "category".
[1]: http://www.swfupload.org/ |
Depends on the language as there might be some slight semantic differences, but the idea is that it will execute (almost) always, regardless of the code in the try block threw an exception or not.
In the second example if the code in the catch block returns or quits, the x = 3 will not be executed. |
Depends on the language as there might be some slight semantic differences, but the idea is that it will execute (almost) always, even if the code in the try block threw an exception.
In the second example, if the code in the catch block returns or quits, the x = 3 will not be executed. In the first it will.
In the .NET platform, in some cases the execution of the finally block won't occur:
Security Exceptions, Thread suspensions, Computer shut down :), etc. |
You can do session variables with [$_SESSION][2].
[1]: http://www.php.net/session_register
[2]: http://www.php.net/manual/en/reserved.variables.session.php |
Wordpress Category Template Question |
|wordpress|templates| |
I am looking at using a custom template for a set of categories. Is it possible to use a category template (like category-4.php) on a parent category and have the children use that template as well? |
You're probably best off using the VMWare Tools .rpm file instead of the install script on Ubuntu. Alien is a program that will [let you turn a .rpm into a Ubuntu-friendly .deb package][1].
[1]: http://ubuntu.wordpress.com/2005/09/23/installing-using-an-rpm-file/ |
If you have access SSIS check out the Fuzzy grouping and Fuzzy lookup transformation.
http://www.sqlteam.com/article/using-fuzzy-lookup-transformations-in-sql-server-integration-services
http://msdn.microsoft.com/en-us/library/ms137786.aspx
|
WPF is pretty stable as far as changes go. Silverlight is still in flux. Though you may watch out since silverlight brought the concept of the state manager(instead of implementing triggers) which may get adopted in wpf...
If that happens there will be multiple ways to defining control templates and behavior...
and that will be a headache. |
You can use the [TypeCode][1] enumeration. Call the GetTypeCode method on classes that implement the IConvertible interface to obtain the type code for an instance of that class. IConvertible is implemented by Boolean, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, Decimal, DateTime, Char, and String, so you can check for primitive types using this. More info on "[Generic Type Checking][2]".
[1]: http://msdn.microsoft.com/en-us/library/system.typecode.aspx
[2]: http://stackoverflow.com/questions/8941/generic-type-checking#8956 |
I've heard a lot of good things about VirtualBox from Sun. If you get fed up with VMWare, it's worth a look. |
NUnit is the way to go for you. |
Take a look at http://selenium.openqa.org/ it offers a good automated way to build unit tests hooking into the browser. there is a nice firefox plugin for recording tests and can utilize almost any unit testing framework. We had a presentation/demo at our local user group meeting last month and it looked awesome. |
More than sending bad data, I think I got an ERROR403. If I just try again it's usually ok.
And I agree : I saw a lot of report about people talking about amazon being totally down, but nobody talking about a "sometimes my access is refused" error, so I guess there might be an error on my side. I just set up the log on amazon. |
More than sending bad data, I think I got an ERROR403. If I just try again it's usually ok.
And I agree : I saw a lot of report about people talking about amazon being totally down, but nobody talking about a "sometimes my access is refused" error, so I guess there might be an error on my side. I just set up the log on amazon.
Anyway thank you! I'll follow your advise and stop blaming "the other guy". |
If you're interested in seeing how the Delegate pattern is used in real-world code, look no further than Cocoa on Mac OS X. Cocoa is Apple's preferred UI toolkit for programming under Mac OS X, and is coded in Objective C. It's designed so that each UI component is intended to be extended via delegation rather than subclassing or other means.
For more information, I recommend checking out what Apple has to say about delegates [here][1].
[1]: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html |
> could you clarify a little bit more how it was for you, what you had to change. Maybe you could point me in the right direction by providing some links to the information you used.
My first source were actually the tools' `man` pages. Just type
$ man toolname
on the command line (`$` here is part of the prompt, not the input).
Depending on the platform, they're quite well-written and can also be found on the internet. In the case of `make`, I actually read the complete [documentation](http://www.gnu.org/software/make/manual/make.html) which took a few hours. Actually, I don't think this is necessary or helpful in most cases but I had a few special requirements in my first assignments under Linux that required a sophisticated makefile. After writing the makefile I gave it to an experienced colleague who did some minor tweaks and corrections. After that, I pretty much knew `make`.
I used GVIM because I had some (but not much) prior experience there, I can't say anything at all about Emacs or alternatives. I find it really helps to read other peoples' `.gvimrc` config file. Many people put it on the web. Here's [mine](http://page.mi.fu-berlin.de/krudolph/stuff/gvimrc.html).
Don't try to master all binutils at once, there are too many functions. But get a general overview so you'll know where to search when needing something in the future. You *should*, however, know all the important parameters for `g++` and `ld` (the GCC linker tool that's invoked automatically except when explicitly prevented).
> Also I'm curious, do you have code completion and syntax highlighting when you code?
Syntax highlighting: yes, and a much better one than Visual Studio. Code completion: yes-*ish*. First, I have to admit that I didn't use C++ code completion even in Visual Studio because (compared to VB and C#) it wasn't good enough. I don't use it often now but nevertheless, GVIM *has* native code completion support for C++. Combined with the [ctags](http://ctags.sourceforge.net/) library and a plug-in like [taglist](http://vim-taglist.sourceforge.net/) this is almost an IDE.
Actually, what got me started was an [article](http://lucumr.pocoo.org/articles/vim-as-development-environment) by Armin Ronacher. Before reading the text, look at the screenshots at the end of it!
> do you have to compile first before getting (syntax) errors?
Yes. But this is the same for Visual Studio, isn't it (I've never used Whole Tomato)? Of course, the syntax highlighting will show you non-matching brackets but that's about all.
> and how do you debug (again think breakpoints etc)?
I use `gdb` which is a command-line tool. There's also a graphical frontend called `DDD`. `gdb` is a modern debugging tool and can do everything you can do in an IDE. The only thing that really annoys me is reading a stack trace because lines aren't indented or formatted so it's really hard to scan the information when you're using a lot of templates (which I do). But those also clutter the stack trace in IDEs.
> Like I said, I had the 'pleasure' to set my first steps in the Java programming language using windows notepad and the command line java compiler in high school, and it was, .. wel a nightmare! certainly when I could compare it with other programming courses I had back then where we had decent IDE's
You shouldn't even try to compare a modern, full-feature editor like Emacs or GVIM to Notepad. Notepad is an embellished `TextBox` control, and this really makes all the difference. Additionally, working on the command line is a very different experience in Linux and Windows. The Windows `cmd.exe` is severely crippled. PowerShell is much better.
/EDIT: I should mention explicitly that **GVIM has tabbed editing** (as in tabbed browsing, not tabs-vs-spaces)! It took me ages to find them although they're not hidden at all. Just type `:tabe` instead of plain `:e` when opening a file or creating a new one, and GVIM will create a new tab. Switching between tabs can be done using the cursor or several different shortcuts (depending on the platform). The key `gt` (type `g`, then `t` in command mode) should work everywhere, and jumps to the next tab, or tab no. *n* if a number was given. Type `:help gt` to get more help. |
As an old-time UNIX guy, I always use Emacs. But that has a pretty steep and long learning curve, so I'm not sure I can recommend it to newcomers.
There really isn't a "good" IDE for Linux. Eclipse is not very good for C/C++. The others are missing all the features you are going to be looking for.
It really is important to learn how all the individual tools (gcc, make, gdb, etc.) work. But after you do so, you may start to find Visual Studio to be very limiting. |
**lint** is constantly updated... so why would you want a more recent one.
BTW flexelint **is** lint |
Just tossing out a second recommendation for Working Effectively with Legacy Code, an excellent book that really opened my eyes to the fact that almost any old / crappy / untestable code can be wrangled! |
I like to write unit tests that use one of the builtin serializers on the original and the cloned object and then check the serialized representations for equality (for a binary formatter, I can just compare the byte arrays). This works great in cases where the object is still serializable, and I'm only changing to a custom deep clone for perf reasons.
Furthermore, I like to add a debug mode check to all of my Clone implementations using something like this
[Conditional("DEBUG")]
public static void DebugAssertValueEquality<T>(T current, T other, bool expected,
params string[] ignoredFields) {
if (null == current)
{ throw new ArgumentNullException("current"); }
if (null == ignoredFields)
{ ignoredFields = new string[] { }; }
FieldInfo lastField = null;
bool test;
if (object.ReferenceEquals(other, null))
{ Debug.Assert(false == expected, "The other object was null"); return; }
test = true;
foreach (FieldInfo fi in current.GetType().GetFields(BindingFlags.Instance)) {
if (test = false) { break; }
if (0 <= Array.IndexOf<string>(ignoredFields, fi.Name))
{ continue; }
lastField = fi;
object leftValue = fi.GetValue(current);
object rightValue = fi.GetValue(other);
if (object.ReferenceEquals(null, leftValue)) {
if (!object.ReferenceEquals(null, rightValue))
{ test = false; }
}
else if (object.ReferenceEquals(null, rightValue))
{ test = false; }
else {
if (!leftValue.Equals(rightValue))
{ test = false; }
}
}
Debug.Assert(test == expected, string.Format("field: {0}", lastField));
}
This method relies on an accurate implementation of Equals on any nested members, but in my case anything that is cloneable is also equatable |
Jay Fields and Obie Fernandez have written and talked extensively on the subject.
- Jay Fields intro on [Domain Specific Languages][1]
- Jay Fields' series on [Business Natural Language][2]
- Obie Fernandez [Expressing Contract Terms in a DSL][3]
- A very good [presentation][4] on infoQ by Jay Fields
You'll also find general stuff on implementing DSL in Martin Fowler's writings (but not specific to finance).
- [DSL][5]
[1]: http://blog.jayfields.com/2008/02/designing-domain-specific-language.html
[2]: http://bnl.jayfields.com/01_introduction.html
[3]: http://www.jroller.com/obie/entry/expressing_contract_terms_in_a
[4]: http://www.infoq.com/presentations/fields-business-natural-languages-ruby
[5]: http://martinfowler.com/dslwip/ |
As mentioned, Quartz is one standard solution. If you don't care about clustering or persistence of background tasks across restarts, you can use the built in ThreadPool support (in Java 5,6). If you use a [ScheduledExecutorService][1] you can put Runnables into the background thread pool that wait a specific amount of time before executing.
If you do care about clustering and/or persistence, you can use JMS queues for asynchronous execution, though you will still need some way of delaying background tasks (you can use Quartz or the ScheduledExecutorService to do this).
[1]: http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html "Scheduled Executor Service" |
Oracle has a set of tools that integrates with Visual Studio. It's packaged with their data access libraries.
http://www.oracle.com/technology/software/tech/windows/odpnet/index.html |
Donald Knuth said that even better then reusable code is modifiable code, so if there is no API, you should seek for an open source app that is written well and therefore possible to customize.
As for databases and login systems and other programming parts (i don't see how e.g. theming could benefit), you can also try, depending on circumstances wrapping stuff so that module believes it's on it's own, but actually talks to your code. |
Cannot handle FaultException |
|c#|exception|wcf| |
i have a wcf service that does an operation. and in this operation there could be a fault. i have stated that there could be a fault in my service contract.
here is the code below;
public void Foo()
{
try
{
DoSomething(); // throws FaultException<FooFault>
}
catch (FaultException)
{
throw;
}
catch (Exception ex)
{
myProject.Exception.Throw<FooFault>(ex);
}
}
in service contract;
[FaultException(typeof(FooFault))]
void Foo();
when a FaultException<FooFault> was thrown by DoSomething() method while i was running the application, firstly the exception was caught at "catch(Exception ex)" line and breaks in there. then when i pressed f5 again, it does what normally it has to. i wonder why that break exists? and if not could it be problem on publish? |
If marketability is a concern, then C++/CLI with WinForms and WPF which really translates to "just learn WinForms and WPF, regardless of what specific language you use".
CodeProject has [a ton of WinForms/WPF samples/tutorials](http://www.codeproject.com/info/search.aspx?artkw=Winforms+OR+WPF) to get you started. |
I think your interpretation is correct - You would not be allowed to download and execute JavaScript code in v8.
If there were some way to run the code in an interpreter already on the iPhone (i.e. the javascript engine in MobileSafari) then that would be permitted I think. |
[The Fox GUI Toolkit][1]
Really decent tried-and-true toolkit with a very nice event system. I've used the Ruby port, and my Windows apps had a very native look and feel.
[1]: http://fox-toolkit.org |
To use views or not to use views. |
|php|model-view-controller| |
I seem right now to be embroiled in a debate with another programmer on this project who thinks that views have no merits. He proposes a system that PHP looks something like this:
$draw = new Draw;
$nav = $draw->wideHeaderBox().
$draw->left().
$draw->image().
Image::get($image,60,array('id'=>'header_image')).
$draw->imageEnd().
$draw->leftEnd().
$draw->left(10).
'<div id="header_text">'.
self::defaultSectionText().
'</div>'.
$draw->leftEnd().
and so on (this is in the controller btw). Now his arguments for this actually make some sense, he claims that if there is a redesign all we need to do is change the HTML in one place and it changes everywhere automatically. For some reason however, this method still rubs me the wrong way, is there any merit to views over this method? I mean besides not having to retype HTML by hand. |
The argument he uses is the argument you need to *have* views. Both result in only changing it in one place. However, in his version, you are mixing view markup with business code.
I would suggest using more of a templated design. Do all your business logic in the PHP, setup all variables that are needed by your page. Then just have your page markup reference those variables (and deal with no business logic whatsoever).
Have you looked at smarty? http://smarty.php.net
|
Ok, so just for fun, you could do this! (assuming you're swapping string values)
mysql> select * from swapper;
+------+------+
| foo | bar |
+------+------+
| 6 | 1 |
| 5 | 2 |
| 4 | 3 |
+------+------+
3 rows in set (0.00 sec)
mysql> update swapper set
-> foo = concat(foo, "###", bar),
-> bar = replace(foo, concat("###", bar), ""),
-> foo = replace(foo, concat(bar, "###"), "");
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> select * from swapper;
+------+------+
| foo | bar |
+------+------+
| 1 | 6 |
| 2 | 5 |
| 3 | 4 |
+------+------+
3 rows in set (0.00 sec)
A nice bit of fun abusing the left-to-right evaluation process in MySQL.
Alternatively, just use XOR if they're numbers. You mentioned coordinates, so do you have lovely integer values, or complex strings?
Edit: The XOR stuff works like this by the way:
update swapper set foo = foo ^ bar, bar = foo ^ bar, foo = foo ^ bar; |
See [XML data binding][1].
Use Visual Studio or [xsd.exe][2] to generate DataSet or classes from XSD, then use [`System.Xml.Serialization.XmlSerializer`][3] if needed to turn your XML into objects/DataSet. Massage the objects. Display them in grid.
[1]: http://en.wikipedia.org/wiki/XML%5FData%5FBinding
[2]: http://msdn.microsoft.com/en-us/library/x6c1kb0s%28VS.71%29.aspx
[3]: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx |
SQL query to get the top "n" scores out of a list |
|sql-server|puzzle| |
I'd like to find the different ways to solve a real life problem I had: imagine to have a contest, or a game, during which the users collect points. You have to build a query to show the list of users with the best "n" scores.
I'm making an example to clarify. Let's say that this is the Users table, with the points earned:
UserId - Points
1 - 100
2 - 75
3 - 50
4 - 50
5 - 50
6 - 25
If I want the top 3 scores, the result will be:
UserId - Points
1 - 100
2 - 75
3 - 50
4 - 50
5 - 50
This can be realized in a view or a stored procedure, as you want. My target db is Sql Server. Actually I solved this, but I think there are different way to obtain the result... faster or more efficent than mine.
|
Actually, you should probably use some sort of HTML parser where you can inspect each node (and therefore node attributes) in the DOM of the page. I've not used any of these for a while so I don't know the pros and cons but here's a list http://java-source.net/open-source/html-parsers |
The answer is: **don't use regular expressions**.
Seriously. Use a SGML parser, or an XML parser if you happen to know it's valid XML (probably almost never true). You will absolutely screw up and waste tons of time trying to get it right. Just use what's already available. |
In each project's properties under the build section you can set different custom constants for each solution configuration. This is where you define custom pre-compiler directives. |
I'm not sure it will work well for the names vs nicknames problem, but the most common algorithm in this sort of area would be the [edit distance / Levenshtein distance][1] algorithm. It's basically a count of the number of character changes, additions and removals required to turn one item into another.
For names, I'm not sure you're ever going to get good results with a purely algorithmic approach - What you really need is masses of data. Take, for example, how much better Google spelling suggestions are than those in a normal desktop application. This is because Google can process billions of web queries and look at what queries lead to each other, what 'did you mean' links actually get clicked etc.
There are a few companies which specialise in the name matching problem (mostly for national security and fraud applications). The one I could remember, Search Software America seems to have been bought out by these guys [http://www.informatica.com/products_services/identity_resolution/Pages/index.aspx][2], but I suspect any of these sorts of solutions would be far to expensive for a contacts application.
[1]: http://en.wikipedia.org/wiki/Levenshtein_distance
[2]: http://www.informatica.com/products_services/identity_resolution/Pages/index.aspx |
WPF set ItemTemplate dynamically |
|wpf| |
Using WPF, I have a TreeView control that I want to set it's ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere.
myTreeViewControl.ItemTemplate = ?? |
How do I set ItemTemplate dynamically in WPF? |
Using WPF, I have a TreeView control that I want to set its ItemTemplate dynamically through procedural code. How do I do this? I assume I need to find the resource somewhere.
myTreeViewControl.ItemTemplate = ?? |
One common use of delegates for generic Lists are via Action delegates (or its anonymous equivalent) to create a one-line foreach operation:
myList.Foreach( i => i.DoSomething());
I also find the Predicate delegate quite useful in searching or pruning a List:
myList.FindAll( i => i.Name == "Bob");
myList.RemoveAll( i => i.Name == "Bob");
I know you said no code required, but I find it easier to express its usefulness via code. :) |
|browsers|firefox|internet-explorer| |
|firefox|internet-explorer|printing|browsers| |
|firefox|internet-explorer|printing|browser| |
This might be what you are looking for?
From [Groovy in Action](http://www.amazon.com/Groovy-Action-Dierk-Koenig/dp/1932394842)
def binding = new Binding(x: 6, y: 4)
def shell = new GroovyShell(binding)
def expression = '''f = x * y'''
shell.evaluate(expression)
assert binding.getVariable("f") == 24
An appropriate use of Binding will allow you to maintain state? |
It is quite possible, if I understand what you're getting at.
You have a PHP server with your domain pointing to it. You also have a separate ASP.NET server that only has an IP address associated with it, no domain.
Is there any drawback to simply pointing your domain name to your ASP.NEt box?
|
Is there a list of browser conditionals for use including stylesheets? |
|css|browser|conditional-statements| |
I've seen people doing things like this in their HTML:
<!--[if IE]>
<link rel="stylesheet" href="ie.css" type="text/css" />
<![endif]-->
Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement?
**Edit**
Thanks [Ross](http://stackoverflow.com/questions/46124/is-there-a-list-of-browser-conditionals-for-use-including-stylesheets#46126). Interesting to find out about **gt, lt, gte, & lte**. |
Can XPath match on parts of an element's name? |
|xpath| |
I want to do this: //*fu, which returns all nodes whose name ends in fu, such as <tarfu /> and <snafu />, but not <fubar /> |
This works across all browsers because anything except IE sees `<!--IGNORED COMMENT-->`. Only IE reads the comment if it contains a conditional clause. Have a look at [this article][1]
You can also specify which version of IE. For example:
<!--[if IE 8]>
<link rel="stylesheet type="text/css" href="ie8.css" />
<![endif]-->
[1]: http://www.quirksmode.org/css/condcom.html |
In some circumstances, dynamically created sql in code can have better performance than a stored proc. If you have created a stored proc (let's say sp_customersearch) that gets extremely complicated with dozens of parameters because it must be very flexible, you can probably generate a much simpler sql statement in code at runtime.
One could argue that this simply moves some processing from SQL to the web server, but in general that would be a good thing.
The other great thing about this technique is that if you're looking in SQL profiler you can see the query you generated and debug it much easier than seeing a stored proc call with 20 parameters come in. |
With TortoiseSVN I just move the file on disk.
When I come to commit my changes I select the missing file and the new one and select "Repair move" from the right click menu.
This means I can let my IDE move round files and use it refactoring tools without losing history. |
The main reason that I'm aware of is that set-based operations can be optimised by the engine by running them across multiple threads. For example, think of a quicksort - you can separate the list you're sorting into multiple "chunks" and sort each separately in their own thread. SQL engines can do similar things with huge amounts of data in one set-based query.
When you perform cursor-based operations, the engine can only run sequentially and the operation has to be single threaded. |
The class that you have is not a real class in OO terms - its just been contructed to take the space of the instance variables.
That said - there propably isnt much issue with speed - its just a style thing in your example.
The intresting bit - is if you contsrtucted the object to be a real "person" class - and thinkng about the other attributes and actions that you may want of the person class - then you would notice not only a style performance - writting code - but also speed performance.
|
I hear Anjuta is pretty slick for Gnome users. I played a bit with KDevelop and it's nice, but sort of lacking featurewise. Code::Blocks is also very promising, and I like that one best. |
@[ESRogs](#24169):
`std::map` lookup is *O*(log *n*) which makes it slow here. Better use a vector.
vector<unsigned int> fib_cache;
fib_cache.push_back(1);
fib_cache.push_back(1);
unsigned int fib(unsigned int n) {
if (fib_cache.size() <= n)
fib_cache.push_back(fib(n - 1) + fib(n - 2));
return fib_cache[n];
} |
The idea behind preferring to do the work in queries is that the database engine can optimize by reformulating it. That's also why you'd want to run EXPLAIN on your query, to see what the db is *actually* doing. (e.g. taking advantage of indices, table sizes and sometimes even knowledge about the distributions of values in columns.)
That said, to get good performance in your actual concrete case, you may have to bend or break rules.
Oh, another reason might be constraints: Incrementing a unique column by one might be okay if constraints are checked after *all* the updates, but generates a collision if done one-by-one. |
How does Hive compare to HBase? |