language-agnostic

Strategies for programmatically controlling a commercial DVD player

If you were tasked with operating a commercial DVD player from a computer program, how would you do it? My company sells a product that does exactly that. We have a couple of different approaches, and they both have major issues: Get an IR Transmitter, Pretend To Be a Remote Control Pros: Works with pretty much every commercial DV...

Typical Pay or am I being taken advantage of?

I have an internship for a small engineering company. I have been working about three years now. What started as an internship turned into a full-out job, and I have worked to take a total of two projects public. I support my software and help on other production tasks throughout the company. My pay is 10.25 an hour. This was my pay whe...

PRNG with adjustable period

I need to build an in-place pseudo-random number generator with an adjustable period. In addition, there must be no collisions within one period. That is, the following must return true: // prng is "generated" at run-time // (though a by-hand solution would work) bool test(func prng, int period) { int seed = 0; // Any number sho...

Most efficient way to visit nodes of a DAG in order

I have a large (100,000+ nodes) Directed Acyclic Graph (DAG) and would like to run a "visitor" type function on each node in order, where order is defined by the arrows in the graph. i.e. all parents of a node are guaranteed to be visited before the node itself. If two nodes do not refer to each other directly or indirectly, then I don'...

If 'else' is about to happen anyway should it be declared or not?

Possible Duplicate: Should else be kept or dropped in cases where its not needed? When a = 0 This: var foo = function() { if (a != 0) return true return false } Or this: var bar = function() { if (a != 0) return true else return false } ...

Programming preference - use else ifs with multiple return statements?

The code: public String getTemperatureMessage(double temp) { if(temp < 32) return "Freezing"; else if(temp < 60) return "Brr"; else if(temp < 80) return "Comfortable"; else return "Too hot"; } Regarding the code snippet above, the else ifs are technically superfluous and don't change the...

Where do I put formatting logic?

I have several classes with raw data, for example: public interface Transaction { public double getAmount(); public Date getDate(); } I need to output formatted versions of this data in several places. For example, I might display the amount as $1,000 on a web page, or 1000.00 on an Excel download. I also want to be able to reus...

What are logging libraries for?

This may be a stupid question, as most of my programming consists of one-man scientific computing research prototypes and developing relatively low-level libraries. I've never programmed in the large in an enterprise environment before. I've always wondered, what are the main things that logging libraries make substantially easier than...

Code Golf: Calculate Orthodox Easter date

The Challenge Calculate the Date of the Greek Orthodox Easter (http://www.timeanddate.com/holidays/us/orthodox-easter-day) Sunday in a given Year (1900-2100) using the least amount of characters. Input is just a year in the form '2010'. It's not relevant where you get it (Input, CommandLineArgs etc.) but it must be dynamic! Output sho...

What is the point of scaffolding?

I don't understand the significance of something like rails, codeigniter, etc. and scaffolding. From what I read, and maybe it's just wrong, scaffolding isn't used in the production environment. I don't know what it's for. It's neat but I don't know what I am supposed to do with it. Thanks. ...

Should I always store a string of HTML instead of printing out portions of it at time?

I've come across dozens of scripts in which html is echo'd out instead of being stored. I'm wondering if it's generally a good practice of always storing the html in a string due to the flexible nature? A random example would be that I have a function that returns the html for a dynamic subnavigation. I'm printing the opening div tag, p...

Expressing 2x2 Logic Grid in Code Efficiently

In an event handler I'm responding to the change of a value. I have access to the old value and the new value and want to do certain things depending on what the change is. Each different outcome will do some combination of actions/functions X, Y, or Z. Z accepts a parameter between -1 and 1. Order of performing these is not important. ...

Good way to procedurally generate a "blob" graphic in 2D

I'm looking to create a "blob" in a computationally fast manner. A blob here is defined as a collection of pixels that could be any shape, but all connected. Examples: .ooo.... ..oooo.. ....oo.. .oooooo. ..o..o.. ...ooooooooooooooooooo... ..........oooo.......oo.. .....ooooooo..........o.. .....oo.................. ...

In-language semantic variance

I've been thinking about doing my own language (practicality: it's a thought experiment). One of the ideas I came up with is in-language semantic variation. You'd write essentially semantic regular expressions, to be replaced with equivalent code. You can see this in a somewhat less direct form in D- they have string mixins that convert ...

What are the practical uses of modulus (%) in programming?

Possible Duplicate: Recognizing when to use the mod operator I wonder, what are the practical uses of modulus? I know what modulo division is. The first scenario which comes to my mind is to using it to find odd and even numbers, and clock arithmetic. But where esle you could use it? ...

finding duplicate video files by database (millions), fingerprint? pattern recognition?

Howdy. In the following scenario: I got a project having a catalog of currently some ten thousand video files, the number is going to increase dramatically. However lots of them are duplicates. With every video file I have associated semantic and descriptive information which I want to merge duplicates to achive better results for eve...

Language Simplicity: Spec vs. Code?

I often see people commenting that what they want is a simple language, with a simple specification and not too many excess features, odd rules and multiple ways of doing things. I've never understood this except when the opposite is taken to the extreme. Isn't a more meaningful measure of language complexity the complexity of the code...

Should I allow a plugin to crash my application?

I am adding an event driven plugin api to a web based system I am working on. Should I wrap the plugin calls in a try/catch to make sure they don't crash or should I leave this up to plugin developers to take care of. Also, some of the plugins may change the data I pass them, should I re-validate all the data or trust the plugin develo...

Performance testing. How to increase hdd operations stability

I try to simulate application load to measure application performance. Dozens of clients send requests to server and significant part of request processing is random data loaded from HDD (random file, random file offset). I use 15 Gb in 400 files. HDD does its best to cache reading operations so overall performance is very unstable f...

What advanced-level programming concepts/techs to learn? Language neutral

Hi, Although I am learning a variety of newer .NET technologies (MEF, SL4, etc), what are the language-neutral advanced technologies to learn? For example, I remember ANTLR being one. I know a little about image recognition/edge detection etc as I am incorporating it in a project, but I am looking for skills which don't require speciali...