I was reading the following article: http://www.canon.com/news/2010/mar16e.html
It seems Canon is the first company to spring for ICANN's new policy, allowing corporations and businesses to purchase their own TLD (Top Level Domain).
I began to think... wouldn't this be the perfect thing for the...
So I got variable $your_momma that eats random foods. My code looks like this:
$your_momma = new Momma("Japanese");
while($your_momma->wants_to_eat()) {
$food = new Food("random");
$your_momma->eat($food);
}
print $your_momma->lastFoodsEaten(5);
$your_momma object adds randomly generated f...
Problem statement
My solution:
'use strict';
function processData(input) {
var parse_fun = function (s) {
return parseInt(s, 10);
};
var lines = input.split('\n');
var T = parse_fun(lines.shift());
var data = lines.splice(0, T).map(parse_fun);
for (var i = ...
@RubberDuck I'm working on an event-driven game, and I'm registering a number of Event Listeners. When executing the events, I'd like to be able to debug easier to find out which event listener is which, so it needs to be uniquely identifiable somehow. To register an event I call something like game.registerHandler(ActionPerformEvent.class, event -> aiPerform(event.getGame())); , but this does not provide much identification for the listener that was added.
So one option would be to pass an 'identifier' or something to the 'registerHandler' method, another is for the code to try to determine from where the handler was added (i.e. creating a stack-trace and backtracking through it), but sometimes that doesn't give all the needed information.
@RubberDuck it feels like if I go with that, I have to change about 30 lines to add the 'this' parameter, and I have to create a reasonable toString for a bunch of classes. It feels like an acceptable solution, but I can't help but feel that there is a better way
I hope some can look over my new object-oriented version of my hangman game I posted here about two weeks ago. Any suggestions or criticisms would be very helpful.
PS: I know I should work more on commenting and be clearer and more descriptive of the methods and their parameters and returns.
Me...
@Malachi I really did not expect to have to write this comment on one of your questions:
To make life easier for reviewers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. See also this meta question. You mention that you are wrong about RNGs, but what is it actually your code is doing? And what was your original belief about RNGs? — Simon André Forsberg1 min ago
I wrote this code to show how wrong I was about Random Number Generators,
Is there anything that I can do to make it more apparent how wrong that I am about the distribution of random numbers?
Random rng = new Random();
Dictionary<int, UInt64> tallyCount = new Dictionary<int, UInt64>();
//Key ...
@ArieLitovsky At first I thought: Whoa, we have an SO moderator among us. But looking further I have a feeling you are a SE employee. Or else you must be very lucky getting elected on so many sites!
When doing a CR, it's important to be able to quickly find methods/classes/whatever in the source. Currently, it's just terrible as you get a couple of small scrolling views and the search takes way more time than anything else.
That's specific to CR, as other sites rarely need that much code. T...
I have these three helper functions that I've used on some projects as a slightly better alternative to the C memset function. The objective is to simplify and clarify code, as well as add asserts where possible:
// Zero fills a POD type, such as a structure or union.
template<class T>
void Zero...
Nokia still builds small phones, you can get a brand new one for around 25$. But not durable at all, damn phone broke when My mom put it in to the washing machine. :(
Lets talk about perfomance
What if I need to use your list very frequently?
Lets look closer at function arraylist_add, if I need list with 1 million of bytes, which is 1MB you will reallocate your data struct member 1 million times.
It is lowest part of your list!
My improvement suggestions...
Based on this answer: MVVM implementation using C# and XAML, I understand that my ViewModel is some kind of a wrapper for my Model.
Being a fan of DI and SOLID principles, I have made my ViewModel Model-dependent.
CustomerDetailViewModel
public class CustomerDetailViewModel : ViewModel<Customer>...
I've been working on an older project that's target framework is 3.5. There is a new user control that displays a list of data from a web service. I hit the web service (soap/xml) and deserialize the data into a list of a custom model/class (this is in a helper class outside the user control).
B...
the more numbers that you request the less deviation you have, so it is truly pseudo random, in that the numbers returned are distributed evenly throughout the range.
I'm working on this code to make it more efficient, maintainable, stable, etc. It's code for the iceblox game. What are some flaws in this code when thinking about analyzeability, stability, changeability, testability, and maintainability. What can I do as far as program changes to make this code...
I watch the presentation about concurrent programming presented by Rob Pike and i saw the daisychain example. I tried to rewrite this code to make it more readable. Everything went well, but i am currently stuck to the point where only a maximum amount of chains are allowed. I want to keep the ra...
its a good question though, the code definitely needs improvement. I am sure there are deeper issues that could be elaborated on if anyone is brave enough to dig into it
I am trying to copy files from machineB and machineC into machineA as I am running my below shell script on machineA.
If the files is not there in machineB then it should be there in machineC for sure so I will try copying the files from machineB first, if it is not there in machineB then I will...
Enum
int gameState;
This little variable can have a lot of magic numbers (as mentioned by mjolka).
As the possible values of this is limited to a fairly small number of values, 12 as far as I can see, I would write up an enum for it.
public enum GameState {
PENGUIN_DEAD, PENGUIN_HAPPY, I...
This script updates a settings in ssl config file for Nginx. I generate DHEC key and then update the Nginx SSL file to that location. I also give an option for the user through arguments if they want to change the bit size of the key and if they want more conservative or hardened SSL cipher suit...
This follows on from a previous question I asked which was of huge help to me. I am still only learning Python and Django and I would love to learn how to code better.
The below is a get_context_data method which is used to return a variable to an internal page of a Django SessionWizardView...
can any one answer what each line really means, I found this online, I am trying to teach myself python, I am not sure what it really mean.
def primo(n):
def z(x):
if x % i : return True
if x == i: return True
return False
nump =[2]+ range(3, n+1, 2)
for i in range(3, int((n**0....
@200_success I am definitely going to have to research that a little bit, it's way over my head at the moment, but I have noticed that the more numbers that I request from the application the smaller the deviation is.
@200_success thank you. I will be looking into that. and probably looking for some of my old Math books, it's been a while since I even thought about statistics let alone Standard Deviation, mean, mode, average, etc.
@200_success lol. last time I learned anything about statistics was in an advanced math class in highschool, but that was something like 13 years ago I think...
We are currently implementing a thread safe in memory cache mechanism!
With the intent of storing objects that are expensive to create or often used by the system!
We also want to include expiration policy, i.e number of times a object was accessed and when it was last accessed date. Which wil...
Me and another developer have recently forked and taken over an abandoned, open-source project. I have also been reading articles and watching videos by Misko Hevery:
http://misko.hevery.com/code-reviewers-guide/
https://www.youtube.com/watch?v=wEhu57pih5w&list=PLD0011D00849E1B79
So when I was...
I'd like to see how the author of this question reacts to my answer. http://codereview.stackexchange.com/a/64462/17000
I tried to keep an as-simple-as-possible object oriented design but since he was thinking that his design was object oriented he could possibly be quite disoriented by my suggestion. Do you think it could be beginner-proof?