language-agnostic

Storage of many log files

I have a system which is receiving log files from different places through http (>10k producers, 10 logs per day, ~100 lines of text each). I would like to store them to be able to compute misc. statistics over them nightly , export them (ordered by date of arrival or first line content) ... My question is : what's the best way to ...

Code Golf: Quickly Build List of Keywords from Text, Including # of Instances

I've already worked out this solution for myself with PHP, but I'm curious how it could be done differently - better even. The two languages I'm primarily interested in are PHP and Javascript, but I'd be interested in seeing how quickly this could be done in any other major language today as well (mostly C#, Java, etc). Return only wor...

How should I Test a Genetic Algorithm

I have made a quite few genetic algorithms; they work (they find a reasonable solution quickly). But I have now discovered TDD. Is there a way to write a genetic algorithm (which relies heavily on random numbers) in a TDD way? To pose the question more generally, How do you test a non-deterministic method/function. Here is what I have ...

Fast generation of random numbers that appear random...

I am looking for an efficient way to generate numbers that a human would perceive as being random. Basically, I think of this as avoiding long sequences of 0 or 1 bits. I expect humans to be viewing the bit pattern, and a very low powered cpu should be able to calculate near a thousand of these per second. There are two different con...

What are some algorithms for finding a closed form function given an integer sequence?

I'm looking form a programatic way to take an integer sequence and spit out a closed form function. Something like: Given: 1,3,6,10,15 Return: n(n+1)/2 Samples could be useful; the language is unimportant. ...

The data structure for the "order" property of an object in a list

I have a list of ordered objects stored in the database and accessed through an ORM (specifically, Django's ORM). The list is sorted arbitrarily by the user and I need some way to keep track of it. To that end, each object has an "order" property that specifies its order in relation to the other objects. Any data structure I use to sor...

Real Life Benefits of Dynamic Languages?

Hi, I'm exploring several possibilities for developing a new system (web application). I'm an "old fashioned" kinda guy, object oriented in nature (converted from procedural many years ago). I played around with Python and studied a bit Ruby, but frankly I'm attracted back to using Microsoft's tools (C#, ASP.NET MVC). All this run-time...

How do I convert a stereo wav to mono

If I already have the wav data in two arrays (left channel & right channel) how does one go about to converting them to a single mono array? Is there a function f so that Mono[x] = f(L[x],R[x]) ? ...

Any source of good object-oriented design practises?

Is there any website where people share and discuss good examples of object-oriented design? Ideally such website should be populated with posts of the following structure: Concise description of the problem, including definitions, links, etc. Several attempts of OO design, diagrams, pseudocode listings (voted up/down by users) Comme...

What different terms mean the same thing (or don't, but people think they do)?

One of the pitfalls I run into on a daily basis is customers saying one thing while meaning another. Usually, this is just due to a miscommunication somewhere, but occasionally they are, in fact, saying the same thing I am just using a different term. For example, one of my customers the other day mentioned a feature he called, "find a...

Upper limit of bugs in a given program

Is there an upper limit to the number of bugs contained in a given program? If the number of instructions are known, could one say the program cannot contain more than 'n' bugs? For example, how many bugs could the following function contain? double calcInterest(double amount) { return -O.07 / amount; } A parser would count four...

How prevalent is UTF-8 really?

How wide-spread is the use of UTF-8 for non-English text, on the WWW or otherwise? I'm interested both in statistical data and the situation in specific countries. I know that ISO-8859-1 (or 15) is firmly entrenched in Germany - but what about languages where you have to use multibyte encodings anyway, like Japan or China? I know that a...

Concurrency vs Parallelism - What is the difference?

Concurrency vs Parallelism - What is the difference? Any examples ...

Progressive Connected Component Labeling

I am working with a grid of squares which have two states, "ON" and "OFF." I have a rather simple Connected Component Labeling algorithm which finds all of the "ON" components. Usually, but not always, there is exactly one "ON" component. I wish to construct an algorithm which takes in as input a matrix of on/off cells, a component la...

Map incrementing integer range to six-digit base 26 max, but unpredictably

I want to design a URL shortener for a particular use case and type of end-user that I have targetted. I have decided that I want the URLs to be stored internally according to an auto-incrementing integer key. However, it is also required that a key be represented to users in the url as six-digit base 26 (a-z * 6) AND it's not possible t...

"Every language was created for a specific purpose"

I was reading the post Why Language is Important (Why I prefer C#) from 'Dot Net Thoughts' and the first paragraph of the article ends with this statement: ...every language was created for a specific purpose. This got me thinking about exactly "why" certain languages exist...ie what is their specific reason of their existence. ...

How to avoid deadlocks?

When using multiple threads, shared memory needs to be locked by critical sections. However, using critical sections causes potential deadlocks. How can they be avoided? ...

How to avoid mutable state (when multithreading)

Multithreading is hard. The only this you can do is program very carefully and follow good advice. One great advice I got from the answers on this forum is to avoid mutable state. I understand this is even enforced in the Erlang language. However, I fail to see how this can be done without a severe performance hit and huge amounts of cac...

Evenly distributed random numbers relatively prime to 2

A specific example I need to generate a random number between 0 and 2, inclusive. (or choose randomly between -1, 0, and 1). The naive approach would be to do something like rand() mod 3 where rand() returns an integer. This approach will not generate statistically random numbers unless the upper bound of rand() is not relatively prim...

ways to learn implementing workflow of a software

Hi... How many ways are there to learn implementing workflow of a software? What are them? ...