language-agnostic

How do I determine which cuboids a point is in without iterating over them all?

I have a number of cuboids whose positions and sizes are given with minimum and maximum x, y and z co-ordinates (so they are parallel to the main axes). e.g. I might have the following 3 cuboids: 10.5 <= x <= 39.4, 90.73 <= y <= 110.2, 90.23 <= z <= 95.87 20.1 <= x <= 30.05, 9.4 <= y <= 37.6, 0.1 <= z <= 91.2 10.2 <= x <= 10.3, ...

EngineYard SHA1 Contest Approaches

EngineYard is holding a constest here, where given a phrase and a dictionary of words, come up with a 12 word phrase whose SHA1 hash has the smallest hamming distance from the SHA1 hash of the given phrase. A couple of sites are using cloud/crowd-sourcing to try to bruteforce it, while others are using CUDA and GPUs. Some reports hav...

Average of two angles with wrap around

Possible Duplicate: How do you calculate the average of a set of angles? I have two angles, a=20 degrees and b=350 degrees. The average of those two angles are 185 degrees. However, if we consider that the maximum angle is 360 degrees and allows for wrap around, one could see that 5 degrees is a closer average. I'm having trou...

Is OOP abused in universities ?

I started my college two years ago, and since then I keep hearing "design your classes first". I really ask myself sometimes, should my solution to be a bunch of objects in the first place! Some say that you don't see its benefits because your codebase is very small - university projects. The project size excuse just don't go down my thr...

what should tell an empoyer in a thank you letter for programming job

It is not exactly the programming question, per se, but I couldn't find a more appropriate stackoverflow family site to post the following: I am sick and tired of writing (and reading, as I regularly interview candidates) a generic thank you letter indicating, It was nice meeting you, all of you are awesome, smart, and cool I am the ...

algorithm to determine minimum payments amongst a group

The Problem I was recently asked to calculate the money owed amongst a group of people who went on a trip together and came upon an interesting problem: given that you know the amounts that each person owes another, what is a general algorithm to consolidate the debts between people so that only the minimum number of payments needs to b...

At what point should architecture become layered?

Obviously, "Hello World" doesn't require a separated, modular front-end and back-end. But any sort of Enterprise-grade project does. Assuming some sort of spectrum between these points, at which stage should an application be (conceptually, or at a design level) multi-layered? When a database, or some external resource is introduced? Wh...

What is this code smell called?

I think of this as broken OOP. It's starting to grow like mold in our code base and I need to start talking with people about cleaning it up. Is there a common name for it? public void eat(Fruit fruit) { if (fruit instanceof Banana) { ((Banana) fruit).peel(); } else if (fruit instanceof Pineapple) { ((Pinea...

Is "username" one word or two?

While trying to cleanup an application's API, I found myself scratching my head... What should I call the variable for a user's name "username", or "userName"? ...

Resources to learn bitwise programming?

I am a c++ programmer and occasionally I'll come across some code that is using bitwise operators to manipulate things at the bit level, but I have no real understanding of those concepts. So I would like a resource to help me learn it so well that it becomes second nature. Does anyone know of good resources for this? A google search did...

Unit Testing: Logging and Dependency Injection

So regards logging from SO and other sites on the Internet the best response seems to be: void DoSomething() { Logger.Log("Doing something!"); // Code... } Now generally you'd avoid static methods but in the case of logging (a special case) this is the easiest and cleaniest route. Within the static class you can easily inject ...

Real world uses for obfuscation

For what purposes would you want to obfuscate your code? I have not run into any real purposes other than participating in contests, but I am sure there must be some intelligent and useful reasons for obfuscating source code. Why, in general, do you want or need to obfuscate your code? What real-life applications does obfuscation hav...

why is embedding JSON in XML bad?

My gut tells me that putting one format in another is wrong, but I can't seem to come up with concrete reasons. <root> <stuff> thing </stuff> <more> <[!CDATA[{"a":["b","c"]}]]> </more> </root> versus just putting it in the xml <root> <stuff> thing </stuff> <more> <a> b </a> <a> c </a> </more> </root> Th...

How closely related is music composition to coding?

It seems to me as if there are a higher proportion of musicians in the programming field than in the general public. Maybe it's just an illusion caused by the fact that I'm an amateur guitarist myself, so I tend to notice coding musicians (or musical coders?) more. But I wonder if there really is some connection. Perhaps a shared set ...

Concise description of all common software licenses for the average programmer?

I'm reviewing some jQuery plugins for distribution with closed source (on the server, anyhow) commercial applications. One thing I'm noticing is that there isn't any standard license that covers all plugins. After reading through the legal BS of a couple licenses, I'm feeling very glad I didn't go through with getting a law degree. ...

What happens when open source software has two or more licenses?

I'm considering using a jQuery plugin in a commercial project. The plugin (datepicker) is "dual licensed": Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. Now the MIT license is pretty permissive license, allowing me to ...

Mechanism to ensure a loop ends

When I was in college we had a guest lecture from David Parnas. In it he mentioned a mechanism that is used to guarantee that a loop (while loop, for loop, etc.) exits safely at some point. He scoffed at the fact that nobody knew what it was....the sad thing is that years later I dont know either. Does anyone know what this mechanism is ...

Sorting two-way cell connections with priority

I have a two dimensional grid of cells. In this simulation, cells may request to switch position with another cell. The request also has a priority. The problem is that Im having a hard time coming up with a good way to structure this. If A wants to switch with B, and B also wants to switch with A, they currently can be switched and swi...

How to interpret unprintable characters in the timestamp sent by the Lotus Notes POP3 server?

I wrote a program for retrieving mail from POP3 servers. One of its users encounters the following problem... His mail server when my program connects to it issues a greeting: +OK Lotus Notes POP3 server version X2.0 ready <PrintableCharacters.UnprintableCharacters> The part in angle brackets is a so-called challenge for the APOP aut...

Guidelines for better unit tests

Jimmy Bogard, wrote an article: Getting value out of your unit tests, where he gives four rules: Test names should describe the what and the why, from the user’s perspective Tests are code too, give them some love Don’t settle on one fixture pattern/organizational style One Setup, Execute and Verify per Test In your opinion these gui...