language-agnostic

User controlled html title tags

What are the best practices for allowing a user to maintain the html title tags of all the major pages of his/her site? One way could be to allow the mapping of URLs to some text. For example, we have an app with the following (most complex) url format: http://lang.example.com/searchpage.zaf?a=foo&b=bar&c=RANDOM There are sev...

What is a mantainable way of saving "star rating" in a database?

I'll use the jQuery plugin for presenting the user with a nice interface The request is to display 5 stars, up to a total score of 10 (2 points per star). By now I thought about using 7/10 as a format for that value, but what if at some point in the future I'll receive a request like We would like to give users more choice, let's i...

How to call an event when the user "finally" selects an item in a list?

When a user clicks once on an item in a Grid or a ListBox, that item is usually selected, hence most UI frameworks have a onSelected event or the like for that. However, how can we generally call the next step when a user "finally" selects an item by e.g. double clicking an entry? You know when some popup might appear in the context of ...

Collision detection between ball & bricks in brick breaker game

How do you detect a collision between ball & bricks in a brick breaker game? ...

What motivates people to learn a new programming language?

There are plenty of question asking Which Programming Language Should I Learn? but I have not found an answer yet to the question what really motivates people to learn a specific new language?. There are the people who think they should learn a new language every year for educational purpose. How do they decide on the languages to be le...

Most hazardous performance bottleneck misconceptions

The guys who wrote Bespin (cloud-based canvas-based code editor [and more]) recently spoke about how they re-factored and optimize a portion of the Bespin code because of a misconception that JavaScript was slow. It turned out that when all was said and done, their optimization produced no significant improvements. I'm sure many of us g...

Updating a Minimum spanning tree when a new edge is inserted

I've been presented the following problem in University: Let G = (V, E) be an (undirected) graph with costs ce >= 0 on the edges e E. Assume you are given a minimum-cost spanning tree T in G. Now assume that a new edge is added to G, connecting two nodes v, tv V with cost c. Give an efficient algorithm to test if T remains the minim...

Do similar passwords have similar hashes?

Our computer system at work requires users to change their password every few weeks, and you cannot have the same password as you had previously. It remembers something like 20 of your last passwords. I discovered most people simply increment a digit at the end of their password, so "thisismypassword1" becomes "thisismypassword2" then 3,...

Calculate date from numeric value

The number 71867806 represents the present day, with the smallest unit of days. Sorry guy's, caching owned me, it's actually milliseconds! How can I calculate the currente date from it? (or) convert it into an Unix timestamp? Solution shouldn't use language depending features. Thanks! ...

Static analysis of multiple if statements (conditions)

I have code similar to: if conditionA(x, y, z) then doA() else if conditionB(x, y, z) then doB() ... else if conditionZ(x, y, z) then doZ() else throw ShouldNeverHappenException I would like to validate two things (using static analysis): If all conditions conditionA, conditionB, ..., conditionZ are mutually exclusive (i.e. it ...

Transposing UML into code

Short question. How do you go about transposing UML diagrams into code? The class diagram is an obvious one but what about others like Activity, Use Case, Sequence, State, Package, etc.? ...

Analyzing client requirements and formulating software functionalities

How does one go about properly analyzing the requirements of a client in terms of software and writing down a list of functionalities? Feel free to share your own experiences. ...

Setting last N bits in an array

I'm sure this is fairly simple, however I have a major mental block on it, so I need a little help here! I have an array of 5 integers, the array is already filled with some data. I want to set the last N bits of the array to be random noise. [int][int][int][int][int] eg. set last 40 bits [unchanged][unchanged][unchanged][24 bits of ...

Constructing colours for maximum contrast

I want to draw some items on screen, each item is in one of N sets. The number of sets changes all the time, so I need to calculate N different colours which are as different as possible (to make it easy to identify what is in which set). So, for example with N = 2 my results would be black and white. With three I guess I would get all ...

Bi-directional communication with 1 socket - how to deal with collisions?

Hi, I have one app. that consists of "Manager" and "Worker". Currently, the worker always initiates the connection, says something to the manager, and the manager will send the response. Since there is a LOT of communication between the Manager and the Worker, I'm considering to have a socket open between the two and do the commun...

Code-Golf: Friendly Number Abbreviator

Based on this question: Is there a way to round numbers into a friendly format? THE CHALLENGE - UPDATED! (removed hundreds abbreviation from spec) The shortest code by character count that will abbreviate an integer (no decimals). Code should include the full program. Relevant range is from 0 - 9,223,372,036,854,775,807 (the upper li...

Explaining NULL and Empty to your 6-year old?

I'm thinking in terms of Objects here. I think it's important to simplify ideas. If you can explain this to a 6-year old, you can teach new programmers the difference. I'm thinking that a cookie object would be apropos: public class Cookie { public string flavor {get; set; } public int numberOfCrumbs { get; set; } } ...

Where should a beginner start with computer vision?

Hi, I'm an undergrad who finds computer vision to be fascinating. Where should somebody brand new to computer vision begin? ...

Why can't create object of an abstract class?

Here is a scenario in my mind and I have googled, Binged it a lot but got the answer like "Abstract class has not implemented method so, we cant create the object" "The word 'Abstract' instruct the clr that not to create object of the class" But in a simple class where we have all virtual method, able to create an object??? Also, we ...

Why do switch statements continue after case

After evaluating a case in a switch statement in Java (and I am sure other languages) the following case's are also evaluated unless a control statement like break, or return is used. I understand this is probably an implementation detail, but what is/are the reasons for having this functionality happen? Thanks! ...