instruction
stringlengths
0
30k
I answered this in another version of this question: > Foreach is for iterating over > collections that implement > IEnumerable. It does this by calling > GetEnumerator on the collection, which > will return an Enumerator. > > This Enumerator has a method and a > property: > > * MoveNext() > * Cu...
I have never found a clean solution (i.e.: a class / method in the .NET Framework) for this problem. I guess it just isn't available except the solutions / examples you provided or Aku's example. :(
I think C++ offers the best semantics in terms of having the 'most correct' behavior ... however it is more work for the compiler and the code is definitiely non-intuitive to someone reading it later. With the .NET approach the function must be very limited not to rely on any derived object state.
Byte arithmetic is discouraged, as it relies on all IPs being 4-octet ones.
@kronoz - well thanks a lot for your long answer, that's a really good place to start from. I'll follow your advices, and look for the book @vecstasy mentioned. now, let me go coding :-) let thanksalot = "thanks a lot" printfn "%s" (thanksalot);;
Both ways can lead to unexpected results. Your best bet is to not call a function like this in the constructor.
Both ways can lead to unexpected results. Your best bet is to not call a function like this in the constructor. The C++ way I think makes more sense, but leads to expectation problems when someone reviews your code. If you are aware of this situation, you should purposely not put your code in this situation for l...
Both ways can lead to unexpected results. Your best bet is to not call a virtual function in your constructor at all. The C++ way I think makes more sense, but leads to expectation problems when someone reviews your code. If you are aware of this situation, you should purposely not put your code in this situation...
You'll need the FileMaker Pro installation CD to get the drivers. [This document][1] details the process for FMP 9 - it is similar for versions 7.x and 8.x as well. Versions 6.x and earlier are completely different and I wouldn't bother trying (xDBC support in those previous versions is "minimal" at best). FMP 9 sup...
I've used by Ubuntu desktop for some coding sessions. I haven't settled on an IDE, but if I'm not using gedit, I'll use emacs as my editor. Sometimes I need to ssh to a remote server and edit from there, in which case emacs is preferred. I'm just not the vi(m) type. Maybe I'll try out Eclipse one day... I love...
Take a look at [BOUML][1]: free, multiplatform (QT), works pretty well and supports colaborative work. > BOUML is a free UML 2 tool box (under development) allowing you to specify and generate code in C++, Java, Idl, Php and Python. > BOUML runs under Unix/Linux/Solaris, MacOS X(Power PC and Intel) and Windows. ...
Using Apache mod_rewrite to remove sub-directories from URL
|apache|wordpress|mod-rewrite|
I'm managing an instance of Wordpress where the URLs are in the following format: http://www.example.com/example-category/blog-post-permalink/ The blog author did an inconsistent job of adding categories to posts, so while some of them had legitimate categories in their URLS, at least half are "uncategori...
When you get to the point where you have a large number of tests, changing the system might require re-writing some or all of your tests, depending on which ones got invalidated by the changes. This could turn a relatively quick modification into a very time-consuming one. Also, you might start making design decisi...
First of all you should be probably connect through the DBI library and then you should use bind variables. E.g. something like: #!/usr/bin/perl # use strict; use DBI qw(:sql_types); my $dbh = DBI->connect( $ConnStr, $User, $Password, ...
First of all you should be probably connect through the DBI library and then you should use bind variables. E.g. something like: #!/usr/bin/perl # use strict; use DBI qw(:sql_types); my $dbh = DBI->connect( $ConnStr, $User, $Password, ...
Java added support for this in 1.5. It will not compile in earlier versions.
Yeah, it's called WPF :) Seriously, there are some newer panel types in WinForms 2.0 that will let you place controls without setting Location and Size. They are FlowLayoutPanel and TableLayoutPanel. You should also look into the AutoSize property. It takes care of sizing when the value of the label, say, changes...
What is your codebase? Eclipse has quite good support for Java. But unfortunately limited support for C++ code. [Heres][1] an article from the makers.. [1]: http://www.ibm.com/developerworks/library/l-eclipse.html
well... with 5.3 on the horizon, all will be better, because with 5.3, we'll get closures and with them anonymous functions http://wiki.php.net/rfc/closures
There are some fairly good reasons for not using `enum`s on an interface boundary like that. Consider [Dare's post](http://www.25hoursaday.com/weblog/2005/08/31/WhyYouShouldAvoidUsingEnumeratedTypesInXMLWebServices.aspx) on the subject.
Try this: RewriteCond %{HTTP_HOST} (.+)\.blah\.domain\.com RewriteRule ^(.+)$ /%1/$1 [L]
Try this: RewriteCond %{HTTP_HOST} (.+)\.blah\.domain\.com RewriteRule ^(.+)$ /%1/$1 [L] @pilif (see comment): Okay, that's true. I just copied a .htaccess that I use on one of my projects. Guess it has a slightly different approach :)
You don't want to hassle users with OpenID, but you want them to deal with this email scheme. Firstly, email can take a long time to go through. There isn't any guaranteed time that an email will be delivered in. It's not even guaranteed that the email will get there at all. I know things usually are quick, but it'...
Rule of thumb for choosing an implementation of a Java Collection?
|java|collections|heuristics|
Anyone have a good rule of thumb for choosing between different implementations of Java Collection interfaces like List, Map, or Set? For example, generally why or in what cases would I prefer to use a Vector or an ArrayList, a HashTable or a HashMap?
Anyone have a good rule of thumb for choosing between different implementations of Java Collection interfaces like List, Map, or Set? For example, generally why or in what cases would I prefer to use a Vector or an ArrayList, a Hashtable or a HashMap?
"Could not load type" in web service converted to VB.NET
|c#|vb.net|web-services|translation|sharpdevelop|
I wrote a simple web service in C# using SharpDevelop (which I just got and I love). The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, so I may seem a little old-fashioned.) But I get ...
How do I get a particular labeled version of a folder in Borland StarTeam?
|version-control|borland|starteam|
I'm about to perform a bunch of [folder moving operations][1] in StarTeam (including some new nesting levels) and I would like to set a label so that I can roll back in case of issues. I figured out how to set a label on a folder and all its children, but I couldn't figure out how to get the version of that folder cor...
This isn't an IIS failure. The SMTP server receiving the message is looking for a valid email address, and when it doesn't find one, sends an email back to your email address saying that there isn't one there. The only way to have it silently fail is by putting the from address as a bogus email like no-reply@company.c...
Configure VS to automaticly remove blank line after cut?
|c#|editor|
Is there a way (or shortcut) to tell VS 2008 that it cuts a line like this: **Before:** Some Text here This gets cut Some Code there **After:** Some Text here Some Code there **What I want:** Some Text here Some Code there PS: I don't want to select the whole line or something like ...
Can VS be configured to automatically remove blank line(s) after text is cut?
|visual-studio|ide|editor|
Have you tried deleting your bin directories before recompiling?
1) Look into using TRY..CATCH in SQL 2005. Unfortunately there is no FINALLY, so you'll have to handle both the success and error cases individually. 2) Not necessary if (1) handles the cleanup. 3) There isn't really a difference between client and server transactions with SQL Server. Connection.BeginTransactio...
If you mean printing out HTML in your code, then no. Unless you have a good reason not to, you should use [templates](http://en.wikipedia.org/wiki/Template_engine_(web)) Even if you think you don't need this now, there's always a good chance you'll need it later. Maybe you want to output in a different forma...
Just for variety: array_diff(explode('/', '1/2//3/'), array('')) This also works, but does mess up the array indexes unlike preg\_split. Some people might like it better than having to declare a callback function to use array\_filter.
It is not supported in the standard (and it is apparently a known bug with Visual Studio that you *can* do it). The standard doesn't allow an inner template (member function *or* class) to be specialized without the outer template being specialized as well. One of the reasons for this is that you can normally just ...
What is a reason that LINQ to SQL wouldn't generate a collection based on a relationship?
|linq-to-sql|
I have a relationship between two entities (e1 and e2) and e1 has a collection of e2, however I have a similar relationship set up between (e2 and e3), yet e2 does not contain a collection of e3's, any reason why this would happen? Anything I can post to make this easier to figure out?
I have a relationship between two entities (e1 and e2) and e1 has a collection of e2, however I have a similar relationship set up between (e2 and e3), yet e2 does not contain a collection of e3's, any reason why this would happen? Anything I can post to make this easier to figure out? Edit: I just noticed that the ...
|linq-to-sql|
struts2: how to substring in jsp?
|struts2|
is there a way to substring in JSP files, using struts2 technologies? I mean, struts2 has its own taglib and also uses ognl. How can I get a substring from a stacked value or bean value? thanks in advance. stv
|jsp|struts2|
How do you implement caching in Linq to SQL?
|.net|sql|linq-to-sql|iis|
This may well end up being a [subjective][1] question, but anyway: We've just started using LINQ to SQL at work for our DAL & we haven't really come up with a standard for out caching model. Previously we had being using a base 'DAL' class that implemented a cache manager property that all our DAL classes inherited...
Why do .Net WPF DependencyProperties have to be static members of the class
|wpf|.net|
Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring to the table is * Support for Callbacks (Validation, Change, etc) * Property inheritance * Attached properties among others. But my question here is why do they need to be declared as static in the contain...
|.net|wpf|
Learning WPF nowadays. Found something new today with .Net dependency properties. What they bring to the table is * Support for Callbacks (Validation, Change, etc) * Property inheritance * Attached properties among others. But my question here is why do they need to be declared as static in the contain...
Multiple exit points are fine for small enough functions -- that is, a function that can be viewed on one screen length on its entirety. If a lengthy function likewise includes multiple exit points, it's a sign that the function can be chopped up further. That said I avoid multiple-exit functions *unless absolutely ...
windowsmobile
|windows-mobile|
Is therу broad way to handle Bluetooth [Audio/Video Remote Control Profile (AVRCP)][1] events on WM device? I especialy interested in Comact Framework way but would be happy with just simple P/Invoke API. [1]: http://en.wikipedia.org/wiki/Bluetooth_profile#Audio.2FVideo_Remote_Control_Profile_.28AVRCP.29
Audio/Video Remote Control Profile (AVRCP) on Windows Mobile
Is therу broad way to handle Bluetooth [Audio/Video Remote Control Profile (AVRCP)][1] events on WM device? I especialy interested in Comact Framework way but would be happy with just simple P/Invoke API. **Update.** I've read [MSDN][2] articles on this theme but I still have no idia how to facilitate this knowledg...
As horrible as it looks, the `git gui` and `gitk` commands are as good as any. GitX looks extremely promising, and very Mac-like (things like QuickLook'ing any file in any revision). Gitnub is probably the furthest along in development, but it has no concept of branching currently, and is pretty basic (it does far l...
Good Git repository viewer for Mac
|design-patterns|object|intersection|
Literal hashes in c#?
|ruby|hashtable|c#|literal|
I've been doing c# for a long time, and have never come across an easy way to just new up a hash. I've recently become acquainted with the ruby syntax of hashes and wonder, does anyone know of a simple way to declare a hash as a literal, without doing all the add calls. { "whatever" => {i => 1}; "and then som...
|c#|ruby|hashtable|literals|
The Microsoft Natural Keyboard has been very, very good for me. I use emacs for everything 10+ hrs a day with no problems.
There are no file attributes that you can place on your files to mark them as immovable. The only way that a file cannot be moved (I think) during defragmentation is to have some other process have the file open (for read or write, I'm not even sure that you need to have the file open in exclusive mode or not). Qui...
You have to handle the postback event (button click or whatever) then enumerate the repeater items like this: foreach(RepeaterItem item in rptQuestions.Items) { //pull out question var question = (Question)item.DataItem; question.Answer = ((TextBox)item.FindControl("txtAnswer")).Text...
Since you are developing a Web App (presumably with ASP.NET), check out [NHibernate Best Practices with ASP.NET][1] at CodeProject. [1]: http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
The greediness of the lexer is probably the determining factor in the absence of parentheses to make it explicit. I'd guess that the lexer isn't greedy.
I think we must assume that this site will be subject to targeted attacks on a regular basis, not just generic drifting bots. If it becomes the first hit for programmers' searches, it will draw a <b>lot</b> of fire. To me, that means that any CAPTCHA system <b>cannot pull from a repeating list of questions</b>, whic...
Hrmm, interesting challenge. I think you can do it without a self-join if you use the new-to-2005 pivot functionality.
I have a MS natural keyboard as well and it's awesome. I've managed to train myself to use the side of my left hand (below the pinky) to hit the Ctrl key.
I know you mentioned batch files, but let me throw something else out for you. I'm going to guess that you are using the 2005 version of TFS. 2008 has all of the scheduling stuff built in. However, you could also use [CruiseControl.net][1] to do scheduled builds for you. I've used both TFS 2008 and CruiseCont...
It can be hard and time consuming writing tests for "random" data like XML-feeds and databases (not that hard). I've spent some time lately working with weather data feeds. It's quite confusing writing tests for that, at least as i don't have too much experience with TDD.
You can get a list of invalid characters from Path.GetInvalidPathChars [http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidpathchars.aspx][1] And GetInvalidFileNameChars [http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx][2] [1]: http://msdn.microsoft.co...
You can get a list of invalid characters from Path.GetInvalidPathChars [http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidpathchars.aspx][1] And GetInvalidFileNameChars [http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx][2] **UPD:** See [Steve Cooper's sugg...
Using MSSQL Management Studio i've transitioned tables with the MySQL OLE DB. Right click on your database and go to "Tasks->Export Data" from there you can specify a MsSQL OLE DB source, the MySQL OLE DB source and create the column mappings between the two data sources. You'll most likely want to setup the data...
It's easier to think in terms of each entity validating itself, and entities which depend on one another delegating their state to the state of their associated entries. In your case, for instance: class Operation < ActiveRecord::Base has_many :entries validates_associated :entries end vali...
When applicable, it's better to use contextual selectors rather than add spurious classes. For instance, if the `<div>` elements are the only children of an element with `id="foo"`, then using `$("#foo > div:visible").attr("id")` would better reflect the purpose of the code.
Alan, there's nothing wrong with dynamic class initialisation. This technique is present also in Java language, where one can convert string to class using `Class.forClass('classname')` method. It is also quite handy to defer algorithm complexity to several classes instead of having list of if-conditions. Dynamic class...
ASP.NET File Upload with *Real-Time* Progress Bar [http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html][1] [1]: http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html
Here are a couple of versions of what you're looking for for some common JavaScript toolkits. - Mootools - [http://digitarald.de/project/fancyupload/][1] - Extjs - [http://extjs.com/learn/Extension:UploadForm][2] [1]: http://digitarald.de/project/fancyupload/ [2]: http://extjs.com/learn/Extension:Uplo...
egrep regexp *.html
egrep '\(?\d{3}\)?[-\s.]?\d{3}[-.]\d{4}' *.html
String initialization..
|c|
What is the difference between Str[32] = "\0"; and Str[32] = "";
Do you keep your existing data in the database? If not, you may want to look at something similar to what Matt mentioned for .NET called [RikMigrations][1] http://www.rikware.com/RikMigrations.html I use that on my projects to update my database on the fly, while keeping track of revisions. Also, it makes it...