I have users that fall into the following
Not logged in
Not Verified
Verified
Moderator
Admin
All code that only admin and moderators can access (like banning) is in ModeratorUser which inherits from verified which inherits from BaseUser. Some pages are accessible to all users such as public profiles. If a user is logged in he can le...
I am looking for an algorithm that could find the two most distant elements in a binary tree, not looking for any special language, just for the algorithm.
Thanks.
...
Map Reduce is a pattern that seems to get a lot of traction lately and I start to see it manifest in one of my projects that is focused on an event processing pipeline (iPhone Accelerometer and GPS data). I needed to built a lot of infrastructure for this project, in fact it overweighs the logic code interacting with it by 2x. Some of th...
Hello, I am building a static-website (as in, to change a page, we change the HTML and there is no DB or anything). Well, it will have a number of pages and I don't want to copy and paste the HTML navigation and layout code around everywhere.
So what would be the best platform to use in this situation so I can have all my layout and "co...
Looks like dynamic memory allocation without garbage collection is a way to disaster. Dangling pointers there, memory leaks here. Very easy to plant an error that is sometimes hard to find and that has severe consequences.
How are these problems addressed when mission-critical programs are written? I mean if I write a program that contr...
On my previous job, providing all methods with javadoc was mandatory, which resulted in things like:
/**
* Sets the Frobber.
*
* @param frobber The frobber
*/
public setFrobber(Frobber frobber) { ... }
As you can see, the documentation takes up space and work, but adds little to the code.
Should documenting all methods be mandato...
I have a 2D array
1 2 3
4 5 6
7 8 9
and want to sort it like this
Snake
1 2 3
8 9 4
7 6 5
Snake (different)
1 2 3
6 5 4
7 8 9
Rotated
1 4 7
2 5 8
3 6 9
Wipe (diagonal)
1 3 6
2 5 8
4 7 9
Well, you got it, all kinds of sorting.
Searching the interweb for hours now. Any resources (specific language or pseudo code) on that great...
There is a large stream of numbers coming in such as 5 6 7 2 3 1 2 3 .. What kind of data structure is suitable for this problem given the constraints that elements must be inserted in descending order and duplicates should be eliminated.
I am not looking for any code just ideas? I was thinking of a Self-Balancing BST where we could ad...
In my portfolio site I have listed my projects under separate tabs (tab menu). This works well except for printing which requires the user to click on a tab, print, click on the next tab and print the same page again to get everything. Being a portfolio I'd assume that visitors want to print all of the content.
Is there a general way to...
Is there a fast method for taking the modulus of a floating point number?
With integers, there are tricks for Mersenne primes, so that its possible to calculate y = x MOD 2^31-1 without needing division. integer trick
Can any similar tricks be applied for floating point numbers?
Preferably, in a way that can be converted into vect...
There is so much written about unit testing but I have hardly found any books/blogs about integration testing? Could you please suggest me something to read on this topic?
What tests to write when doing integration testing?
what makes a good integration test?
etc etc
Thanks
...
Should I frequently rely on default values?
For example, in PHP, if you have the following:
<?php
$var .= "Value";
?>
This is perfectly fine - it works. But what if assignment like this to a previously unused variable is later eliminated from the language? (I'm not referring to just general assignment to an unused variable.)
There...
I ask since a project I work on generates a single, monolithic DLL of about 50 MB size.
Does a large library like this one impede performance, or can it bring other gotchas?
UPDATE:
I work with Embercadero RAD Studio Delphi 2010 on Windows (XP|Vista|7).
...
Suppose there are ~10,000's of keys, where each key corresponds to a stream of events. I'd like to support the following operations:
push(key, timestamp, event) - pushes event to the event queue for key, marked with the given timestamp. It is guaranteed that event timestamps for a particular key are pushed in sorted or almost sorted or...
I have the following array:
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
I use it for some visual stuff like this:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Now I want to sort the array like this to have a "zig-zag" when rendering later.
// rearrange the array according to this schema
1 3 6 10
2 5 9 13
4 8 12 15
7 1...
Pretend1 there is a place to type in a name:
Name: __________________
When the text box changes, the value is absorbed into the controller, who stores it in data model. Business rules require that a name be entered: if there is no text entered the TextBox should be colored something in the view to indicate baddness; otherwise it ca...
i'm facing the problem of the view showing data that's not in the model, and the model containing data that isn't in the view.
Imagine the data model has a birth date field:
DateTime: BirthDate;
And the view lets the user enter a birth date:
Birth Date: 11/28/1973
And that date goes into the model via the controller and all...
If from one view a user enters some invalid data, e.g.:
E-mail: [email protected]
then i want the controller to:
not place the data into the model
color the text box reddish
not allow the user to save
But it's possible that if the user enters the same invalid data in a different view i want the controller to:
place the data ...
When a user tries to click:
Save
and they have entered in some invalid data, i want to notify them. This can be with methods such as:
directing their attention to the thing that needs their attention with a balloon hint
automatically dropping down a combo-box
triggering an animation
showing a modal dialog box
etc
What is the...
Here's the easy pseudo-code:
void TextBox1Changed()
{
//If the text isn't a number, color it red
if (!IsValidNumber(TextBox1.Text)
TextBox1.Color = Pink;
else
TextBox1.Color = WindowColor;
}
What's the MVC enterprisey version?
...