@Vogel612 You were right. The 2 could've worked after the letters instead of in front. After all, it's I2C and not 2IC. Should've known, but I didn't think of it.
Good points, thanks. Yes, it does just fine in unit tests, I just felt like I was violating some sort of unwritten coding convention. Nothing obviously wrong with it. I'll see if I can move this to Code Review, didn't even know that branch of StackExchange existed. Thanks. — millejos41 secs ago
As a follow up to my previous question here is the improved code + algorithm.
The compression now works the following way:
Each character is followed by a length byte. The top 3 bits of that byte denote the number of additional length bytes which encode the count. The count is stored in "little ...
@Zak Same here. I took a 7 hour nap and woke up at midnight. So far I have dyed my hair blue, done ironing, washing, had two mugs of hot chocolate and had breakfast.
@Quill You kids and your pointless changes... back in my day when we wanted to write a piece of code, we walked up a snow covered hill both ways backwards and we were thankful for what we got. /s
Use whatever you and your team find the most readable.
Other answers have suggested that a new string is created every time you use "". This is not true - due to string interning, it will be created either once per assembly or once per AppDomain (or possibly once for the whole process - not sure...
In C#, lower-case type names are aliases for the System.xxx type names, e.g. string equals System.String and int equals System.Int32.
It's best practice to use these language alieses for the type names instead of their framework equivalent, for the sake of consistency. So you're doing it wrong. ...
Of course, I'm only praising VS now because I haven't used it in 2 weeks. Expect me to come in here in about ~6 hours swearing about how annoying VS is.
I recently solved this leetcode problem:
Given n nodes labeled from 0 to n - 1 and a list of undirected edges
(each edge is a pair of nodes), write a function to check whether
these edges make up a valid tree.
For example:
Given n = 5 and edges = [[0, 1], [0, 2], [0, 3], [1, 4]], retu...
@Quill Good luck, it's a whole other framework to what Angular used to be
I'm not really a fan of TS because it flat-out refuses to work with a lot of npm modules unless they have typings, and there are a surprising amount that don't
because it uses annotations - that's probably why you're going to use TypeScript. Angular2 uses typescript in their docs, and it isn't until recently that Babel supported annotations.
I've just consumed a regular coffee, a pro plus and a doubleshot of expresso.
Just found this gem during my start-of-year Macro checks:
> '/ I don't like the hacky nature of this, but it will run fine for the next 2 years by which time I sincerely hope we'll have moved to a proper database system
Explanation
For this Christmas, I got this puzzle as a present, with the aim being to try and fill 25 "Z" shaped pieces into a 5x5x5 box. Once I saw this gift, I thought I would challenge myself into trying to make a program to solve this for me.
Picture of piece
All pieces are exactly the sa...
@Zak I assume this means you didn't move to a proper database system yet? ^^
Also, candidates - next, acc + next is probably not a valid Scala code, but I believe it's clear what it means: remove the selected next from candidates and add it to the accumulator acc. — wxdMay 21 '15 at 9:13
Yea, that question should probably go.
Don't recommend other SE sites as vaguely as you did in your comment though.
It's off-topic here, that's enough. Let other sites decide whether it's on-topic for them.
I'm just wondering if what I've done below is correct.
I'm using a method to make initialize the attributes of my objects, and this method is called from both constructor.
What it does is, if no correct currency has been passed, choose € by default.
Code
class Prix
{
double valeur;
...
I'd definitely go to management and say "Hey, since we're going to move to a different system anyway, let's do it right in one go instead of having to move again in a couple of years"
On an unrelated note, could one of the C# guys take a quick look at this so we'll have at least an indication whether it's broken or not? I'd love to take OP's word for it, but he isn't sure either.
@itsbruce Put it this way, I plan to do a lot of asking you guys "How should I design a database for future growth" before / during transition
Once it's in a database, it should be much easier to argue for moving to a different database as and when necessary (probably once we get to a point where a web front-end would make sense)
I'm learning clojure and I'm interested in areas that could be more idomatic. The main function is below. If you're interested in the whole lib, check out https://github.com/tenpn/clj_playground.
The function operates on a grid, which contains a finite number of cells. A cell is a single point ...
I have been studying the architecture of the Siamese neural network introduced by Yann LeCun and his colleagues in 1994 for the recognition of signatures ("Signature verification using a Siamese time delay neural network".pdf, NIPS 1994).
I had some problems in understanding the general archit...
I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed.
Situation
We have one message queue. We would like to process messages in parallel and limit the number of simultaneously processed messages.
Our s...
I have created a Java windows service using procrun. When I try to stop the service it gets hung. Below shown is my stop method implementation.
private static void stopPlugins() {
LOGGER.log(Level.INFO, "Came inside stop plugins method");
for (Class cl : classes) {
LOGGER.log(Level.INFO, "Th...
I'm making a Battleship game using python 2.7. However, how to make it is not currently my issue. The main aspect that I'm asking about is the style and method of making the code. Am I following best (or even good) practice? Are the comments too much, too little, unclear? If someone could give...
No mess ? This is mostly code copied from a sample you found somewhere, it's full of unnecessary commented code, wierd spaces, wrong identation, ... For example, why do you override onResume just to call super.onResume ?? This would get so many -1 on a real company code review that there would be not enough space to show them on a 42inch screen... — 2Dee44 secs ago
what mast is trying to say here is: You really need to be dead sure beyond 100% certainty that it's off-topic on source site and on-topic for where you think it's on topic
and almost everyone gets it wrong on the first try
And if you're certain, you can flag it for moderator attention. But SO usually only takes such flags on already closed questions. And many migration requests from SO to CR get rejected.
So, you have found your way to the Code Review main chat room, The 2nd Monitor, perhaps for one of these reasons:
You were invited or "pinged" by a site moderator or other user to discuss a post on the main Code Review site;
You visited Code Review for the 1st or Nth time, and noticed the chat ...
Because the Code Review community hasn't agreed they'd accept one yet.
Is that relevant? Yes. Let me quote Pops, who mentioned after a migration from Code Review to Stack Overflow was set-up:
FYI: this migration path only goes one way, from CR to SO; it doesn't let questions come from SO to ...
We can migrate stuff to SO, the other way isn't as fast.
Thanks for the suggestion/ code review! I love when people explain some things I have done wrong. Ill try to implement this when I get home and I will make sure to change the stream closing in a finally catch and I will update with what I find. Thanks a lot for the help! I was not sure where to even start looking :), at least this gives me some ideas to try and see what happens. Thanks again! — Justin Smith13 secs ago
I have a list T of objects (of class Element.cs, this class stores attribute values(strings) of elements from a HTML page) in C# - Visual Studio. I am interested in finding the maxPageWidth. To do that i want to check the whole list of objects for the LEFT value and the WIDTH value. The highest o...
I am trying to write a program which will check if a string entered by the user is a panagram or not but I have no idea where to start. Could I get some help or an idea in the right direction?
Thanks. I am using Python 3 currently.
I am learning Java, and I wanted to make sure that I understood object instantiation, reference variable creating and assignment.
Are the comments exactly correct in the following code?
How could they be made more correct?
/*
Two reference variables are created, both of type `Person`.
JVM alloc...
@πάνταῥεῖ I would like to unedrline write a working version of your solution as at CodeReview we review working code, a pseudocode question like this now would be off-topic — Caridorc58 secs ago
I even changed the name mountain_adapter to indirect_adapter in the library since Mountain sort is just a specfific implementation of an indirect sort.
@Elyasin CodeReview is not meant for broken code. — YSC55 secs ago
@Elyasin: CodeReview is for working codes only. Unless I'm misunderstanding "but nothing to testcase-2" (I'm assuming this means that testcase-2 doesn't provide the right answer), OP's code is not working at the moment. — R_Kapp50 secs ago
oh!. Sorry i didn't know this. I was not having any idea so i came here and asked question. i'll look for help on CodeReview. Thanks — CruiseDevice41 secs ago
@Elyasin The code is broken. Stack Overflow is for broken code. Code Review is not. — Zak53 secs ago
A very important reason why we're very wary of allowing a SO --> CR migration path:
SO gets 5,600 questions/day
CR gets 28
If even 1% of SO questions were incorrectly migrated to CR, our site would become 2/3 crud overnight.
Even at present, where the only people who can suggest CR are those...
It's not meant to be an estimate of how many would actually be migrated. Just making the point that any appreciable fraction of SO's question torrent would radically alter the site if they were inappropriate migrations.
Here is what I've written for a program to print upper half triangle of a matrix. Now i need a way to do it without using goto:
#include <iostream>
using namespace std;
int main()
{
int a[10][10], r, c, i, j;
cout << "Enter the number of rows and columns";
cin >> r >> c ;
c...
Based on suggestions and some thoughts I made some refactorings of my classes to hold EAN13 codes.
I create a contract interface which now is extended by BarCode classes, since there will be other types of BarCodes, like DUN-14, UPC-A...
public interface BarCode {}
I decide to move all the v...