language-agnostic

What conditions can I rely on for a script that determines whether my servers are "up"?

I usually deal with at least two dozen servers on a weekly basis. I thought it would be a good idea to create a script that queries each of them and determines whether they're "up" or not. The servers run either Apache2 or IIS7. The hosting providers vary There are usually multiple sites on each server The setups are inconsistent, the...

Should I avoid do/while and favour while?

Possible Duplicates: Test loops at the top or bottom? (while vs. do while) While vs. Do While In discussions here it seems most people prefer while loops over do/while loops. To me it seems do/while is a fundamental part of the language, and one that everyone should understand as easily as while. It may be less common, but ...

What is the difference this oop patterns pros and cons?

i writed some codes about oop pattern. But i cannot see clearly these two kind of usage advantage disadvantagages: Firs one: class Program { static void Main(string[] args) { Report rp = new Report(); rp.MakeReport(); rp = new ExcelReport(); rp.MakeReport(); ...

Passing my own project on someone else - what to do?

Often there are situations where a project is passed on someone else. And often this process is unpleasant for both sides - the new owner complains about horrible documentation, bugs and bad design. The original owner is then bothered for months with questions about the project, requests to fix old bugs etc. I might soon be in a situati...

NFA minimization without determinization

It is well-known how one gets from an NFA for a regular language to a minimal DFA. However, the DFA might have an exponentially larger number of states. What I need is a way to reduce an NFA, giving again an NFA but with a smaller number of states. T.i. I don't need the result to be deterministic, but I'd like it to be as small as possi...

is it good practice to create functions which use other functions that you built?

I was wondering if it was good to have this since it makes code less portable. Thanks ...

Can a executable behave differently when run on a Virtualized Server?

Let's say I have a piece of code that runs fine on an OS. Now, if I install that OS on a virtual machine (server virtualization), and run that code on that, is it possible that the code behaves differently? If so, what are the prerequisites for that? For example, does it have to be compiled machine code (in other words, are interprete...

Besides serialization, what would be the legitimate uses of reflection to access private members?

Reflection can be used to access just about any object's internals, which is kind of not cool. I tried to list the legitimate uses of it, but in the end only serialization came to my mind. What other (legitimate) uses can you find to using reflection in order to access otherwise inaccessible members? EDIT I mean stuff you can't do if y...

Where might I begin on this optimization problem?

I have a simple program which reads a bunch of things from the filesystem, filters the results , and prints them. This simple program implements a domain specific language to make selection easier. This DSL "compiles" down into an execution plan that looks like this (Input was C:\Windows\System32\* OR -md5"ABCDEFG" OR -tf): Index Succe...

How do you call a string that matches /^\w+$/?

Strings that match /^\w+$/ are quite common. For example many authentication systems use that pattern to validate usernames. I'm wondering if a term exists that identifies this kind of strings. I've been thinking of the term "alphanumeric" but is a string alphanumeric if it contains an underscore? ...

Algorithmic issue: determining "user sessions"

I've got a real little interesting (at least to me) problem to solve (and, no, it is not homework). It is equivalent to this: you need to determine "sessions" and "sessions start and end time" a user has been on in front of his computer. You get the time at which any user interaction was made and a maximum period of inactivity. If a ti...

Understanding the motion of a disk using two static switches

This is a major re-write of the original question, I tried to clarify those points that were evidently confusing for some in my first version of the question. Thanks for the input in helping formulate the problem better! CONTEXT The challenge comes from a real-life coding problem. The first thing that responders should be aware of, is ...

Best way to represent Spain address in java.

I have coded the below to represent addresses in Spain. Let me know if there are better ways of doing this or if there is already a open source library dealing with i18n addresses. /** * From <a href="http://www.addressdoctor.com/en/countries_data/sampleaddress.asp?code=ESP%2BSpain}"&gt;Address doctor</a> * <p> * Format * </p> * ...

How to share your code

I have to admit I've never been very pragmatic or business oriented when it comes to writing computer code, but looking through some of my past projects, I see a ton of pretty good ideas with some decent code. Some are finished products, others just bits and pieces. What's the best way to share your code and give it some exposure? i.e. ...

How would I find all the short urls that link to a particular long url?

Basically I want to know how many people have tweeted a link to a url, but since there are dozens of link shortener out there I don't see any way to do this without having access to all of their url maps. I found a previous question here but it was over a year old and didn't have any new answers. So #1, does anyone know of a service/AP...

rightrotate without bitwise operators

How can I implement the rightrotate (and leftrotate) operations on 32 bit integers without using any bitwise operations? I need this because High Level Shader Language (HLSL) does not allow bitwise oeprations upon numbers, and I need rightrotate for a specific shader I'm trying to implement. ...

What would we do without NULL?

I once read that having nullable types is an absolute evil. I believe it was in an article written by the very person who created them(in Ada?) I believe this is the article Anyway, so what if by default a language like C# used non-nullable types? How would you replace some of the common idioms in C# or Ruby or any other common language...

Why is separation of user and profile data considered good?

Hello. I've been reading this question and felt that I don't quite agree with the statement Separation of user and profile data is a nice touch. As I see it, profile data, such as, e.g. country or whatever belongs in the user object, while separating such data into profile leads to creating a new object (and table) with 1-to-1 relation...

Why aren't we all reverse debugging?

Is it me, or is reverse debugging the most amazing feature ever that no-one seems to be using or building into all or debuggers for that matter? By Reverse debugging I mean a debugger that by some means records the state of your program at every execution level and thus allows you to go backwards and forwards in time through the executi...

Divide grid (2D array) into random shaped parts?

The Problem I want to divide a grid (2D array) into random shaped parts (think earth's tectonic plates). Criteria are: User inputs grid size (program should scale because this could be very large). User inputs grid division factor (how many parts). Grid is a rectangular shaped hex grid, and is capped top and bottom, wrap around ...