language-agnostic

Simple integer encryption

Is there a simple algorithm to encrypt integers? That is, a function E(i,k) that accepts an n-bit integer and a key (of any type) and produces another, unrelated n-bit integer that, when fed into a second function D(E(i),k) (along with the key) produces the original integer? Obviously there are some simple reversible operations you can...

Is there server-side code which is not cross browser compatible?

Was there a case in any server-side language where a code did not work in a browser while it did work in the rest? I am asking this because I can't imagine such a scenario because server-side code runs in the server, not in the browser but I have seen discussions where, as said, there were "server-side browser compatibility issues". I c...

Pre Project Documentation

I have an issue that I feel many programmers can relate to... I have worked on many small scale projects. After my initial paper brain storm I tend to start coding. What I come up with is usually a rough working model of the actual application. I design in a disconnected fashion so I am talking about underlying code libraries, user inte...

Is using a finite state machine a good design for general text parsing?

I am reading a file that is filled with hex numbers. I have to identify a particular pattern, say "aaad" (without quotes) from it. Every time I see the pattern, I generate some data to some other file. This would be a very common case in designing programs - parsing and looking for a particular pattern. I have designed it a...

Determining the order of a list of numbers (possibly without sorting)

I have an array of unique integers (e.g. val[i]), in arbitrary order, and I would like to populate another array (ord[i]) with the the sorted indexes of the integers. In other words, val[ord[i]] is in sorted order for increasing i. Right now, I just fill in ord with 0, ..., N, then sort it based on the value array, but I am wondering if...

Language independent logic question

If one has three fields in a db that they are querying an object by.... One of these fields must always be an associations id. Concerning the other two fields "only one needs to be true" What interpretation do you take or make of "only one needs to be true"? ...

Can I use part of MD5 hash for data identification?

I use MD5 hash for identifying files with unknown origin. No attacker here, so I don't care that MD5 has been broken and one can intendedly generate collisions. My problem is I need to provide logging so that different problems are diagnosed easier. If I log every hash as a hex string that's too long, inconvenient and looks ugly, so I'd...

Unsigneds in order to prevent negative numbers

let's rope I can make this non-sujective Here's the thing: Sometimes, on fixed-typed languages, I restrict input on methods and functions to positive numbers by using the unsigned types, like unsigned int or unsigned double, etc. Most libraries, however, doesn't seem to think that way. Take C# string.Length. It's a integer, even though...

Convert 0 to 1 and Vice Versa

I was asked in an interview : how to convert 0 to 1 and 1 to 0. I answered : Simple if and switch Bit flipping. Are there any other approach? ...

New design patterns/design strategies

I've studied and implemented design patterns for a few years now, and I'm wondering. What are some of the newer design patterns (since the GOF)? Also, what should one, similar to myself, study [in the way of software design] next? Note: I've been using TDD, and UML for some time now. I'm curious about the newer paradigm shifts, and or ...

Is it kEatSpeed or kSpeedEat?

I have a bunch of related constants that are not identical. What's the better way to name them? way #1 kWalkSpeed kRunSpeed kEatSpeed kDrinkSpeed Or, way #2 kSpeedWalk kSpeedRun kSpeedEat kSpeedDrink If we evaluate these based on readability understandability organization in member list (autocomplete) not bug prone with subt...

Measuring how "heavily linked" a node is in a graph

I have posted this question at MathOverflow.com as well. I am no mathematician and English is not my first language, so please excuse me if my question is too stupid, it is poorly phrased, or both. I am developing a program that creates timetables. My timetable-creating algorithm, besides creating the timetable, also creates a graph who...

Scrum stories and behind the scenes features

As I understand things, the Scrum backlog is composed of a series of Stories that represent something for the end user and this is further decomposed into Features. If this is the case, where does all the behind the scenes features go that aren't really linked to a story but are still useful? For example, say I'm making an application ...

Serialize and unserialize

What does the serialize do? Why do we need to serialize an Object and again unserialize it? Is it for any sort of security measures? ...

How would you start automating my job?

At my new job, we sell imported stuff. In order to be able to sell said stuff, currently the following things need to happen for every incoming shipment: Invoice arrives, in the form of an email attachment, Excel spreadsheet Monkey opens invoice, copy-pastes the relevant part of three columns into the relevant parts of a spreadsheet te...

Deploying software on compromised machines

I've been involved in a discussion about how to build internet voting software for a general election. We've reached a general consensus that there exist plenty of secure methods for two way authentication and communication. However, someone came along and pointed out that in a general election some of the machines being used are almost...

Forcing a machine to boot from a live CD

If I want to distribute some software on a bootable CD, is there a way (from windows) to force the machine to restart onto the CD OS, even if the BIOS is not setup with boot from CD? ...

Need an algorithm to group several parameters of a person under the persons name

Hi. I have a bunch of names in alphabetical order with multiple instances of the same name all in alphabetical order so that the names are all grouped together. Beside each name, after a coma, I have a role that has been assigned to them, one name-role pair per line, something like whats shown below name1,role1 name1,role2 name1,role3 n...

Starting a personal reuasable code repository.

Hi, I've been meaning to start a library of reusable code snippets for a while and never seem to get round to it. At the moment I just tend to have some transient classes/files that I drag out of old projects. I think my main problems are: Where to start. What structure should my repository take? Should it be a compiled library (wher...

What are the benefits and drawbacks of using header files?

I had some experience on programming languages like Java, C#, Scala as well as some lower level programming language like C, C++, Objective - C. My observation is that low level languages try separate out header files and implementation files while other higher level programming language never separate it out. Those languages use some i...