instruction
stringlengths
0
30k
I would have a look at the Parallel extensions to the .net framework. It is still in ctp, however it supposed to make the best use of multi core processors. The easiest place to get started for .net is on the [parallel teams blog][1] As for java i have no idea. [1]: http://blogs.msdn.com/pfxteam/
How popular is WPF as a technology?
|wpf|
I had a discussion with some colleagues mentioning that there are not too many projects that we do which make use of WPF for creating UI for a windows application (we almost always use Windows Forms instead). * Are your experiences the same - i.e. there is not too much adoption of this technology? * Why do you think that is? And will we have a time when we see much more of WPF?
|wpf|
Gitty is under development right now, basically I am working on it and it is in turn working off of BazaarX which is under heavy restructuring right now. Gitty will essentially be BazzarX with the Bazaar backend ripped out and a GIT backend put in instead and any UI tweaks made for GIT Differences from Bazaar (ie hashes instead of version#'s,etc. The good news is that as developers on BazaarX we have got our act together and have our respective assignments for what area of BazaarX to work on and BazaarX is being designed to be VCS agnostic which will make my job of integrating GIT Into it much easier. We also have a bunch more people working on BazaarX now which makes my job of working on Gitty easier. Currently Gitty is the only native/Cocoa app for this that i am aware of. I can't say when i'll be done and hit 1.0 but I am happy with the direction I am going on in Gitty and BazaarX.
Try this: var matches = dict.Values.Where(rec => rec.Name == "foo").ToList(); Be aware that that will essentially be creating a new list from the original Values collection, and so any changes to your dictionary won't automatically be reflected in your bound control.
How can I convert IEnumerable<T> to List<T> in C#?
|listview|linq|c#|
I am using LINQ to query a generic dictionary and then use the result as the datasource for my ListView (WebForms). Simplified code: Dictionary<Guid, Record> dict = GetAllRecords(); myListView.DataSource = dict.Values.Where(rec => rec.Name == "foo"); myListView.DataBind(); I thought that would work but in fact it throws a **System.InvalidOperationException**: > ListView with id 'myListView' must > have a data source that either > implements ICollection or can perform > data source paging if AllowPaging is > true. In order to get it working I have had to resort to the following: Dictionary<Guid, Record> dict = GetAllRecords(); List<Record> searchResults = new List<Record>(); var matches = dict.Values.Where(rec => rec.Name == "foo"); foreach (Record rec in matches) searchResults.Add(rec); myListView.DataSource = searchResults; myListView.DataBind(); Is there a small gotcha in the first example to make it work? (Wasn't sure what to use as the question title for this one, feel free to edit to something more appropriate)
|c#|linq|generics|listview|
How to plot a long path with Virtual Earth
|javascript|virtual-earth|
The obvious way to plot a path with virtual earth (VEMap.GetDirections) is limited to 25 points. When trying to plot a vehicle's journey this is extremely limiting. How can I plot a by-road journey of more than 25 points on a virtual earth map?
You might also try: var matches = new List<Record>(dict.Values.Where(rec => rec.Name == "foo")); Basically generic collections are very difficult to cast directly, so you really have little choice but to create a new object.
Yes - I've got experience with that - unfortunately it was no different from your own. I've generally avoided scrolling forms and used paging wherever possible on .Net CF. If this is an option for you, I'd recommend it. I'd assume the scroll bar issue is to do with the form size being fixed to the width of the available screen (regardless of design-time settings) so the introduction of a vertical scroll bar obscures part of the (not needed) full-width form.
C++ templates are actually much more powerful than their C# and Java counterparts as they are evaluated at compile time and support specialization. This allows for Template Meta-Programming and makes the C++ compiler equivalent to a Turing machine (i.e. during the compilation process you can compute anything that is computable with a Turing machine).
myListView.DataSource = new List<Record>(dict.Values.Where(rec => rec.Name == "foo")); or you could cast it myListView.DataSource = (List<Record>) dict.Values.Where(rec => rec.Name == "foo");
|.net|vb.net|cast|
Use a '*' wildcard in the AssemblyVersion attribute. Documentation is [here][1]. Note that if the application is built from multiple assemblies, the version you care most about is the one for the .exe. [1]: http://msdn.microsoft.com/en-us/library/system.reflection.assemblyversionattribute.aspx
In one of the project files, probably AssemblyInfo.cs, the assembly version attribute is set to `[assembly: AssemblyVersion("3.5.*")]` or something similar. The * basically means it lets Visual Studio automatically set the build and revision number. You can change this to a hard coded value in the format `<major version>.<minor version>.<build number>.<revision>` You are allowed to use any or all of the precision. For instance 3.5 or 3.5.3167 or 3.5.3167.10000. You can also use compiler conditions to change the versioning based on whether you're doing a debug build or release build.
Incidentally, I think that the Turing completeness of templates shows that halting is overrated. Most languages guarantee that their compilers will halt; not so C++. Does this diminish C++ as a language? I don't think so; it has many flaws, but compiles that don't always halt aren't one of them.
<a href="http://msdn.microsoft.com/en-us/library/s2dy91zy%28VS.80%29.aspx">MSDN</a> seems to indicate that the Cxxx casts for specific types can improve performance in VB .NET because they are converted to inline code. For some reason, it also suggests <a href="http://msdn.microsoft.com/en-us/library/7k6y2h6x.aspx">DirectCast</a> as opposed to CType in certain cases (the documentations states it's when there's an inheritance relationship; I believe this means the sanity of the cast is checked at compile time and optimizations can be applied whereas CType always uses the VB runtime.) When I'm writing VB .NET code, what I use depends on what I'm doing. If it's prototype code I'm going to throw away, I use whatever I happen to type. If it's code I'm serious about, I try to use a Cxxx cast. If one doesn't exist, I use DirectCast if I have a reasonable belief that there's an inheritance relationship. If it's a situation where I have no idea if the cast should succeed (user input -> integers, for example), then I use TryCast so as to do something more friendly than toss an exception at the user. One thing I can't shake is I tend to use ToString instead of CStr but supposedly Cstr is faster.
It looks like I just needed to be more specific in my element selector although it is weird that a hard coded number would work. jQuery('#pagination-digg li').eq(currentPage).addClass("active");
How are you doing the cross-platform calls? Is it all called from Java? http://java.sun.com/docs/books/tutorial/i18n/text/string.html might be useful. I'm a bit confused about exactly what you are trying to do. Is the database essentially interface between all the code? Then it should be easy - just make the DB UTF-8 and each of the clients will need to do their own conversions. Sounds like an interesting problem, could you share some more details?
My company recently started using Mojo Helpdesk: www.mojohelpdesk.com. It's a hosted service, not FOSS, but it's pretty cheap and the interface is slick.
|security|command-line|hacks|injection|
How do I specify "the word under the cursor" on VIM's commandline?
|vim|commandline|
I want to write a command that specifies "the word under the cursor" in VIM. For instance, let's say I have the cursor on a word and I make it appear twice. For instance, if the word is "abc" and I want "abcabc" then I could type: :s/\(abc\)/\1\1/ But then I'd like to be able to move the cursor to "def" and use the same command to change it to "defdef": :s/\(def\)/\1\1/ How can I write the command in the commandline so that it does this? :s/\(*whatever is under the commandline*\)/\1\1
|command-line|vim|
All that plus there's the fact that on the Win machine most probably an antivirus software will kick in during the CreateProcess... That's usually the biggest slowdown.
About your first question, the effective maximum size for the *database* is usually determined by operating system, specifically the file size MySQL Server will be able to create, not by MySQL Server itself. Those limits play a big role in *table* size limits. And MyISAM works differently from InnoDB. So any tables will be dependant on those limits. If you use InnoDB you will have more options on manipulating table sizes, resizing the tablespace is an option in this case, so if you plan to resize it, this is the way to go. Give a look at [The table is full][1] error page. I am not sure the real record quantity of each table given all necessary information (OS, Table type, Columns, data type and size of each and etc...) And I am not sure if this info is easy to calculate, but I've seen simple table with around 1bi records in a couple cases and MySQL didn't gave up. [1]: http://dev.mysql.com/doc/refman/5.0/en/full-table.html
It definitely improves your code. Your tentatively formulated claim, that it's obscure and that code would merit from a `catch` block is simply not true in C++ because RAII is an established idiom. Resource handling in C++ *is* done by resource acquisition and garbage collection is done by implicit destructor calls. On the other hand, explicit `catch` blocks would bloat the code and introduce subtle errors because the code flow gets much more complex and resource handling has to be done explicitly. RAII (and especially `ScopeGuard`s) aren't an obscure technique in C++ but firmly established best-practice.
I haven't used this particular template but I've used something similar before. Yes, it does lead to clearer code when compared to equally robust code implemented in different ways.
I would recommend <a href="http://www.ektron.com">Ektron CMS400.net</a> -- it's an excellent CMS with great built-in translation.
You already implicitly have multiple implicit return statements, caused by error handling, so deal with it. As is typical with programming, though, there are examples both for and against the multiple return practice. If it makes the code clearer, do it one way or the other. Use of many control structures can help (the **case** statement, for example).
|build-process|ant|
May be worth checking out this article on [F# "101"](http://www.code-magazine.com/Article.aspx?quickid=0809051) on CoDe Mag recently posted. Also, [Dustin Campbell has a great blog](http://diditwith.net/) where he has posted many articles on his adventures on getting up to speed with F#.. I hope you find these useful :) ###EDIT: Also, just to add, my understanding of functional programming is that _everything_ is a function, or parameters to a function, rather than instances/stateful objects.. But I could be wrong F# is something I am dying to get in to but just dont have the time! :)
Using MSTest with CruseControl.NET
|cruisecontrol.net|buildprocess|msbuild|
We have been using CrusiseControl for quite a while with NUnit and NAnt. For a recent project we decided to use the testing framework that comes with Visual Studio, which so far has been adequate. I'm attempting to get the solution running in Cruise Control. I've finally got the build itself to work; however, I have been unable to get any tests to show up in the CruiseControl interface despite adding custom build tasks and components designed to do just that. Does anyone have a definitive link out there to instructions on getting this set up?
|build-process|msbuild|cruisecontrol.net|
Making a production build of a PHP project with Subversion
|toroisesvn|svn|buildprocess|
If you are working in PHP (or I guess any programming language...) and using subversion as your source control, is there a way to take your project (for example): > C:\Projects\test\\.svn > C:\Projects\test\docs\ > C:\Projects\test\faq.php > C:\Projects\test\guestbook.php > C:\Projects\test\index.php > C:\Projects\test\test.php and build/copy/whatever it so it weeds out certain files and becomes: > C:\Projects\test\faq.php > C:\Projects\test\guestbook.php > C:\Projects\test\index.php automagically? I'm getting tired of making a branch, and then going through the branch and deleting all of the ".svn" folders, the docs directory, and my prototyping files. I know I could probably use a .bat file to only copy the specific files I want, but I was hoping there was some way with subversion to sort of pseudo ignore a file, to where it will still version it, but where you could make a snapshot of the project that ignores the files you told it to psuedo ignore. I know I read online somewhere about some functionality that at least lets you copy without the .svn folders, but I can't find it now...
|svn|tortoisesvn|buildprocess|
|svn|build-process|tortoisesvn|
@Sean > However, factoring out common finctionality into a base class, then reusing that in other descendant classes is a deeply elegant thing, IMHO! But "procedural" developers have been doing that for decades anyway. The syntax and terminology might differ, but the effect is identical. There is more to OOP than "reusing common functionality in a base class", and I might even go so far as to say that that is hard to describe as OOP at all; calling the same function from different bits of code is a technique as old as the subprocedure itself.
How do you prevent leading zeros from being stripped when importing an excel doc using c#
|c#|asp.net|excel|ado.net|
I'm able to connect to and read an excel file no problem. But when importing data such as zipcodes that have leading zeros, how do you prevent excel from guessing the datatype and in the process stripping out leading zeros?
To reduce the risk you can also associate the originating IP with the session. That way an attacker has to be within the same private network to be able to use the session. Checking referer headers can also be an option but those are more easily spoofed.
Prefix with '
Every application has it's own performance profile for using a database, and chances are it will change over time. The best thing you can do is to test your options. Switching between MyISAM and InnoDB is trivial, so load some test data and fire jmeter against your site and see what happens.
This is the idiom I've always used to get a modified copy of a string without changing the original: ($new = $original) =~ s/foo/bar/;
Prefixing the contents of the cell with ' forces Excel to see it as text instead of a number. The ' won't be displayed in Excel.
Hmm, none that I know of. You can always retrieve the definitions as SQL and then run a diff tool on them, but it's a bit of a pain in the rear. Probably the best solution for this is using some kind of "Migrations" tool, so you can keep your database definitions together with your code, and version them, etc.
I think the way to do this would be to format the source excel file such that the column is formatted as Text instead of General. Select the entire column and right click and select format cells, select text from the list of options. I think that would explicitly define that the column content is text and should be treated as such. Let me know if that works.
What is the best way to communicate with a SQL server?
|c++|sql|database|c|mysql|
I am going to be using c/c++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one?
@Thomas Owens: (re source control) Yes, but that's not source control in the same sense that I can check in a .cs file (or .cpp file or whatever) and go and pick out any revision I want. To do that with database code requires a potentially-significant amount of effort to either retrieve the procedure from the database and transfer it to somewhere in the source tree, or to do a database backup every time a minor change is made. In either case (and regardless of the amount of effort), it's not intuitive; and for many shops, it's not a good enough solution either. There is also the potential here for developers who may not be as studious at that as others to forget to retrieve and check in a revision. It's technically possible to put ANYTHING in source control; the disconnect here is what I would take issue with. (re debuggable) Fair enough, though that doesn't provide much integration with the rest of the application (where the majority of the code could live). That may or may not be important.
myListView.DataSource = (List<Record>) dict.Values.Where(rec => rec.Name == "foo");
Not an expert with this stuff but it looks like the first 3 parts of the address are being masked out. Is it possible that the mobile device is being given a network mask of: 255.255.255.0 As to reach beyond the range of the first 3 parts you need the mask to be: 255.255.0.0 This may be an oversimplification or completely wrong but that's was my gut response to the question.
For linux: $ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'open.*tnsnames.ora' shows something like this: open("/opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora", O_RDONLY) = 7 Changing to $ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'tnsnames.ora' will show all the file paths that are failing.
For linux: $ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'open.*tnsnames.ora' shows something like this: open("/opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora",O_RDONLY)=7 Changing to $ strace sqlplus -L scott/tiger@orcl 2>&1| grep -i 'tnsnames.ora' will show all the file paths that are failing.
`disable-output-escaping` isn't evil in itself, but there are only few cases where you should use it and this isn't one of them. In XSLT you work with trees, not markup string. Here's an XSTL 1.0 solution: <xsl:template match="/STORIES/STORY"> <component> <xsl:if test="ARTICLEBODY"> <xsl:call-template name="wrap-text"> <xsl:with-param name="text" select="ARTICLEBODY"/> <xsl:with-param name="delimiter" select="'&#10;'"/> <xsl:with-param name="element" select="'p'"/> </xsl:call-template> </xsl:if> </component> </xsl:template> <xsl:template name="wrap-text"> <xsl:param name="text"/> <xsl:param name="delimiter"/> <xsl:param name="element"/> <xsl:choose> <xsl:when test="contains($text, $delimiter)"> <xsl:variable name="t" select="substring-before($text, $delimiter)"/> <xsl:if test="normalize-space($t)"> <xsl:element name="{$element}"> <xsl:value-of select="$t"/> </xsl:element> </xsl:if> <xsl:call-template name="wrap-text"> <xsl:with-param name="text" select="substring-after($text, $delimiter)"/> <xsl:with-param name="delimiter" select="$delimiter"/> <xsl:with-param name="element" select="$element"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:if test="normalize-space($text)"> <xsl:element name="{$element}"> <xsl:value-of select="$text"/> </xsl:element> </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:template>
The ViewData.Eval("DisplayMessage") method should work for you.
I believe a good way to do this is to [render the HTML to an image](http://weblogs.mozillazine.org/roc/archives/2005/05/rendering_web_p.html) and then use some [diff tool that can compare images](http://www.scootersoftware.com/) to spot the differences.
Neep Alt 13/17 is very good.
[RT - Request Tracker][1] handles inbound mail. I'm working to add inbound mail support to [TicketDesk][2], but that might be a little while before that makes it into a release. [1]: http://bestpractical.com/rt/ [2]: http://codeplex.com/ticketdesk
I don't know how hard people think it is, so I can't say if it is easier. However, you are right in your observation that undecidability of a problem (in general) does not mean that all instances of that problem are undecidable. For instance, I can easily tell you that a program like `while false do something` terminates (assuming the obvious semantics of the while and false). Projects like the Terminator project you mentioned obviously exist (and probably even work in some cases), so it is clear that not all is hopeless. There is also a contest (I believe every year) for tools that try to prove termination for rewrite systems, which are basically a model of computation. But it is the case that termination in many cases is very hard to prove. The easiest way to look at it is perhaps to see the undecidability as a maximum on the complexity of instantiations of a problem. Each instantiation is somewhere on the scale of trivial to this maximum and with a higher maximum you typically have that the instantiations are harder on average as well.
Styling Html Helpers MVC.Net
|css|asp.net-mvc|html-helper|
If i have a html helper like so: Name:<br /> <%=Html.TextBox("txtName",20) %><br /> How do i apply a css class to it? Do i have to wrap it in a span? Or do i need to somehow utilize the HtmlAttributes property of the helper?
We use FogBugz...er, "fooogzeeebugzo"...and while it may be a bit expensive for your needs, it works very well.
You can try and cut stuff out with vLite, but unless you cut out a real lot it's not going to save a ton of drive space. Here's your best bets: - Disable Hibernate and run disk cleanup to remove any hibernation file. - Disable System restore entirely and use disk cleanup to remove all restore points... this will save an enormous amount of space. - Disable SuperFetch (since it kills your VM hard drive with it's crazy usage) - Minimize the size of your pagefile by setting a smaller static size and make sure to assign lots of memory to your VM to compensate. - Use the disk utilities to shrink your VM drive down as far as possible. Once you have the base machine configured, I would suggest using VMware workstation and the awesome Linked Clones feature, which will let you create a completely new VM based on the base machine, but only using a portion of the space. I would not advise running a Vista VM from a USB flash drive, it will be slower than dirt.
I also faced the same problem, and I could not find any other way but splitting the single SQL operation in separate files, then executing all of them in sequence. Obviously the problem is not with lists of DML commands, they can be executed without GO in between; different story with DDL (create, alter, drop...)
<a href="http://bugzilla.org>bugzilla</a> is more of an issue tracker than a request tracker, but it can be configured to handle email-based status tracking. That said, I think Steven has it- RT is the standard recommendation for this that I've seen.
How to get your network support team behind click-once?
|smart-client|
I'm trying to make the case for click-once and smart client development but my network support team wants to keep with web development for everything. What is the best way to convince them that click-once and smart client development have a place in the business?
You could try. [Brian the build bunny][1] :-) [1]: http://www.woodwardweb.com/gadgets/000434.html
How can you easily reorder columns in LINQ to SQL designer?
|c#|linq-to-sql|linq|
When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to reorder the classes for the purposes of having the resultant columns in a DataGridView appear in a different order. Unfortunately this seems to be exceedingly difficult; you need to cut and paste properties about, or delete them and re-insert them manually. I *know* you can reorder columns fairly easily in a DataGridView, however that would result in a lot of hardcoding and I want the designer to match up to the grid. Does anyone know of any easier way of achieving this or is cutting/pasting the only available method? I tried manually editing the .designer.cs file, but reordering properties there doesn't appear to do anything!
|c#|linq|linq-to-sql|
When designing LINQ classes using the LINQ to SQL designer I've sometimes needed to reorder the classes for the purposes of having the resultant columns in a DataGridView appear in a different order. Unfortunately this seems to be exceedingly difficult; you need to cut and paste properties about, or delete them and re-insert them manually. I *know* you can reorder columns fairly easily in a DataGridView, however that would result in a lot of hardcoding and I want the designer to match up to the grid. Does anyone know of any easier way of achieving this or is cutting/pasting the only available method? I tried manually editing the .designer.cs file, but reordering properties there doesn't appear to do anything! **Edit:** Just to make it clear - I want to reorder what's in the LINQ to SQL designer, not what's in the table. I haven't made an error in ordering requiring a reversion to the original table layout; rather I have a table which I want to possess a different ordering in Visual Studio than in SQL Server.
How to use LINQ To SQL in an N-Tier Solution?
|linq-to-sql|n-tier-architecture|
Now that LINQ to SQL is a *little* more mature, I'd like to know of any techniques people are using to create an n-tiered solution using the technology, because it does not seem that obvious to me.
They have a place in the Windows environment but not in any other environment and so if you intend on writing applications for external clients, then your probably best sticking with Web based development. I heard this "Write Once, Run Many" before from Microsoft when Asp.net 1.1 was released, it never happened in practice.
Different solutions/project files for Local vs Build environments
|buildprocess|
As part of improvements to our build process, we are currently debating whether we should have separate project/solution files on our CI production environment from our local development environments. The reason this has come about is because of reference problems we experienced in our previous project. On a frequent basis people would mistakenly add a reference to an assembly in the wrong location, which would mean it would work okay on their local environment, but might break on someone else's or on the build machine. Also, the reference paths are in the csproj.user files which means these must be committed to source control, so everyone has to share these same settings. So we are thinking about having separate projects and solutions on our CI server, so that when we do a build it uses these projects rather than local development ones. It has obvious drawbacks such as an overhead to maintaining these separate files and the associated process that would need to be defined and followed, but it has benefits in that we would be in more control over *EXACTLY* what happens in the production environment. What I haven't been able to find is anything on this subject - can't believe we are the only people to think about this - so all thoughts are welcome. Thanks!
|build-process|
best .net build tool
|.net|buildprocess|nant|
What is the best build tool for .net. I currently use [nant][1] but only because I have experience with [ant][2]. Do people prefer msbuild ? [1]: http://nant.sourceforge.net/ [2]: http://ant.apache.org/