« first day (2354 days earlier)      last day (37 days later) » 

12:00 AM
RELOAD! There are 6179 unanswered questions (90.1058% answered)
2 hours later…
1:58 AM
better platform for this code reviewprashant rana 42 secs ago
Q: Size out of limits in array made with malloc

AlexaNI'm applying what I learned in statistics class to a program to calculate everything automatically, but encountered an unexpected 'mistake' in my code. I say unexpected, because it's not the first time I use malloc() to make a variable sized array and used reference from my previous work, but it ...

2:44 AM
Q: C# Bowling Game interview test

Chris NielsenI recently interviewed for a software engineering job that requires at least one year of C# and experience with the Microsoft stack. Even though I made it clear at the outset that I had zero experience with C#, they still wanted me to take their engineering test, which led me to believe that they...

1 hour later…
3:44 AM
Q: Find the closest enemy

LinnyI'm currently creating a 2d game in python. I have to calculate the closest enemy so the player knows which one to target. I have the following function to accomplish this task: import math def find_closest(character: tuple, enemies: list) -> (int, int): """ Finds the closest enemy in e...

1 hour later…
4:50 AM
5:11 AM
I have posted the question in both link and link and deleted them as well. — RamkumarSP 20 secs ago
1 hour later…
6:28 AM
Q: Implement state eraser for NIST DRBG and other crypto primitives using macro

DannyNiuAs a spare-time personal project, I'm implementing a set of symmetric-key cryptographic primitives. One thing I've left vacant for a long time, is the key/state eraser, which I decide to add right now. I intend it to be a macro, so that it doesn't require any additional object file; the macro...

2 hours later…
8:50 AM
Q: TCP reassembly not happening with windows APIs in WINDOWS APPLICATION .NET

Malay PattanayakI refereed to your answer on : "Always stay connected" mechanism for socket connection if (this.mNetworkStream.CanRead) { byte[] data = new byte[5000]; int noOfBytesRead = 0; noOfBytesRead = this.mNetworkStream.Read(data, 0, data.Length); if (noOfBytesRead > 0) { byte...

Working code should be posted on Code ReviewSweeper 43 secs ago
2 hours later…
10:32 AM
Q: Python - 'if name in dict:' OR 'try:/except:'

mattrea6I'm writing some OO Python and I would like to know which of these methods is more pythonic, or which is generally better, or faster. This is an accessor for an attribute which is a dictionary. Method 1: if/else def GetSlot(self, slot_name): if slot_name in self.Slots: return self.S...

Q: 2 player dice game, assistance needed

ComputerScience-IsTheBestThe players roll two 6-sided dice each and get points depending on what they roll. There are 5 rounds in a game. In each round, each player rolls the two dice. The rules are: • The points rolled on each player’s dice are added to their score. • If the total is an even number, an additional 10 poi...

Q: "Bigint" decimal to two's complement binary list of bytes in Python

Curt J. SampsonI'm toying with the idea of writing a "bigint" library in 6502 assembler that would handle variable-length integers up to 255 bytes long. To help wrap my mind around the representation issues I've come up with a function in Python that takes a decmial integer and deposits it into (emulated) memor...

Monking @all
Code Review is the site for asking for design improvements. — Barmar 26 secs ago
10:46 AM
This might be more on-topic for GameDev or CodeReview. Be sure to look up their help centers to see if your question would be acceptable. — Turamarth 8 secs ago
Q: Breadth-first search(BFS) Implementation in Python 3

brijesh kalkaniI have implemented a BFS. Does this look like a proper implementation of BFS in Python 3? And if you think something needs to be improved, say it. class Node(object): def __init__(self, name): self.name = name self.adjacencyList = [] self.visited = False self...

Q: Changing opacity of KML file (with icon linked) fetched in the Leaflet Map

Mariusz KrukarI have a solution for making the .kml file transparent in the Leaflet Map. The working code looks like this: L.KML = L.FeatureGroup.extend({ initialize: function (kml) { this._kml = kml; this._layers = {}; if (kml) { this.addKML(kml); } }, addKML: function (xml) { ...

Monking :)
Hi, it's not about the debug code running, is about "being there", doesn't help in the code review. It's more code to read and doesn't bring value for the review. — I-NOZex 14 secs ago
11:13 AM
Q: Is this PHP code for blacklisting and rewriting/redirecting URLs good?

YoKoGFXWe faced an issue where URLs had a wrong "subfolder" in its URL, so e.g. example.com/match1/randomgenerated should have been example.com/rewritewiththis/randomgenerated We currently use this code for redirecting URLs that (maybe it could be that it only starts at urls that are "bad"): $oldu...

Q: Creating procfs entry on linux in Kernel Module

St.AntarioI'm currently learning how to write Kernel Modules for Linux and implemented this simple module which creates a new procfs entry and allows some data to be read from it. The module consists of the following files: init.c: #include <linux/module.h> #include <linux/kernel.h> #include <linux/proc...

11:54 AM
Q: C++ My Collision Detection is buggy

TRGamer TRHi i have basic collision detection code. But it's buggy when i go backwards and go back the collision detection stopps working. I using floats for my variables here my code snippet this code was located in display function i using FreeGlut and Visual Studio 2017 My variables are: float tra_x ...

12:27 PM
Stackoverflow's help center and How to Ask should also hint that codereview is not a good fit for SO — mplungjan 1 min ago
When you have a working solution and you would like to improve it, please consider codereview.stackexchange.com — kojiro 34 secs ago
If you have a working solution and would like to improve it, consider asking at codereview.stackexchange.comkojiro 47 secs ago
Q: TypeError: Object of type Undefined is not JSON serializable

JackI've tried various way referencing overflow but couldn't fix the error. Here are my code HTML {% extends "layout.html" %} {% block title %} Sell stock {% endblock %} {% block main %} {% if status == 0 %} <h2>Please select a stock that u sell.</h2> <form method="post" class="needs-validation"...

12:57 PM
> Me: "My rep was 16k last week, who downvoted what?"
> SE: "-15 User was removed"
> Me: "That's a crock of crap."
Sounds like a good question for codereview.stackexchange.com :) — magnattic 27 secs ago
@410_Gone I don't know nuthin
It is what it is.
1:38 PM
Greetings, Programs.
2:05 PM
It sounds like this may be a better fit for codereview.stackexchange.comDavid just now
@410_Gone I've probably lost 70 rep this way.
@pacmaninbw overall?
@pacmaninbw It happens infrequently to me, I don't really get upset about it.
@Vogel612 Yes
then you're off pretty well, I think
2:06 PM
Happened at least 4 times this year.
> -150 02:25 removed User was removed (learn more)
I lost 150 a while back from it
@410_Gone Now that hurts
We may see more of this as fall out for the new CoC
Going back just a little bit in my history so far I count -185 from users being removed.
it's easiest to check with the reputation feed
though I'm confused as to why I only have a -50 and a -100 (which probably are bounties) aside from downvotes and unaccepts
@pacmaninbw Shouldn't be much? As I understood it, a user self-deleting (and even a lot of network deletions) don't remove historic votes.
2:20 PM
@Kaz I'm not sure. I think there's a preservation check at some threshold, but that only means an employee reviews the vote deletion
2:36 PM
Can someone add a fifth VTC to this codereview.stackexchange.com/questions/230674/…
2:47 PM
// A
$user = new User();
$user->email( TRUE, $_POST[ Register::KEY_EMAIL ] );
$user->displayName( TRUE, $_POST[ Register::KEY_DISPLAY_NAME ] );
// B
$user = new User( $_POST[ Register::KEY_DISPLAY_NAME ], $_POST[ Register::KEY_EMAIL ] );
^^ A or B?
usually I'd prefer B and not allow mutation
Well I have to allow mutation here, unfortunately.
But, I'm trying to decide if I just want to use the constructor when registering.
I use the constructor when loading from the database, so that's a non-issue.
The problem is passwords...
I use the constructor for loading from the storage system, which means I have to pass raw-passwords in there.
But, for registering, I pass the password into a changePassword in the user which does the proper hashing.
Maybe I should just make a register function in the user. That would let me do both.
@410_Gone that sounds bad, actually
Well there are only so many options.
    public function loadUserByEmail( string $email ) : ?User {
        $filename = $this->baseFolder . "users/" . $email . ".user";

        if ( file_exists( $filename ) ) {
            $data = explode( "\r\n", file_get_contents( $filename ) );
            $user = new User( $data[ 1 ], $email, $data[ 0 ] );
            return $user;
        } else {
            return null;
(Right now it just stores things in a folder)
So $data[ 0 ] is the password hash (stored in the file, would be a column if using SQL).
And $data[ 1 ] is the display name.
This makes the responsibility of encoding the data entirely the job of the "Data Manager".
I dunno, we'll see where it goes, I don't think it's worth thinking too hard on (yet).
3:19 PM
Q: Message handling: Should a test/spec do it?

vikingosegundoI am currently implementing an app that uses an architecture based on features & usecases and message sending. Features are created with message handler passed in. To test the feature, a handler intercepting the resulting message, must be passed in. I came up with 2 solutions: use an object...

3:39 PM
Q: Reverse a String (JavaScript, Python)

EmmaProblem Given a string, the task is to reverse the string and return a reversed string. Code Just for practicing, I've implemented a simple reverse string problem using JavaScript and Python. If you'd like to review the codes and provide any change/improvement recommendations, please do so and...

3:51 PM
I ended up writing a TSX snippet and injecting it into the minified vendors~main.xxx.js file via sed. Next question: How do I get this past a code review? cryingDaniel Darabos 58 secs ago
1 hour later…
4:57 PM
Appreciate whomever UV'd me
5:21 PM
Q: Monitoring Traces for Satisfaction of Temporal Logic Properties

Agnishom ChattopadhyayI am trying to implement a monitor for a certain temporal logic. What this means is the following: There is some external source, from which a trace of items are coming. An item looks like a timestamp along with some propositions which holds at that point. There is a property of traces we care ...

Q: code works but shows wrong values

islem habibiHi I am new to programming while trying to execute this script the input file has this form (in this case they are called nohd*.txt files) NSGEAPKNFGLDVKITGESENDRDLGTAPGGTLNDIG IIIIMMMMMOOOOOOOOOOOOOMMMMMMMMMMMIIII and I would like to count the following content of a file named d.txt D O ...

I'm voting to close this question as off-topic because if the code is working the question belongs at codereview.stackexchange.comJoakim Danielson 45 secs ago
Hi there :) your title doesn't really reflect what you're actually asking (not how to check, but rather how you could improve your code). This isn't a big deal in and of itself, but it does mean that your actual question is more suited to Code ReviewMyStackRunnethOver 19 secs ago
5:37 PM
I moved my question to code review. It wasn't known to me earlier. Sorry about that. — Manoj Banik 9 secs ago
Q: Checking an array is sorted in either order efficiently

Manoj BanikHere is my code, it works fine, just wondering if there any anything to make it even better. public static boolean isSorted(int[] arr) { int n = arr.length; int i = 0; while (arr[i] == arr[i + 1]) // same elements at the beginning i++; if (arr[i] < arr[i...

1 hour later…
7:04 PM
Q: Need help converting my program to M-V-C

huntgang99I'm currently doing a course in Object Oriented programming in Java, and we need to create a game using JavaFX and the Model-View-Controller approach for our last lab so my lab partner and me chose to make a 2 player checkers game. We wrote the following classes but without the M-V-C approach, ...

7:14 PM
@DouglasLeeder I've sync'ed that file again with P4 depot but error remains same. Can you please recommend anything which helps to commit code to P4 depot using git. I just want to check diff b/t my local master changes and depot master and git is very useful in that, specailly in code review process. — Mukesh Kumar 44 secs ago
7:54 PM
@CaptainObvious Come back when you're done.
Hi @Thomas
how goes it?
Q: Can't replicate code with the same logic

adamThe code that gets the right value (Utility percentage) #include <iostream> #include <math.h> using namespace std; const int N = 50; // Geografines platumos koordinates double lat[N] = { 54.683, 54.9, 55.717, 54.95, 55.733, 54.4, 54.517, 55.4, 55.083, 55.5, 5...

8:58 PM
Questions about improving working code are more appropriate for Code Review. — Barmar 36 secs ago
Q: leetcode 230: kth smallest element in a Binary Search Tree

neetHere is my implementation: the goal of the algorithm is to find the kth smallest element in a BST. class Solution(object): def kthSmallest(self, root, k): """ :type root: TreeNode :type k: int :rtype: int """ count = 1 stack = [] ...

9:26 PM
Q: LeetCode: Diameter of Binary Tree

Giladhttps://leetcode.com/problems/diameter-of-binary-tree/ Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. Examp...

1 hour later…
10:28 PM
Q: Updating NamedTuple members based on a function and previous value

CarcigenicateI'm using a NamedTuple to represent the state of my game while it's running. The user can alter these settings using key presses, so in my PyGame key handler, I'm writing things like: if key_code == 273: # Up arrow return game_settings._replace(fps=game_settings.fps + 5) Each key press tr...

11:27 PM
11:47 PM
@Cheesegrater to some extent it does not matter if you expose the locking object directly (obviously via get-only property so one can't change it from outside) or use your custom Lock/Unlock pair or even lock the object itself the problem of mismatched pairs is the same - there is nothing (expect code reviews) that prevents people to incorrectly lock either without matching unlock or for too long time... — Alexei Levenkov 39 secs ago

« first day (2354 days earlier)      last day (37 days later) »