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 ... |
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... |
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 firs... |
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
... |
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 correspon... |
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 releas... |
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... |
**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://m... |
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 ... |
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 ... |
<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</... |
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... |
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... |
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 t... |
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...
... |
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, an... |
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... |
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... |
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 s... |
> 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 ... |
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... |
**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 ... |
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
Y... |
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 o... |
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 ... |
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>
... |
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('i... |
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 pag... |
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> upda... |
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]: ht... |
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... |
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, ... |
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");
... |
|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(... |
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:/... |
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.cs... |
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 cod... |
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 ... |
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 t... |
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... |
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 value... |
How does Hive compare to HBase? |