It goes without saying that using hard-coded, hex literal pointers is a disaster:
int *i = 0xDEADBEEF;
// god knows if that location is available
However, what exactly is the danger in using hex literals as variable values?
int i = 0xDEADBEEF;
// what can go wrong?
If these values are indeed "dangerous" due to their use in various ...
I'm relatively unskilled in Dependency Injection, and I'd like to learn some best practices and anti-patterns to use and avoid respectively when using DI.
...
I have a desktop application that runs on a network and every instance connects to the same database.
So, in this situation, how can I implement a mutex that works across all running instances that are connected to the same database?
In other words, I don't wan't that two+ instances to run the same function at the same time. If one is...
The challenge
The shortest code by character count to output an hourglass according to user input.
Input is composed of two numbers: First number is a greater than 1 integer that represents the height of the bulbs, second number is a percentage (0 - 100) of the hourglass' capacity.
The hourglass' height is made by adding more lines to...
Recently, I've been learning different programming langages, and come across many different names to initalize a function construct.
For instance, ruby and python use the def keyword, and php and javascript use function, while VB uses void, etc.
My question is: What is the reasoning and differences between these different constructs an...
Hi guys, I recently confronted with a weird yet interesting question. The questions is as follows:
Need to write a program which can give the gender as output based on the name.
Example: INPUT --> John
Michael
Britney
OUTPUT--> male
male
female
So this ...
I find myself very intrigued by the existence of a ConcurrentBag<T> class in the upcoming .NET 4.0 framework:
Bags are useful for storing objects when ordering doesn't matter, and unlike sets, bags support duplicates.
My question is: how might this idea be implemented? Most collections I'm familiar with essentially amount to (under...
We are told that we should implement hashCode() for our classes but most people like me have no real idea of how to do this or what happens if we get it "wrong". For example I have a need for a hash function for indexing nodes in a tree (http://stackoverflow.com/questions/1685239/finding-the-most-frequent-subtrees-in-a-collection-of-pars...
I've spent several years in software development, using many different languages/technologies. To be clear, I have 10 years of software development experience myself. Now as I want to advance in my career, it seems most companies that I would want to work for desire a very specialized technical pedigree - even for a manager/director le...
Hi,
I would like to know if it's possible to point it out, and if so If anyone would know to summarize, considering things well beyond the basics and expectable of course, what would be nowadays the overall or statistical most highly regarded pieces of technical knowledge I better have if I wanna improve my chances of getting the highes...
I know:
C++, Java, and tons others:
object.method() , object.method(arg)
Objective-C:
[object method] , [object method:arg]
Smalltalk:
object method , object method: arg
PHP, Perl
object->method(), object->method(arg)
$object->method;
$object->method($arg1, $arg2, ...);
OCaml
object#method , object#method args
CLOS...
I'm working with Websphere Portal and Oracle. On two occasions last week, I found that the most direct way to code a particular solution involved using API's provided by IBM and Oracle. However, I realize every line of code written using these vendor API's renders us a little bit more locked in to these systems (particularly the portal...
Imagine you have two images A and B, and a third grayscale image T. A and B contain just about anything, but let's assume they're two scenes from a game.
Now, assume that T contains a diamond gradient. Being grayscale, it goes from black on the outside to white on the inside.
Over time, let's assume 256 not further elaborated on "ticks...
Disassembling/decompiling is usually considered reverse engineering. What if I don't decompile the executables but only observe the changes to the computer - what registry changes the program installer made, what files it copied and what system calls are done when the program is running (using something like Process Monitor) in order to ...
I have need to do some cluster analysis on a set of 2 dimensional data (I may add extra dimensions along the way).
The analysis itself will form part of the data being fed into a visualisation, rather than the inputs into another process (e.g. Radial Basis Function Networks).
To this end, I'd like to find a set of clusters which prim...
Given an array of integers, how can you find two indices, i and j, such that the sum of the elements in the indices is maximized, in linear time?
...
According to various sources, such as Wikipedia and various .edu websites found by Google, the most common ways for a hash table to resolve collisions are linear or quadratic probing and chaining. Randomized probing is briefly mentioned but not given much attention. I've implemented a hash table that uses randomized probing to resolve ...
My gut tells me there is no good way to achieve this, but, unlike Mr. Stephen Colbert, I'd rather trust a community of developers than my gut...
Is there a known way to efficiently implement a "best of both worlds" list, one that provides random access by index and O(1) insertion/removal like a linked list?
I foresee two possible outco...
I want to have a button that has numbers in the range 0 ... 255. I'd like the color of the button to be white when it's zero and blue (RGB = (0,0,255)) when it is 255. How can I accomplish this? At first I tried to make it RGB = (0,0,0) in the beginning, but it will only make it black.
How can I accomplish this?
...
I started toying with this idea some years ago when I wrote my university papers. The idea is this - the perfect color quantization algorithm would take an arbitrary true-color picture and reduce the number of colors to the minimum possible, while maintaining that the new image is completely indistinguishable from the original with a nak...