language-agnostic

Smart progress bar ETA computation

In many applications, we have some progress bar for a file download, for a compression task, for a search, etc. We all often use progress bars to let users know something is happening. And if we know some details like just how much work has been done and how much is left to do, we can even give a time estimate, often by extrapolating fro...

Create your own MD5 collisions

I'm doing a presentation on MD5 collisions and I'd like to give people any idea how likely a collision is. It would be good to have two blocks of text which hash to the same thing, and explain how many combinations of [a-zA-Z ] were needed before I hit a collision. The obvious answer is hash every possible combination until hit two has...

Windows Filtering Platform Callout Drivers - Samples, Tutorials, Help

I'm trying to write a Windows Filtering Platform Callout Driver for a parental control program. Unfortunately, I've never written a driver before, and the MSDN documentation on it isn't too helpful unless you already know the basics (I'm guessing). Does anyone know of any good resources on the subject? Books, online samples, documenta...

What's the most effective workflow between people who develop algorithms and developers?

We are developing software with pattern recognition in video. We have 7 mathematicians who are creating algorithms. Plus we have 2 developers that maintain / develop the application with these algorithms. The problem is that mathematicians are using different development tools to create algorithm like Matlab, C, C++. Also because the...

Efficient way to handle adding and removing items by bitwise And

So, suppose you have a collection of items. Each item has an identifier which can be represented using a bitfield. As a simple example, suppose your collection is: 0110, 0111, 1001, 1011, 1110, 1111 So, you then want to implement a function, Remove(bool bitval, int position). For example, a call to Remove(0, 2) would remove all items...

How to test if matrix is diagonal?

I need to test if one variance matrix is diagonal. If not, I'll do Cholesky LDL decomposition. But I was wondering which would be most reliable and fastest way to test is matrix diagonal? I'm using Fortran. First thing that come to my mind is to take sum of all elements of matrix, and substract diagonal elements from that sum. If the an...

Your Language Regex match full name "last, first middle1 middle2 suffix"

Spent me 3 hours to get a good regex finished for parsing these 3 main possible situations. Redden, Taylor Captain Hasting Jr. Redden, Taylor Hasting Jr. Redden, Taylor Hasting full, l, f, m1, m2, s = /your_regex_here/.match("Redden, Taylor Captain Hasting Jr.").to_a I want to see what other possible answers there are beside min...

When does Big-O notation fail?

What are some examples where Big-O notation[1] fails in practice? That is to say: when will the Big-O running time of algorithms predict algorithm A to be faster than algorithm B, yet in practice algorithm B is faster when you run it? Slightly broader: when do theoretical predictions about algorithm performance mismatch observed runnin...

Quicksort with 3-way partition

What is QuickSort with a 3-way partition? ...

storing + evaluating performance data

since we suffer from creeping degradation in our web application we decided to monitor our application performance and measure individual actions. for example we will measure the duration of each request, the duration of individual actions like editing a customer or creating an appointment, searching for a contract. in most cases the d...

What is a good network graph library for language X?

I have noticed that a recurring question is: “What is a good network graph library for language X”. I have played with quite a few of the libraries and I can share my experiences with you. Python: NetworkX is a robust library which has built-in visualization but also has an interface to Graphviz using pyGraphviz. (pyGraphviz and Network...

Are endless loops in bad form?

So I have some C++ code for back-tracking nodes in a BFS algorithm. It looks a little like this: typedef std::map<int> MapType; bool IsValuePresent(const MapType& myMap, int beginVal, int searchVal) { int current_val = beginVal; while (true) { if (current_val == searchVal) return true; MapType::i...

Algorithm to generate a crossword

Given a list of words, how would you go about arranging them into a crossword grid? It wouldn't have to be like a "proper" crossword puzzle which is symmetrical or anything like that: basically just output a starting position and direction for each word. ...

Does YAGNI also apply when writing tests?

When I write code I only write the functions I need as I need them. Does this approach also apply to writing tests? Should I write a test in advance for every use-case I can think of just to play it safe or should I only write tests for a use-case as I come upon it? ...

What's the Right Tool for automating refresh+scrub of a page behind a login?

A friend just asked me if I could help him in automating something that is taking up a lot of his time. He grades essays online so basically there is a website that he logs into and sits on a page refreshing it until some data appears (new essays to be graded). Instead of doing this he would like to simply be notified when there are ne...

How to make comments on if statements most readable

I'm trying to make my code easily understood by future readers. I've always had issues with how to word my if statement comments to make it the most understandable. Maybe it seems trivial, but it's something that's always bothered me Here's an example: if ( !$request ) { $request = $_SERVER['REQUEST_URI']; } Here are some way I...

How to model execution time of algorithms?

Which models of algorithm running time exist? We all expect mergesort to be faster than bublesort, and note that mergesort makes O(n log n) comparisons vs. O(n2) for bubblesort. For other algorithms, you count other operations (than compares and swaps), such as pointer dereference, array lookup, arithmetic on fixed-size integers, etc. ...

What tips can you offer for programming on paper?

In exams and interview situations, it's common to need to either write or review code that's not on a screen. Whether it's on paper or a whiteboard, what tips can you offer for both the writing and reviewing/debugging processes? ...

What is Functional Decomposition?

Functional Decomposition, what is it useful for and what are it's pros/cons? Where are there some worked examples of how it is used? ...

incremental k-core algorithm

Calculating the k-core of a graph by iteratively pruning vertices is easy enough. However, for my application, I'd like to be able to add vertices to the starting graph and get the updated core without having to recompute the entire k-core from scratch. Is there a reliable algorithm that can take advantage of the work done on previous it...