language-agnostic

How long does code last?

I'm in the process of going back over some of the more minor TODO's in my code. One of them is in a class that handles partial dates, e.g. Jan 2001. It works fine for dates that will be seen in our system (1990 - 2099) and gracefully fails for other dates. The TODO that I've left for myself is that I don't handle dates in the century 21...

How to display changed fields

Hi, I am working on Audit Trail for my project and I have been asked to think of how can we display the fields which have changed between two versions. I have the list of changed fields I am looking for suggestions on how to display the fields so that user can easily find out: which fields have changed what was the old and new value ...

What's the bean pattern name when used in other languages

Java has the concept of a "bean", which is a class with a no-arg constructor and getter/setter methods. Does this pattern have a more generic name so that, if we're talking to programmers who have never used Java, we can avoid using the term "bean"? ...

How should I be handling checksum collisions in my application?

I have a part of my application that stores files. Because we could potentially be adding many of the same file, I am first keeping a hash of each file. If two files have the same hash, then we throw out one, and both "references" to that file point to the same physical file. How much should I be worried about hash collisions? In th...

Code Golf: Does a binary number lie within the Cantor set?

Definition The Cantor set T, sometimes called the Cantor comb or no middle third set (Cullen 1968, pp. 78-81), is given by taking the interval [0, 1] (set T0), removing the open middle third (T1), removing the middle third of each of the two remaining pieces (T2), and continuing this procedure ad infinitum. The challenge Given a s...

What is the largest program ever written?

In a fit of idle curiosity, I was wondering that the largest program ever written was. What did it do? What language was it written in? How successful was it? How buggy was it? How many man years did it take to create? I realise that 'largest' and 'program' are both a bit ill-defined. For the sake of argument I am defining it as a singl...

How are things represented visually?

Hello, I'm a beginner and I was wondering how pictures,video,windows and buttons etc are represented visually on the screen. I'm not asking whether it was made from for example gtk or wxwidgets, My question is what is the fundamental idea behind making the pixels come up the way they do. And what exactly does GUI library use to put them ...

Good name for the opposite of the "canary" metaphor

The "canary" is a common metaphor (for example in buffer overflow checks) for detecting mis-behaving operations by setting a flag before and verifying that it is still set after. Is there a common term for the opposite, when the operation should kill the "canary"? ...

(OpenXML) Add data pages to xml package without framework

Hi all, lately I've been into combining multiple OpenXML speadsheets via PHPExcel which showed me that this framework has certain issues which makes it pretty much unusable for what I want to do (my related SO question). To make it short: it's hard to guarantee that all formatting features of Excel 2007 will persist a file merge perfor...

Are there any inobvious ways of abusing GUIDs?

GUIDs are typically used for uniquely identifying all kinds of entities - requests from external systems, files, whatever. Work like magic - you call a "GiveMeGuid()" (UuidCreate() on Windows) function - and a fresh new GUID is here at your service. Given my code really calls that "GiveMeGuid()" function each time I need a new GUID is t...

Use Dijkstra's to find a Minimum Spanning Tree?

Dijkstra's is typically used to find the shortest distance between two nodes in a graph. Can it be used to find a minimum spanning tree? If so, how? Edit: This isn't homework, but I am trying to understand a question on an old practice exam. ...

Most intuitive, readable API / language reference documentation

I'm working on the dreaded last stage of a project: documenting the API for a semi-technical audience. I'm wondering: what API docs have you found to be particularly elegant? Note that this has nothing to do with how elegant the API itself is: this is purely a question of the formatting/appearance of the API docs themselves. Which lang...

Number grouping using regexps

Is it possible to do number grouping (e.g., converting the number 1000 to the string "1 000") using one pass with only regular expressions? (I know the boundary between regexp and language facilities are a bit blurred in some systems - listen to your conscience before replying.) Reason why I'm asking: Another dev recently asked me how t...

What quality attributes are vital to an ecommerce web application?

This question is just out of interest, and perhaps could be useful for my thesis. A web application, especially when your business is relying on it financially, needs to meet certain requirements in order to survive. I'd like to hear what kind of (software) quality attributes you find most important (name a few) regarding to web applic...

Converting color value from float 0..1 to byte 0..255

What would be the correct way of converting color value from float to byte? At first I thought b=f*255.0 should do it, but now I'm thinking, that in this case only the exact 1.0 will be converted to 255, but 0.9999 will already be 254 which is probably not what I want... It seems that b=f*256.0 would be better except that it would have ...

How can I use TOR as a proxy?

I'm trying to use TOR as a generic proxy but it fails Right now I'm trying with python but I'm pretty sure it would be the same with any other language. I can connect to other proxies with python so I get how it "should" be done. I found a list of TOR entry nodes h = httplib.HTTPConnection("one entry node", 80) h.connect() h.request("...

CRC32 and MD5 algorithms for dummies

I'd like to implement the CRC32 and MD5 algorithms on my own but I'm still trying to wrap my head around the different sources I've found on the subject. Could someone helpful point me to a ressource that explains the algorithms in a simple format or post a bullet list of the different steps so I can attempt to fill them in. TIA. Here's...

How can I fairly choose an item from a list?

Let's say that I have a list of prizes: PrizeA PrizeB PrizeC And, for each of them, I want to draw a winner from a list of my attendees. Give that my attendee list is as follows: user1, user2, user3, user4, user5 What is an unbiased way to choose a user from that list? Clearly, I will be using a cryptographically secure pseudo-rand...

Am I overdoing it with my Factory Method?

Hello. Part of our core product is a website CMS which makes use of various page widgets. These widgets are responsible for displaying content, listing products, handling event registration, etc. Each widget is represented by class which derives from the base widget class. When rendering a page the server grabs the page's widget from th...

Data structure for storing thousands of vectors

I have upto 10,000 randomly positioned points in a space and i need to be able to tell which the cursor is closest to at any given time. To add some context, the points are in the form of a vector drawing, so they can be constantly and quickly added and removed by the user and also potentially be unbalanced across the canvas space.. I a...