« first day (892 days earlier)      last day (3129 days later) » 

12:00 AM
RELOAD!
There are 1576 unanswered questions (94.3166% answered)
 
@Duga Ouch...
One more than yesterday: one more zombie to shoot...
 
12:29 AM
-1
Q: Tic-Tac-Toe Game (Java)

aebkeaHow could this code be improved? package tictactoe; public class TicTacToe { public static void main(String[] args) { GameBoard myGame = new GameBoard(); myGame.displayBoard(); int counter = 1; while (myGame.gameActive() && counter < 10) { if (...

 
12:40 AM
@EthanBierlein Your second query is 100% redundant. Check the Messages tab.
 
0
Q: Yahtzee Game in Java - Code organization/enum's a good idea?

Robert BlatnerI am designing two methods to be used in a Java implementation of Yahtzee. For those not familiar with the game, basically players take turns rolling dice and acquire points based on the face up values of a roll. 5 6-sided dice are rolled per turn. There are 13 categories that determine a score...

0
Q: The Handy-Dandy Apocalypse Assistant

SirPython Code Review is running rampant with an infection. A zombie infection. Everywhere posts are becoming rapidly mutated into slobbering, green freaks of nature. But the citizens of Code Review are not running. No; they are fighting! These CRitters are shooting the zombies left and right to...

 
1:04 AM
@Hosch250 Sounds like an answer to me.
 
Not really.
If @RubberDuck wishes to mention it, he can. It isn't substantial enough by itself.
 
1:33 AM
@rolfl I use PascalCase for keywords.
 
2:01 AM
Rather quiet, I'd say
 
Monk*
 
Hello @Phrancis!
 
I got an annoying problem to solve...
void deleteUser(String userName) {
    def userExists = usersCollection.find( { user_name : userName } )
    if (!userExists) {
        println "No such user to delete: \"$userName\""
    } else {
        usersCollection.remove( { user_name : userName } ) // MongoDB receives a closure, even though it's native Mongo syntax
        println "User \"$userName\" deleted."
    }
}
> groovy.lang.MissingMethodException: No signature of method: com.mongodb.DBCollectionImpl.remove() is applicable for argument types: (groovydatabase.UsersCollection$_deleteUser_closure2) values: [groovydatabase.UsersCollection$_deleteUser_closure2@38425407]
 
So for some reason it seems the compiler assumes { user_name : userName } is a closure, which is a problem, since it isn't
 
2:10 AM
What is it supposed to be?
 
db.inventory.remove( { type : "food" } )
^^ MongoDB syntax
 
Is there a different syntax for it?
 
Nope
 
Hmm
I sense a possible bug
 
But the funny thing is... usersCollection.find( { user_name : userName } ) works just fine
Only difference is find instead of remove
Yeah you may be right. So, I gotta make a workaround now
 
2:13 AM
Have you tried declaring the input as a variable and then just passing it?
def a = { user_name : userName }
 
Hm, good idea, let's try
 
0
Q: computational performance, Microsoft Visual c# vs Intel® Visual FORTRAN

LoneXcoderi am programming in c#, but recently i was trying to check performance, taking c# to it's limits via unsafe and parallelism..etc'. then i have discovered that for things like low level computations and calculations, accessing the hardware, i should use some low level language. as i don't like ...

0
Q: Max and Min in array using minimum comparisons

ItalianIs this the most robust and fastest way for finding min and max out of an array without using STL functions ? How can i improve it ? Here is the code #include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]) { system("clear"); int c=9,n[10],max,min,i; while (c>=0) { n[c]=ran...

 
@EthanBierlein Same thing :|
 
pfft
darn mongodb
 
I think Groovy is the problem, TBH
 
2:16 AM
Ah
 
Well:
Report possible bugs there ^^
 
@CaptainObvious Totally unclear.
@CaptainObvious POB, maybe?
 
@Hosch250 No but I think this will, just gotta use Java syntax mkyong.com/mongodb/java-mongodb-delete-document
 
Hey guys, we may have a new contributor soon
KingCodeFish, Charlotte Hall, MD
1 1
I know him from off-site, and he may be posting things.
 
2:28 AM
Okay, getting a different error, that's good
> java.lang.IllegalArgumentException: can't serialize class groovydatabase.UsersCollection$_deleteUser_closure1
Have no idea what it means, but hey at least it's not the same thing
 
lol
Java/the JVM is so frickin screwy
@Phrancis This might help you:
12
Q: Inserting Java Object to MongoDB Collection Using Java

yogesh prajapatiI am trying to insert whole java object into MoggoDB Collection using java i am getting following error. Error : Exception in thread "main" java.lang.IllegalArgumentException: can't serialize class net.yogesh.test.Employee at org.bson.BSONEncoder._putObjectField(BSONEncoder.java:185) a...

 
That's terrible. But, oh well.
The Mongo API manual says you can just use regular query language, which is what I was trying to do in the first place :|
 
Hmm
Trying to design the basic layout for a programming language is pretty difficult.
especially one that's easy for young children to write
And then trying to come up with a name is even more difficult
 
Name for a language?
 
Something memorable is hard to come up with
Meh, I might just use the placeholder name BLAH in these outlines for it.
 
2:52 AM
0
Q: What is wrong with this code to interpolate colours?

TonyI have written a module to choose a colour on a gradient between two other colours. The purpose is to aid in setting up styles for my trading platform. I don't have enough reputation to post all the links I would like to, sorry. Research (howaboutanorange.com/blog/2011/08/10/color_interpolatio...

 
3:29 AM
Code review is the right place for this "question". — Greg Kopff 56 secs ago
 
3:48 AM
@EthanBierlein Bah, you going to write BASIC--?
We don't need more kid languages, do we?
I know kids who write better Python than I do C#.
 
0
Q: Return inside switch best practice (JS)

MarcioLet's say the function below expects an attribute. It goes through the switch if it has one of the values in the switch everything is fine. If it goes to default it returns false which in this case stops the execution of the function. Is it considered good practice to return in the default? Is t...

 
Hardware, Software.
2 OSes.
2 Computers.
2 Programming Languages
1 Funk Button.
 
0
Q: Python3 Alarm Function

KryptosI'm trying to create an alarm function with Python3. The below code does work but it doesn't seem like this is the most optimal way of achieving something like this. Is there a more pythonic way? #!/usr/local/bin/python3 import os import time def alarm(): os.system('amixer -D pulse sset Ma...

0
Q: Getting Funky with pi

LegatoPush a button and an LED lights up1 and sends a signal to another computer that plays a song. First project on the Raspberry pi, really simple but definitely fun and educational to implement. Also, second time using python and sockets so I'd especially appreciate input on anything I do inefficie...

 
4:05 AM
Yay, just completed my first post on Code Review :-) : codereview.stackexchange.com/questions/95085/…
 
Welcome @KingCodeFish.
 
Hey @Legato :-)
 
Nice answer. I see you know @EthanBierlein?
 
The best first posts are answers. :)
 
Yes, I'm a friend of his off Khan Academy.
Let me find his
 
4:08 AM
You have a website too. :P
neat.
 
@Hosch250 How did you know though?
 
I've used Khan Academy just a bit, but I find my textbooks have more information.
@Legato Magic.
2 hours ago, by Ethan Bierlein
I know him from off-site, and he may be posting things.
;)
 
Yeah, I rarely use it for math because it can take a while to find a single answer. I'm more lenient to the CS section
 
I used the Economics section.
 
4:10 AM
Khan Academy has been a huge help for all things mathematics.
 
It was listed as a resource I was supposed to check out.
 
Just the videos can be so much better than my actual professors.
I've never checked out the CS section, maybe I should if you guys recommend it.
 
My professors are actually pretty good, but they could be so much better. I guess I'm just used to a customized education and self-working through the material.
 
Yeah, my latest game over there is called "A 1D Game". It can be found here: khanacademy.org/computer-programming/…
Yeah, in my opinion, Khan Academy is more helpful if you go through a subject as a whole.
 
When you are using college level textbooks, you don't really need to use it, in my experience. That is, if you understand the textbooks.
Some of my fellow students would do well to study there, but I've almost always liked reading textbooks.
 
4:13 AM
Yeah, that's true. I'm in 10th grade, so I'm not really sure about college lol. :P
I'm very fond of textbooks too.
 
(I'm a bit ashamed to say this, but that kind of started when I went through mid-life crisis around age 15...)
 
Oh lol. :P
Surprisingly, I'm the same age as Ethan.
Yeah, Legato, I saw your post 14 minutes ago. I wish I could help you, but I'm just starting to get acclimated with my Pi. :/
 
What is a Raspberry Pi?
 
raspberrypi.org Question is answered on the Home page
 
So, kind of like a completely open smart phone?
 
4:21 AM
Not really. It was actually intended to teach kids programming because it was super cheap, but still a whole computer. To this day many people have done thousands of DIY projects with it and used it as media centers, temperature controllers, etc. It runs Raspbian, a fork of the Debian distro of Linux.
Arduino is similar to it, but without the full OS. It's good for smaller projects that need a microcontroller and allows for basic input and commands.
 
Sounds interesting.
 
Yeah, I got mine with a kit that came with a Bluetooth and WiFi dongle. Sadly it took me forever to set up the drivers and get stuff working. Then I had Bluetooth connection issues, and instead found the Blueman GUI for the Bluez CLI library which fixed my issues and also came with a nice interface. So I guess a win-win for me. :-)
 
4:36 AM
Monking
 
4:51 AM
Ho
 
5:21 AM
0
Q: Finding geographical points in a circle

Omid HezavehI've written this code to read a list of clients including their coordinates, and then filter out those who are located more than 100 kms away. Please let me know what I could do better. var ClientsNearby = (function(){   'use strict';   var contacts = [],     dublinOffice = {       latit...

 
5:40 AM
0
Q: Finding clients in a 100 km circle

Omid HezavehI needed a node app that reads a list (text file format) from URL. Then parses the items on the list, name, longitude, latitude and finds names of the people who live maximum 100 kms away from a set location. Could you take a look and let me know what I could have done better here? var Client...

 
6:10 AM
@CaptainObvious duplicate of the one above it
 
6:21 AM
0
Q: Just a small program based on a physics concept

Aryan SrivastavaI am a beginner and I wanted to make programs that would help me while I learnt Java. I made a program to help me in my assignments. THE MAIN METHOD public class MirrorFormula { public static void main(String[] args) { Scanner keyboardInput = new Scanner(System.in); double u =0...

0
Q: Generating 3 combinations in Python

CodeYogiI have been experimenting around to generate all the n-combinations of an array. Below is the code to quickly generate all \$\text{k-combinations}\$ of a given array. I am testing my own implementation because of some restrictions in coding competitions (Also, knowing basics never hurts :)). """...

 
See below:
 
0
Q: Genetic Drift Simulator - Follow Up

QuillThis question is a follow-up of a previous question of mine: Genetic Drift Simulator. Following the advice given in the last question, and some more general improvements, the code has been slimmed down a bit. The major one was implementing Underscore.js, which slimmed down a few of the loops int...

0
Q: SQLiteDatabase. Opening, Closing, and when to access concurrently?

VictorWhen I make an app using SQLite for local storage I've settled into a nice routine. Create a contract class and a extended BaseColumns class to hold column names and the functions for my all my CRUD db access needs. And of course extend SQLiteOpenHelper and with all of the create table and drop t...

 
7:27 AM
0
Q: Game code optimisation advice

MessyMasseyStudiosHi I'm wondering whether anybody would be willing to review this code for a game I'm working on with my friends. I feel quite confident with python but am wondering whether there are some places that it could be made more efficient or errors I haven't spotted. Github link for the repo is here. Th...

 
monking!
 
monking
 
hey @Quill havent seen you around in a while
hows it going
 
good thanks. just got off holiday
a bit exhausted from it. first time in a country fluently speaking another language
 
nice :) what language?
 
7:30 AM
Japanese.
 
oh christ, visual studio crashed trying to compile.. booted it back up again, compiled.. crash.
oh wow. my 16 year old self is envious
 
@CaptainObvious off-topic for code not included
I've been getting back into the coding swing of things with a nice little bio-related simulator too, which is fun
 
a what now?
 
Simulates Genetic Drift
 
7:53 AM
@KingCodeFish omitting braces {} although they might be optional can lead to serious bugs. Sure anybody can have his/her style but has live with the consequences too.
 
Ah yes
Should I remove it
 
I would remove it
 
Its up to you. Basically code review is somehow opinion based.
 
Alright, day-to-day I hear a ton of people talk about it. Not sure why
 
@KingCodeFish because of this:
    if(foo)
      return true

    if(foo) {
      return true
    }
less-smart js interpreters could place a ; after the if
 
7:54 AM
the apple ssl bug referencing errytime
 
also, if you fail on your indentation, you'll end up seeing this....
if(foo)
return true
and you might not catch that you'll return true when you scan the code
 
elif direction.lower() == 's' and room[roomnumber]['directions'][direction.lower()]:
    roomnumberint -= 1000
    roomnumber = str(roomnumberint)
elif direction.lower() == 'e' and room[roomnumber]['directions'][direction.lower()]:
    roomnumberint += 10
    roomnumber = str(roomnumberint)
elif direction.lower() == 'w' and room[roomnumber]['directions'][direction.lower()]:
    roomnumberint -= 10
    roomnumber = str(roomnumberint)
well jesus
K. I've added the code in. — MessyMasseyStudios 3 mins ago
those with close votes, feel free to remove them now
 
K, edited.
Not sure why I added it as I never use them myself
I never use omitted curly braces, man that sounded whack.
 
elem.outerHTML.match(/^<[^>]+>/m)[0]
regex and html don't mix ;-;
 
RegEx issue I see
I'm an avid user of Khan Academy CS and just wrote this recently: bit.ly/1jUGyDc I feel ya bud. :)
 
8:01 AM
@KingCodeFish is there no way to space that post out more/
looks like it could use some line breaks
(on KA)
 
Yeah, it probably could lol. I was typing as fast as I could.
Bit better now?
 
signiifcantly better
 
Yep, I thought so.
The long answer I wrote before that can be found here: bit.ly/1M2HOyT
 
Zak
morning all
 
Hey o/
For some reason I feel satisfied so much after writing a long answer. :)
Alright I'll see you guys. Bye o/
 
8:47 AM
0
Q: Custom wrapper for none angular

AndersI must admit, I'm not a fan or expert on Angular. I created a little wrapper for one of my JavaScript libraries to enable angular functionality. Any pitfalls I should be ware of with my code? angular.module("signalR.eventAggregator", []) .run([ "$rootScope", function($rootScope) { ...

 
Zak
> This question has an open bounty worth +150 reputation from Ismael Miguel ending in 7 days. Thank you!
 
@Zak link?
 
Zak
10
Q: Template UserForm Input - launch, input, validation, error handling

ZakI'm building a template [Process-Tracker] spreadsheet. The idea is that, for any process where we can define what steps should occur in what order (and preferably, how far apart), there will be a spreadsheet with buttons for: Adding a new [Item] to be tracked Updating the List of [Items] an...

 
9:13 AM
0
Q: Removing listeners for a notifications manager class

Running TurtleAssuming a NotificationsManager class that contains a Dictionary: public class NotificationsManager { Dictionary<string, List<Component>> listeners = new Dictionary<string, List<Component>>(); } I want to implement a public function to remove listeners as follows: public void RemoveListen...

 
@CaptainObvious appears broken/code not yet written - second opinion please?
 
@ARedHerring It doesn't appear to be broken, but I could understand the code not written.
It's a design question.
 
I said broken because:
> Is there anything wrong with my implementation ?
but yes, in retrospect, seems to be a design question.
I've VTC as code-not-written either way.
 
Aug 26 at 15:23, by Ismael Miguel
@Mast No. I promised I'll never do that again. Last time I gave a bounty of 100 and it was completely wasted. So, no, no more bounties from me
2
 
@Mast lol
 
9:22 AM
12 hours ago, by Ismael Miguel
Where shall I place the bounty?
2
 
nailed it.
 
Zak
@mast ❤
 
0
Q: Sharing data between C/C++ and other languages

MarcelLet's say I have an application (written in either C, C++, Fortran, or Python) which essentially works as follows: // Initialization: Setup data structure // Repeatedly work on data structure for (int k = 0; k < kmax; k++) { // Solve equations and store results in data structure } // Final...

0
Q: For loop step including last value

HeuerI've got the following code. I want to loop through my dataset (which is a matrix) in steps of let's say 50.000 and perform biglm on it. lengthdata <- 100340 stepsize <- 50000 for (i in seq(1, lengthdata, stepsize)){ if(i+stepsize > lengthdata){ ## call function (i, lengthdata) pri...

 
9:45 AM
Monkinh
 
Monking @SuperBiasedMan
 
Monking
 
9:59 AM
0
Q: Generate all available numbers for pattern, shuffle and save to multiple files

MisiuI've build simple application that allows me to generate all numbers that have desired length and start with prefix. For example if I specify 12 as prefix and set desired length to 4 it will generate numbers from 1200 to 1299. I'm storing all generated numbers in List<int> then using shuffe metho...

 
Any basic information I could provide to make my answer better?
3
A: Game code optimisation advice

MastWhile reading your code I had one thought coming over and over: Get yourself acquainted with Object-Oriented Programming. Python allows you to build your own classes. Use that to your advantage. Why? It will remove constructions like: def movefunc(direction): global roomnumberint glo...

 
I'm actually working on an answer to that too, but if you have time maybe explain what global actually does or link to some resource about it.
global is a demon child keyword.
 
Yea, I could expand on why global doesn't do what he thinks it does.
 
there's nothing inherently wrong with keeping state in functions (functional programming)
However using global is evil
maybe you could explain that?
 
@ARedHerring Except being highly impractical for a game in Python.
I'm on it.
 
10:13 AM
@Mast Why is that?
Games in Python composed of classes will use functions and state much the same way that games composed with just functions will
all classes are are groupings of state and functions that can be inherited
 
Extensibility.
 
This is how an entity component system works
And they are very extensible :p
 
Hmmm, would that work in Python, ECS?
You could make that an answer on it's own.
 
No idea. I don't use Python.
I'm just not sure why its not feasible in Python
In C# and Java I could understand because everything there has to be a class
 
I'm not sure if I'm missing something here, but how would you actually have persistent values in the functions in a clean way? There are mildly hacky ways to do it, but they're not great.
 
10:16 AM
@SuperBiasedMan closures
 
Well in Python everything is a class in the end, including functions and integers.
 
i mean, a constructor is essentially a function
function player({name, health}) {

  return {
    function setHealth(newHealth) {
      health = newHealth
    }
  }
}

const dan = player({ name: 'Dan', health: 100 })
dan.setHealth(5)
in ECS, though, you would instead not store data in functions at all, you'd just have pure functions that data passes through
 
In general optimization questions don't fit to stackoverflow but to codereview. — Tim Schmelter 22 secs ago
 
function world (systems) {
  let components = []
  function tick () {
    components = systems.map((system) => system.update(components))
  }

  return { tick }
}

const healthSystem = function (components) {
  ...
}

const w = world([healthSystem])
w.tick()
w.tick()
w.tick()
ECS example
(very bare bones)
 
I think this question belongs to codereview.stackexchange.com — Francesco Casula 45 secs ago
 
10:20 AM
I have heard much of closures but I don't know them so I've stuck that in a to read tab
 
Closures often come in handy, just don't overuse them or you'll regret it.
 
i'm not sure of the overhead they have in python but they are pretty mandatory in javascript, we use them all the time
 
In JS-like languages they're especially useful.
Has something to do with the async nature of JS I think, not sure about that.
 
No, its because its a functional concept
its also to do with the fact that classes only really came about recently..
we've had the prototype chain but its annoying to assign to
and again, closures make a lot of sense in a lot of cases
 
Prototypes can be abused quite easily.
 
10:25 AM
Yeah
 
Did it once, quite fun for a while.
 
The prototype chain also sucks quite a bit because if you try and find something in the prototype chain and its not at the first level
javascript will check allllll the way up the prototype chain until it reaches Object before telling you whether or not something is missing
 
Yeah I'm looking up examples, it's funny because Python has it sort of the opposite way around (or at least that's how my brain reads it)
One Python example is about passing a function into the nested function instead of a parameter from outside the nested function being preserved.
 
ooh, that's interesting
 
Zak
I am on fire! this morning. The code is flowing and it's working and it's continuously refactoring and it feels awesome :)
 
10:32 AM
 
@Zak nice :-)
 
0
Q: How can this decoding string algorithm can be optimized?

markovcdI'm trying to solve this challenge on CodeEval. Quoting: For example, you can put pieces together and get the original text: evil pl vil pla il plan The answer is ‘evil plan’. Your task is to print out the original text. Due to repetitions in the text, you will sometimes get iden...

 
Monkingg
 
10:48 AM
0
Q: Merging two sorted linked lists C++

Nash VailRoutine to merge two linked lists together and return a new merged list. One optimization I can think of is passing by reference instead of value. Any other suggestions ? Is there a shorthand to make lines 4 and 5 single/shorter? template<class t> Linkedlist<t> merge(Linkedlist<t> firstList, Lin...

 
thats a new one
VS crashed whilst it was loading
 
Expanded a little on my answer.
 
@Mast Looks good. Hopefully it can scare them off using global
 
Hope so.
 
Zak
11:30 AM
promoting this as worthy of more upvotes:
2
A: Template UserForm Input - launch, input, validation, error handling

HeslacherYou have added logic to an event of a button, which is not the best choice. You should extract most of the logic to at least separate methods or much better to a separate class. First let us take a look at this Private Sub ValidateValues(ByRef values As Collection, ByRef validationMessage ...

 
sorry @rolfl, my skills weren't enough (LOL)
 
@Zak Why delete your selfie on there?
 
Your skiils were ^^
@SuperBiasedMan It has been noted in chat a while back, can't remember.
 
Ah, ok then. I saw an undelete vote on it and wasn't sure if Zak had been told about it.
 
1
Q: Usage of 'obsolete' modifier in the title on CR-meta

NanneThis question drew my eye today: *OBSOLETE* Iterative code reviews: how can they happen successfully? *OBSOLETE* and I found out there are several other questions with the *OBSOLETE* modifier (for lack of a better word) in the title ont CR-meta. This surprised me, as I have never seen this on ...

 
Zak
11:42 AM
@SuperBiasedMan It should have just been a code edit, so once it became clear that no-one was in the middle of writing an answer, I deleted it and edited the code accordingly.
I wasn't aware of the undelete vote
 
11:53 AM
Ah, that makes sense. I didn't think to check if you'd changed the question itself.
 
1
Q: TCP Client Class implementation in C#

quserI tried to implement following class which should handle connecting to a server, as well as sending and receiving data. Your feedback is welcome. Please note I am beginner in .NET and don't give too advanced feedback. I tested it and it seems to work. So in case you see some major problems pleas...

 
12:38 PM
@chiastic-security :) :) :) If it weren't for that little twist, the whole question would be a great candidate for migration to codereview.stackexchange.com. — dasblinkenlight 53 secs ago
 
@ARedHerring My Visual Studio is all better now.
 
Well, it's still Visual Studio, so I don't know about all better...
4
 
@nhgrif Well, the major issues I had are no longer issues. I suppose that's a good start.
 
@CaptainObvious Watch it with that question. OP is known to have a temper.
 
@Mast I was just writing up an answer for it, thanks for the warning.
 
12:52 PM
-2
Q: Converting Roman numerals to decimal without conditionals

CassandraI couldn't find an answer to this question. here is my code so far: s = "MDCLXVI" n = eval(input("Enter the Roman numeral value: ")) pos = n total = 0 roman = s[pos:pos+1] for n in range(s): total = roman I know it's not finished but I have no idea what to do. I can't use...

0
Q: Media Queries Iphone 6

user1087110Why doesn't this code cover Iphone 6? @media (max-width: 599px), (max-width: 640px) and (max-height: 400px), (max-width: 767px) and (orientation: landscape){ /*My code*/ } See menu on: www.hakanbenjaminsson.se

 
@CaptainObvious Nuke it, off-topic.
 
Well that's one answer for the day down.
My work here is done.
 
@CaptainObvious CTV broken
 
@CaptainObvious Spam-flagged it.
 
@Mast Why spam?
 
1:04 PM
i don't think this is spam
I think he is just providing an example
i can see why you would think it is spam
removed for spam, RIP
 
do you see any other issues with my class? (also it seems you ignored other functions in class but I assume they should be there) — quser 38 secs ago
Obvious beginner and help vampire.
 
@EBrown At least he found the by himself.
 
not sure what the issue is with being a beginner
 
@ARedHerring The issue is with the help vampire part.
 
@ARedHerring ^^^
I don't mind helping beginners at all, but I don't have time to spoon-feed him/her.
3
 
1:11 PM
Just ignore him for the next 30 minutes and see what happens.
 
@Mast Well I'm editing the answer with the other feedback I wanted to mention.
 
0
Q: Randomly Generate Planets

SuperBiasedManThis is code I'm writing for an android game where I want to be able to randomly generate small planet sprites. It seems like the best way to do this is to have a set of small PNG textures that can be layered onto each other. I found code for recolouring a drawable programmatically here that was ...

 
Answer by a brand-new user:
0
A: TCP Client Class implementation in C#

JD.BSeems pretty solid, but there are some style things that I would personally change. In public void WriteBytes(byte[] data, int length) { ... } and public void ReadAllBytes(byte[] buffer, int length) { ... } there doesn't seem to be a need for the length parameter. This would get rid of the...

 
Your answer looks pretty solid as well
3
A: TCP Client Class implementation in C#

EBrownIt looks like you should be implementing IDisposable here. See on MSDN. Then, in your Dispose(bool) method, you can call CloseDppClient (or, better yet, do them the other way around and call Dispose() from your CloseDppClient method). You should also be putting explicit access modifiers on your...

 
I just added more to it, but I'd rather pimp that new user's answer. (I'll take a loss if it means we get a new, good user.)
 
1:20 PM
His is at +3 now as well, that's fairly good for a new user.
+4
 
Very nice.
 
Zak
Upvotes for all of you ^^
 
Thanks not so secret Santa!
 
1:32 PM
Someone flag this as obsolete please?
And this too.
Anyway, that's done now.
apart form dispose I think your comments are mainly stylistic? — quser 3 mins ago
Anyone wish to (kindly) tell him that's not the case?
 
Well he's not wrong..
braces, access modifiers and naming conventions are stylistic
 
"Mainly"
Is the wrong part.
 
Who cares? Improvement is improvement, regardless of their category.
 
1:47 PM
I think my debugger is borked.
Visual Studio won't launch this programme.
But only this one programme...wth.
 
I've never seen so many problems in one version. Older versions worked quite well.
 
Yeah, I am not at all impressed.
PC just needed a reboot.
 
2:05 PM
@quser by asking this community feedback on your code, you agree to welcome comments about any & all aspects of your code. Programming is 20% writing and 80% reading code; readability cannot be understated if you want to write maintainable code. — Mat's Mug ♦ 15 secs ago
Monking!
 
Monking @Mat'sMug. :)
My SO Careers profile (as well as my linked in) need some serious help.
I need to get some of these damn projects off my desk.
 
0
Q: Refactored to use polymorphism in place of case statements

derek kenneypublic bool RunNextJob() { // Return true if we found a job to run DeferredJob dJob = _jobRepository.GetNextJob(); SessionProvider sessionProvider = ObjectFactory.GetInstance<SessionProvider>(); if(dJob != null) { Logger.Info(string.Format...

 
2:20 PM
I hate it when I'm right...
 
@Mat'sMug That user seems to expect too much.
 
Who's good at Python?
Also, hey everybody.
 
Zak
@Mat'sMug: I see but author of answer should clearly point out which is functional problem which the author solved (and was not working in my question) and which is readability problem he/she improved — quser 15 mins ago
Some people are never satisfied
 
@Legato Define 'good'
And hi!
 
Ah, lol, well better than me cause I'm a total noob.
 
2:33 PM
@Tushar thanks for the code review. Lazy answer by me - you made it better! — Jamiec 53 secs ago
 
@SuperBiasedMan can't run this till I get home, but wondering if this is what was meant/would it work? ideone.com/0nWGKO
 
@Legato You mean the if __name__ == "__main__"?
 
Yes, I'm not sure if the scope would work too.
For the main function
 
0
Q: HTML Voting poll with html to wix.com

rafacardosocI created my website on wix.com and ​I would like to have a poll on it that would let the customer add their own votes. BECAUSE it's on wix, all this has to be done in HTML i believe. let me explain a little: The poll is for them to vote WHAT CITY we should go next with our Workshop. I wanted ...

 
This feels like a better fit for codereview.stackexchange.com. One comment though - broadcasting/multicasting to subscribers is far more efficient than iteratively messaging each one in turn (as you mention in your opening paragraph). Round-robin appraches don't tend to scale very well. — Daniel Kelley 8 secs ago
If you are solely asking how to improve your code, maybe check out the Code Review stack — Thomas Wagenaar 16 secs ago
 
2:40 PM
Well yes the name == main works, and actually I was going to say you could move the variables further out of scope if you wanted, haha.
Python's scope is very permissive. It keeps searching outwards when it needs to read a value, so you don't even need the sent button and led values to be in the if block.
Short answer: Yes it'll run.
 
This question is more suited at codereview.stackexchange.comSteven 40 secs ago
 
0
Q: Is this a correct usage of inheritance?

derek kenneyI had a job interview take home test where I was asked a series of questions on object inheritance. In addition to answering the questions, I created the following application to demonstrate inheritance among different objects. The first piece of code are different shape classes. Some inherit fr...

 
Zak
Is this not still hypothetical/example code?
 
2:55 PM
@Zak Yes, in my opinion it is.
 Quill reviewed this 47 mins ago: Reopen
sunny reviewed this 54 mins ago: Reopen
Ethan Bierlein reviewed this 2 hours ago: Edit and Reopen
paritosh reviewed this 2 hours ago: Reopen
Mast reviewed this 3 hours ago: Leave Closed
And I stand by my decision.
 
Zak
I agree with you. I just saw the 4 reopen votes and figured I'd get a second opinion first since I'm not very familiar with the language.
 

« first day (892 days earlier)      last day (3129 days later) »