language-agnostic

Overcoming Programmers' UI

I am decidedly a programmer, and not a UI designer, so when I am working on internal tools, I really struggle with laying out controls in a useful manner. For example, all those questions I've been asking for the last two days have been for building this tool: http://www.gfilter.net/junk/taskmanager.jpg And while I am pretty happy wit...

How to respond to an alternate URI in a RESTful web service

I'm building a RESTful web service which has multiple URIs for one of its resources, because there is more than one unique identifier. Should the server respond to a GET request for an alternate URI by returning the resource, or should I send an HTTP 3xx redirect to the canonical URI? Is HTTP 303 (see also) the most appropriate redirect?...

Is regex case insensitivity slower?

Source RegexOptions.IgnoreCase is more expensive than I would have thought (eg, should be barely measurable) Assuming that this applies to PHP, Python, Perl, Ruby etc as well as C# (which is what I assume Jeff was using), how much of a slowdown is it and will I incur a similar penalty with "/[a-zA-z]/" as I will with "/[a-z]/i" ? ...

Are there similar tools to Code Detective for Other languages/IDEs?

Just saw this linked on YCombinator news and the idea heavily appeals to me, and seems like it would be useful for many languages, not just c#, but haven't seen anything similar elsewhere. For reference: http://www.codeplex.com/CloneDetectiveVS edit: basic description of the tool for those who don't want to follow the link - It scans ...

Validate a UK phone number

How do I validate a UK phone number in C# using a regex? ...

Helpful snippits?

I'm a relatively new coder, and I'm looking to increase my snippits library. What are some of your most used snippits? I'm mainly looking for ones that I might not have thought about until I've had more experience, but will make me more productive. Have a snippit that is particularly clever? Post it! ...

How do you write code that is both 32 bit and 64 bit compatible ?

What considerations do I need to make if I want my code to run correctly on both 32bit and 64bit platforms ? EDIT: What kind of areas do I need to take care in, e.g. printing strings/characters or using structures ? ...

What are generally accepted code formatting guidelines?

According to McCall's Quality Model, Product Revision is one of the three main perspectives for describing the quality attributes of a software product. Under the Product Revision perspective, maintainability, the ability to find and fix a defect, is identified as a key quality factor that impacts the ability to revise the software. Cle...

What is tail-recursion?

Whilst starting to learn lisp, I've come across the term tail-recursive. What does it mean? ...

Looking for examples of "real" uses of continuations

I'm trying to grasp the concept of continuations and I found several small teaching examples like this one from the Wikipedia article: (define the-continuation #f) (define (test) (let ((i 0)) ; call/cc calls its first function argument, passing ; a continuation variable representing this point in ; the program as the arg...

Natural Sorting algorithm

How do you sort an array of strings naturally in different programming languages? Post your implementation and what language it is in in the answer. ...

What is a good Hash Function?

What is a good Hash function? I saw a lot of hash function and applications in my data structures courses in college, but I mostly got that it's pretty hard to make a good hash function. As a thumble rule to avoid collisions my professor said that: function Hash(key) return key mod PrimeNumber end (mod is the % operator in C and sim...

if statement condition optimisation

I have an if statment with two conditions (seperated by an OR operator), one of the conditions covers +70% of situations and takes far less time to process/execute than the second condition, so in the interests of speed i only want the second condition to be processed if the first condition evaluates to false. if i order the conditions ...

Interview programming test practice

Does anyone know of some good resources for practice coding questions typically asked in interviews. I know of topcoder.com which is kind of fun to use to exercise your algorithms. And I have seen the occasional test set on company websites. Any others? Edit: Also found in my bookmarks ... techinterviews.com ...

Should a function have only one return statement?

Are there good reasons why it's a better practice to have only one return statement in a function? Or is it okay to return from a function as soon as it is logically correct to do so, meaning there may be many return statements in the function? ...

Virtual functions in constructors, why do languages differ?

In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function. I think everyone who encountered for the first time was surprised but on second thought it makes sense, if the derived constructor hasn't yet run the object is not yet a derived so how can a derived function be called? The precon...

How to robustly, but minimally, distribute items across a peer-to-peer system

If one has a peer-to-peer system that can be queried, one would like to reduce the total number of queries across the network (by distributing "popular" items widely and "similar" items together) avoid excess storage at each node assure good availability to even moderately rare items in the face of client downtime, hardware failure, ...

True random number generator

Sorry for this not being a "real" question, but Sometime back i remember seeing a post here about randomizing a randomizer randomly to generate truly random numbers, not just pseudo random. I dont see it if i search for it. Does anybody know about that article? ...

What are some good IRC channels for programmers?

I am looking for some IRC channels for programmers. Websites, forums, and stackoverflow are good for large-ish questions, but for quick stupid things or just chatting about issues with easy back-and-forth then IRC would be ideal. Can anyone recommend IRC channels, either about specific languages or more general programming chat? ...

Is a GUID unique 100% of the time?

Is a GUID unique 100% of the time? Will it stay unique over multiple threads? ...