« first day (799 days earlier)      last day (3211 days later) » 

3:00 PM
It is essentially treating yield in a unique way - I tried converting the code to Es6 to see if it would work, but the code printed 'undefined' (as expected)
 
@DanPantry seriously worse than not knowing why your code doesn't work.
 
That leads me to think that SpiderMonkey versions 18 through 24 had people experimenting on yield, which makes sense, because yield was not defined in the ES5 spec and was therefore undefined behaviour
In the same way that dereferencing a null pointer might work fine, or might just burn your house down
 
I'm curious, that maybe I should have it return a State that I use to make what changes need to the server? — EBrown 1 min ago
Maybe @EBrown.
 
@RubberDuck That was about the only extensible solution I could come up with, I'm not phenomenally great at doing programme design.
 
@EBrown I would personally recommend treating 'messages' as just bags of data and having an interface consume those messages to do something with them.
interface IMessageHandler<T> { void DoSomethingWithMessage(T t); }
I think having the message contain its own structure and know how to handle itself seems a bit.. messy
 
3:03 PM
I suppose I could go that route.
 
It already knows how to serialize and deserialize itself from a stream
 
especially since you need to handle the message to know how it needs to be handled...
 
Indeed.
 
and it's quite the overhead..
 
Having the message know how to deserialize/serialize itself is fine
that should be there because it's shared behaviour for that specific type of message.
However, how the message is handled is implementation specific
 
3:04 PM
Well, all this code is shared between the Client/Server.
 
@Vogel612 that's a good point. Maybe it just gets directly handled in the DataMessageHandler instead of returning an adapted type at all.
 
@EBrown that just furthers my point.
Let the message know how to serialize, and deserliaze, itself, that's fine
But place the processing logic somewhere else
Also, a huge switch statement to switch on an enum based on packet types is only going to cause you pain
as our lovable bath friend @RubberDuck said, that's what polymorphism is for
 
> lovable bath friend
Man that sounds dirty @DanPantry.
 
So in this case, where would I move each relative bit to?
 
@RubberDuck I get it. Baths. dirty
2
 
3:07 PM
(It's still quite early, haven't completely woken up.)
 
@EBrown no idea, i'm trying to wrap my head around that. I'm not entirely sure how you would translate abstract data packet -> processing logic
You could potentially use an event for that, and then have packet handlers only listen for a certain event
That way you don't have a monolithic switch statement, and each message handler is only informed about the message they want
 
usually you have some "message type"
and then process depending on the type.
 
The problem is in the interface me thinks. You need to pass each Process method the same args, but each implementation will need something different.
 
then you got a problem...
 
@RubberDuck Basically. Some of them won't do anything with some of the objects.
 
3:09 PM
So, maybe passing through somekind of state object would be a good solution.
 
and you need a container
 
@RubberDuck this. This is why I suggested that having the packet know how to handle itself is bad.
I don't know.
You could potentially do something like
er... give me a few minutes
 
message.Process(state);
Then it doesn't really matter if it needs it or not, it gets it.
 
If I made a state that only contained updates, then I could merge it with the actual object states at the end.
The problem is, that the Client won't have/need the same state.
 
wat..
 
3:12 PM
The stuff in the State, between server and client can differ, on purpose.
 
meh... the message isn't supposed to care
 
// Implementations define what they need in their constructor
interface IMessageHandler<T> where T: IMessage {
  Task Process<T>(T message);
}

// The POCO
interface IMessage {
  string Name { get; }
}

// When server receives a message, it publishes an even
// Then somewhere you need to have the message handler do something like
//
server.On("Foo", new MyMessageHandler<FooMessage>());

class MyMessageHandler<FooMessage> : IMessage<FooMessage> {
  MyMessageHandler(PlayerService playerService) {
 
the server is the single authority, the client gets updated by the server and that's it
 
0
Q: Find Longest lines from a file

SteephenThis is a challenge question from codeeval.com Write a program which reads a file and prints to stdout the specified number of the longest lines that are sorted based on their length in descending order. Input sample: Your program should accept a path to a file as its first argument....

 
sorry for line numbers, direct C+P from vim
 
3:13 PM
edit them out then??
 
@RubberDuck How's your introduction into microprocessors going so far?
 
Didn't know how to
There
 
@Mast I decided to take Amtel Studio's simulator for a spin. Just got it up and running.
 
Atmel is a big company, first uC I got started with was an Atmel.
So if you get the hang of it with their simulator, you're well on your way.
 
So, as it stands now, my IDataMessage interface would need an additional Process(ServerConfiguration config, ServerState state) method. Which each of those parameters would have some effect on how it processed the messages.
 
3:21 PM
This has now been posted to codereview.SE and should be deleted from SO. — Paul R just now
 
The IDataMessage HandleMessage(NetIncomingMessage message) would still need that large switch statement, so that it could build the proper messages. But the ProcessDataMessage(NetIncomingMessage message) would not need one. It would just call messageResult.Process(config, state).
 
@EBrown IDataMessage should not know how to process itself.
Publish an event that can be listened to that is raised every time a message has been decoded from the input stream.
Have handlers listen to this and determine themselves what they want to listen to.
 
There we go ^
 
Those handlers can request the information they require via constructor injection.
 
So, LoginMessageReceived?
Etc?
 
3:25 PM
you could use that.
Or you could just use MessageReceived.
And have the handlers decide what messages they want to listen to.
 
Yeah. Similar to how Windows listens for messages.
 
It's up to you. LoginMessageReceived is less backwards compatible than MessageReceived because you would need to add a new event for every message received
You would IMO quickly get a monolith with that pattern.
MessageReceived allows you to not do that, however it might make following the code a bit harder.
 
And how would you suggest I limit the types to watch for? The DataMessageType Type property I already have?
 
Eh. I'd still kill that and use typeof instead.
 
In JavaScript we'd listen on a name property or similar
I don't like the idea of typeof but I like the Type property much less
 
3:28 PM
@RubberDuck I could use the object is type idea, and make a few more interfaces for various types to check for.
 
Take the approach that makes the most sense to you
You can avoid doing all of that with more layers of indirection, but then that complicates the problem
 
Oh no @Mast. Now I have to figure out what board I want to simulate... it's just a bunch of serial numbers... lol
 
I would say for now you could just do something as simple as
   public void MessageReceived(IMessage message) {
     if(!message is FooMessage) {
       return;
     }
  }
and hook that method up to an event
there's no real 'nice' way to do this unfortunately
 
@RubberDuck What are your options?
 
That's the problem, I've been searching for a good way to do something that hasn't one...lol
 
3:30 PM
All of them.
 
Pick something with an ATmega on it, those can handle pretty much anything you throw at them.
Ah, good pick I guess.
 
I.e., LoginChangeMessageReceived, etc. Where that would handle Login, LoginCredentialsUpdate, etc.
 
I don't think it would be wise to have a multicast event like that.
Either have an event broadcast all types of messages
Or have one event per message
 
@RubberDuck Can those be programmed with C++ nowadays?
 
don't try and lump the events together like that or it will just get confusing (because then you start to wonder where you draw the boundaries)
 
3:32 PM
I thought that series was still C style, but the programmer is probably converting it anyway...
 
Well my main concern is that I don't want a massive block of code that I cannot break up.
So, if I made them events, I could drop each method to handle each event into it's own class somewhere.
 
You are aware that a massive list of events is going to be a massive block of code that you cannot move, right? ;-)
you can handle each event in their own class regardless of whether you have an event that publishes every message or one event per message, that's moot
 
Yes, but it's more extensible than one event with a massive amount of work to check for. :P
 
I wouldn't necessarily say so..
In your approach you have to add your event listener to a specific event on a class
in mine, you have to check whether the message you are given is something you can handle
You have to bear in mind i'm approaching this from a javascript perspective where this exact pattern is used in Flux
I've seen most people go your approach in C# though, and that's why I said I reckon you should just go with what you think is best
As long as your tests pass the implementation doesn't matter until it starts to leak memory/performance like a sieve
 
@Mast yeah. C++ is an option.
 
3:37 PM
this library may also be of interest to you
 
Well, if I were doing events I would prefer to make many events that are verbose of their meaning, than one event and having to wonder which method implements which portions of that event.
 
@EBrown yeah, that is the downside of the approach I suggested (and one of the criticisms levied against Flux)
My approach will likely only work if you architect your application like Flux.
Also, I really do hate C# lol
No, that's a lie, I hate Visual Studio
 
I wonder how bad my wife would flip if I printed this 250 page manual.....
 
Print it to a tablet.
"print"
 
@RubberDuck I have a Laser Printer at home just for that. Lol
 
3:52 PM
@RubberDuck Try printing a protocol specification ^^
Bluetooth 4.0 is what, 2k pages?
 
No thanks.
 
Wi-Fi must have at least 2.5k on the latest revision.
 
Okay, so now I guess I just need to figure out how to actually set a register....
 
What are you doing?
 
@RubberDuck It's not that different from a variable.
 
3:53 PM
@Mast Have you ever looked at the Intel CPU Architecture Specifications?
 
PORTC = something
That's for writing entire output sides, but register values also work.
@EBrown Probably even bigger?
 
@Mast I have the PDF's here on my PC, let me find them.
 
The spec of the ATmega 328 is exactly 555 pages if I recall.
 
Oh, and the US Revised Code is 75K Pages, by the way.
@Mast The Intel Architectures Software Developer's Manual (Volumes 1, 2A, 2B, 2C, 3A, 3B and 3C) is 3429 pages.
 
Darn.
 
3:59 PM
:22722928
user image
3
 
@DanPantry No truer words.
 
holy carp it built.
 
Concerning the event stuff... what about a Chain of Responsibility!
 
Chain of Responsibility?
 
It's a pattern in programming
 
4:07 PM
You'll have to be more descriptive.
 
It looks (slightly) like this
function chain(input, next) {
  // do something with input
  if(next) return next(input);
}
In object-oriented design, the chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing objects to the end of this chain. In a variation of the standard chain-of-responsibility model, some handlers may act as dispatchers, capable of sending commands out in a variety of directions, forming a tree of responsibility...
 
I see, I suppose it could be applied here.
 
0
Q: What is the complexity of this code

geeksoulThis is prim's implementation! Indeed this is very complex and slow and a better version is here but I still want to know the time complexity of below code. You can check the same code here too nice colors and indentation #include <bits/stdc++.h> using namespace std; const int size = 12345; i...

0
Q: Implement Cartesian Product of Collections by Java 8

stanleyerrorRight now I can only implement the Cartesian Product of two collections, here is the code: public static <T1, T2> Collection<Pair<T1, T2>> getCartesianProduct( Collection<T1> c1, Collection<T2> c2, Collector<Pair<T1, T2>, ?, Collection<Pair<T1, T2>>> collector) { return c1.st...

0
Q: Nodejs and circular dependencies

kbariotisI have created three layers on an Express based REST API. The first layer is Express Controllers that are basically functions that accepts req, res, next. Those controllers are always dealing with the next layer which is the Services. Services are wrappers around Mongoose models and provides ba...

 
I'm going to go see about implementing some of these suggestions to this code, I'll be back later in any case.
 
0
Q: How can I solve key error in my code?

marysdThe aim of this code is to produce dictionaries of probabilities of words given tags(called emit here in my code) and tags given tags (called trans in my code) and each dictionary and also the tags which were used in the corpus are saved in separate files. But there's a key error and also there i...

 
4:25 PM
@CaptainObvious Removed already?
 
Has anyone ventured into the depths of using CUDA on the host GPU in an Ubuntu VM?
 
CUDA in a VM?
I wrote one CUDA 'Hello World' application once, but that was on the native OS (Win7)
 
Yeah ^^
This application about Recurrent Neural Networks can be ran either on CPU or GPU, CPU works but is obviously lots slower
 
0
Q: Analying complexity of an implementation of Prim's algorithm

geeksoulThis is a Prim's implementation! Indeed this is very complex and slow and a better version is here but I still want to know the time complexity of below code. You can check the same code here too nice colors and indentation #include <bits/stdc++.h> using namespace std; const int size = 12345;...

This doesn't seem to be an on-topic question
But I don't know which reason it fits under
 
@jacwah It's migrated.
 
4:33 PM
0
Q: Script to create a customized, efficient adblocking hosts file

amt528I am writing a Python script that creates a customized, efficient adblocking hosts file. Basically it checks the user's DNS cache and sees if any entries there are listed in the popular hosts files. If so, it adds those entries to the user's hosts file. The purpose is to keep the hosts file sm...

 
@Mast Oh I recieved it in my review queue
Nevermind then
 
Morning
 
Afternoon
 
Greetings
 
Hi all
 
4:37 PM
howdy
 
Someone sent me an email critiquing a patch I submitted and closed it off with "Thanks,"
That sounds so arrogant to me
But I'm not a native speaker
 
It is arrogant
Who sent it is using sarcasm
 
Are there any Python programmers in here besides me?
 
@EthanBierlein I know python!
 
@jacwah Okay. Would you happen to know whether it's better to use for loops over a rather lengthy generator expression?
 
4:44 PM
@EthanBierlein I would, if it simplifies your code
But I'm not an expert... Maybe post for review :)
 
Mkay.
Meh. The for loops would be much clearer and easier to understand.
 
I wouldn't, depending on how much you want to generate
 
:( My RNN started so promising
"text":"Deal $1 damage to a minion. If that kills it, dhagg of the borent he pen.",
2
 
If it is to generate over (say) 100 elements, I would use a generator
If it is to generate something small, a for loop is alright
@skiwi What are you trying to do?
 
@IsmaelMiguel Train a neural network, you feed it input data of existing things (HearthStone cards in my case), and then it generates random samples
 
4:48 PM
@jacwah I'm glad to see that we agree.
 
Oh god. There's a question coming. RUN
 
So... in theory I could make a bot, feed him text from The 2nd Monitor as input data, and let him say something every once in a while, and it would still make sense
As it "counts occurrences" it will often say "PHP is crap" and very often say "Java is crap"
2
 
I think you can get help from here: codereview.stackexchange.comManoj Kumar 8 secs ago
 
0
Q: Given a linked list of line segments, remove middle points

Jaspinde VirdeeThis code removes any middle point find in line. It works only in x and y axis. This problem is JAVA implementation of http://www.geeksforgeeks.org/given-linked-list-line-segments-remove-middle-points/ package com.atleyvirdee.myDataStructures.linkedlist.problems; import com.atleyvirdee.myDataS...

 
Sounds dificult
But hey, who am I to say anything?
 
4:55 PM
@CaptainObvious JAVA!
 
If you seem to get good results, keep on going
 
@CaptainObvious hiss hiss
 
As manoj said, this is better suited for codereview — Tivie 1 min ago
 
@EthanBierlein I think that SirPython should be the one saying that
 
@IsmaelMiguel Okay, how about: ROAR ROAR
 
5:01 PM
That better, way better
Or we could go over-dramatic:
 
@skiwi I hate JavaScript
 
? NOOOOO!!!!!!!
 
Or what about:
I will hunt the until the day I die...
 
0
Q: Please help me clean this mess up

William CrutchleyPlease could someone help me with cleaning all this code up... and making sure everything I have done is as efficient as possible? There is just a menu-bar at the top of the page... and image in the background with a title over the top of sed image. The menu is dropdown when you hover over "HOME"...

 
@EthanBierlein clearer and easier to read wins hands down
 
5:04 PM
That yes ^^
 
But I don't get what's so bad about linked lists...
 
@IsmaelMiguel me neither
 
@CaptainObvious That's some ugly, not properly indented, hacked-together HTML.
 
@Mast Isn't all HTML like that?
 
Holy crap I'm flipping bits on an imaginary processor....
 
5:06 PM
@RubberDuck :D
Congrats!
 
@RubberDuck I did that in class last fall.
 
19
A: What's a Zombie? And what are the many other memes of Code Review?

JamalMeme: Yet another linked-list (also nooooooooo) Originator: skiwi Cultural Height: The apparent popularity of linked list implementations Background: The site has received a lot of linked list questions with more coming in over time. It has also led to many duplicate titles and even some dupl...

 
Only, on a real Altera processor thing.
 
This is seriously the coolest thing I've ever done with a computer.
 
Well, the HTML isn't that clean, but it doesn't even have a doctype.
 
5:07 PM
Now I need to go buy an actual board and make an LED blink! =D
 
@RubberDuck Are you using C?
 
@Hosch250 Altera microprocessor? Only used there FPGAs.
 
Yeah.
 
@Mast Similar, only a different one.
 
Hmm. I think I should get back into VHDL.
 
5:08 PM
That is actually more interesting than the typical linked list question.
 
I don't remember the actual model, but the FPGA's were listed on the related products slip.
 
@RubberDuck Get a cheap uC with basic pin-out for 10 bucks, drop it in a prototype board and put on the LEDs yourself.
 
Can somebody explain to me exactly what this does though?
(1<<PB0)
 
@RubberDuck Bitshifting!
 
I understand it's shifting bits, but... I can't picture what it's doing.
 
5:09 PM
2 to the power of PB0
4
 
Thanks @200!
 
That ^^
 
Shifting left by one position is multiplying by 2. Shifting right is dividing by 2, with truncation.
 
@EthanBierlein Would be great to have more people around into that.
 
5:11 PM
Oh oh oh! Okay!
That makes perfect sense.
01 << ? == 10
01 << 1 == 10
right?
 
May 2 at 16:12, by Mast
If people learn LOLCODE just for kicks, we should empower people to learn VHDL instead...
2
 
Left shift one place?
 
@EthanBierlein I remember that was pinned for a while.
I also remember sending you some VHDL books in PDF.
 
Mhm. Still have them too!
 
I still have some of those if anyone is interested. FPGAs are perfect for Digital Signal Processing.
 
5:14 PM
@Vogel612 The question about the translations DB?
(monking all)
 
1 << 1 is 2.
 
They're also often combined with ARM processors nowadays.
 
Welp. I just started downloading modelsim. I better crack open free-range VHDL again.
 
0
Q: A Range object for Java that partially implements `List`

CarcigenicateI'm writing a neural net which uses a genetic algorithm to adjust the weights. To represent possible range of "genes" for the GA, I'm passing in a list of bases. Unfortunately, I realized after the fact that there will be a huge possible range of weights for the net, and storing a list of all pos...

 
Yeah. Okay. I think I get it now.
 
5:27 PM
It is impossible for me to reproduce your problem unless you either give me a link to your entire code base, which means you should probably post your question to code review, or you reduce your problem with the simplest piece of code possible to reproduce the issue you are having. Again, I'll link this article for helpful information on this. — John Carpenter 39 secs ago
@JohnCarpenter This question would be off-topic for Code Review. — Mast 18 secs ago
 
@Phrancis yep exactly
I think you can find some more stuff in there :D
 
@Vogel612 Maybe, but that stuff becomes irrelevant with your idea... Heck I didn't even know you could do that, that's a cool way to do it
 
I wasn't sure about selecting the expression as value, though..
 
Paging any associate to the customer service counter!
@200_success but how can I change it to be on-topic? — marysd 5 mins ago
 
ermph...
"learn reading" ...
 
5:47 PM
@200_success Wasn't this already addressed in three places?
 
1
Q: Java ConcurrentHashMap Implementation

Thomas MathewI have written a simplified version of my own MyConcurrentHashMap. I tried to make use of a Lock[] array for Lock striping, so that all put() operations to the MyConcurrentHashMap is through a lock if required. Also, I made my own MyHashMap made internally as the backing data structure for MyConc...

0
Q: Separate roles into modular parts that are interdependent

jdloftI have a IRC bot that I'm writing (code is here, bot24-irc.py is the main module). This bot needs to be able to perform many different, separate roles so that each can be reloaded and sandboxed (for stability). I'm defining a role as being a function that reads all PRIVMSGs sent and returns a li...

 
6:36 PM
0
Q: Longest lines of file descending

CaridorcThis is a challenge question from codeeval.com: Write a program which reads a file and prints to stdout the specified number of the longest lines that are sorted based on their length in descending order. Input sample: Your program should accept a path to a file as its first argume...

 
This would be a more appropriate question for codereview.stackexchange.comheinst 49 secs ago
 
@Duga Not sure about that one... Anyone else have an opinion?
 
looks good for me
 
How do I quote a code block in a question?
 
Using a >, I think.
> test
Yup
>test
Like that, in a line on it's own
Currently, I'm testing a system to interpret some things that are said here in the chat
 
6:51 PM
@jacwah You can select the code block, then click the "quote" button at the top is easiest. You can also use HTML tags
 
@Phrancis Thanks
 
@Phrancis Here in the chat?
 
<blockquote><code>Your quoted code block here</code></blockquote>
@IsmaelMiguel No in a question/answer
 
Oh! In a question that way is easier
 
2 mins ago, by jacwah
How do I quote a code block in a question?
 
6:52 PM
-.-
Sorry
Brainfreeze
 
It's alright
 
Happens to the best of us
 
That's because I'm half-focused here
 
It does something neat if you actually invert the code and blockquote HTML tags
 
What's that?
NICE!
I've developed a little Javascript that runs here in the chat
It reads the messages and interpret things
If, for example, I write "Jamalized", it shows a link with a title to explain what it means
 
6:55 PM
@IsmaelMiguel ^^ that
 
When you click the link, it goes to the meaning
@Phrancis That looks freaking cool!
Alright, zombie maker incoming
Not :/
 
@Phrancis There is an easier way.
@IsmaelMiguel Do this instead: "> firstLoC"
It is a "> ", then the standard 4-space indent for the code.
 
> Like this?
 
The "> " is blockquote in chat and Q/A's.
The four spaces is codequote.
So yeah, except it looks like the extra spaces were removed in the chat message.
 
Probably were
 
7:07 PM
> Code Review

Beta Q&A site for feedback on projects you're working on, by sharing your code with fellow programmers and getting extensive feedback/review of best practices, design pattern usage, application UI, security, etc.
1635
Code Reviewcodereview.stackexchange.com

Beta Q&A site for feedback on projects you're working on, by sharing your code with fellow programmers and getting extensive feedback/review of best practices, design pattern usage, application UI, security, etc.

Currently in public beta.

 
7:26 PM
I'm writing a question about a patch I'm writing to a GPL project. Is it okay to include a bit of code I've not written myself as context? I'll paste the copyright notice from the source file.
 
Don't see anything wrong with that
You are saying that the bit you didn't wrote isn't yours
You aren't adding it to the review
(I mean, you aren't saying to review that part)
So, yeah, go ahead
 
Is it a legal issue to post someone elses code? From Stack Exchange TOS:
> You agree that all Subscriber Content that You contribute to the Network is perpetually and irrevocably licensed to Stack Exchange under the Creative Commons Attribution Share Alike license.
Maybe it would work better if I put it in a Gist/Pastebin?
 
@jacwah If it's copyright code, you should post a link to the code itself, if published. If not, I'd leave it out entirely, unless you have the author's permission
 
Honestly, I think that adding a disclamer that the code isn't yours is enough-
*.
Unless the licenses are conflicting.
 
^ that
 
7:35 PM
@Phrancis It is published under GPL2
They're not compatible so I'll put it up on Gist
 
OK. I'd suggest just including a link to the repo. GPL2 is not far off from CC-SA, although CC is more commonly used for media content (as in, the content of the post becomes media under CC, regardless if it's code or not)
 
Monknoon
 
Hey there
 
Hello
 
How's it going?
 
7:38 PM
@EthanBierlein 15:34:19.063 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
 
@Phrancis The thing is that reviewers probably don't want to look through a 4.5 KLOC file
@EthanBierlein Legal stuff is fun
 
@jacwah I'm going to disagree with that statement, unless it's sarcasm, then I will agree.
 
@EthanBierlein Trying to figure out how to post code only partly written by me...
 
@jacwah Can you not link to a specific section? I know on Github you can right-click on a line-number to get a link to that line
Or rather, left-click, which updates the URL in your browser to that line
 
It's not on Github, but I'll look into that. They have some code browser on they're site
 
7:50 PM
Zombie down
0
A: Tick module for the game

Ethan Bierlein Do you really need a comment above every line? There are a few good comments like # Function to retrieve current timestamp, hopefully using window.performance object, but comments like # Indicates if module is running are really not useful. They add no value to the code itself, and can b...

 
0
Q: Singly Linked List with Generics and Comparable Data - Corrected Code

Jaspinde VirdeeI am currently reading about the thread-safe implementation of a linked list. I would like someone to point out some mistakes that will create issues if I try to make it thread-safe in the future. Information: Please review the SinglyLinkedList mainly. You may Point out any Design issue in cl...

 

« first day (799 days earlier)      last day (3211 days later) »