instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I had a code review and got told by the senior programmer that it was very bad programming practice to use the json_decode() function of php to determine if a string was not in JSON format. My argument was that the json_decode function has a fail case (returning NULL) and this exists for reasons such as the purpose I w...
stackexchange/codereview
This is my second jQuery script: a universal tooltip for my entire web page. It took me a couple of days to research and make it work. Now, I need help from the experts to optimize my newbie code. This is one of the ways I can show the tooltip: <a class="tooltip" data-tooltip="this is the text for my tooltip" href="#">...
stackexchange/codereview
I've implemented a self-organising map in Tensorflow's low-level API. After testing with sklearn's Iris data, the results seem correct. I did implement the algorithm also using NumPy before converting it to tf, because I'm new to Tensorflow, and had no idea whether it would work or not. So of course I tried out which w...
stackexchange/codereview
I tried to implement an immutable list. public class ImmutableList<T> : IEnumerable<T> { public T Head { get; set; } public ImmutableList<T> Tail { get; set; } protected ImmutableList() { } public static ImmutableList<T> WithItems(IEnumerable<T> items) { if (items.Count() == 1) ...
stackexchange/codereview
I've recently read this article, and I agree that the new keyword is not good practice. Thus, I've made an improvement on John Resig's Simple JavaScript Inheritance in order to use the Class.create method instead of new: // The dummy class constructor function Class() { // I remove the initialization procedure in co...
stackexchange/codereview
I am making a board game with a computer player. The game is on a 6x6 grid. It's like chess but with pawns only. Each player has 6 pawns; one player is circles and one is crosses. The goal is to be the first player to reach the other side of the board. Each move is either one step forward, or a "jump" on a diagonal ove...
stackexchange/codereview
This project was completed as part of an interview challenge. The feedback I received was: The code is neither optimized nor does it follow generally accepted paradigms, naming conventions or best practices There are a lot of nested loops and if/else clauses that could be simplified, he has redundant import statement...
stackexchange/codereview
I recently saw a youtube video on printing even and odd numbers from 0 to 100 in Java. https://www.youtube.com/watch?v=eRNTx8k5cmA Thread 1 prints even numbers and thread 2 prints odd numbers. Both the threads print the numbers till 100. I tried to write something similar in C++. But C++ does not have synchronized keyw...
stackexchange/codereview
I have the following code function x () { return a ? (b ? 'result2' : 'result1') : 'result1'; } Is there a better way to combine these two conditions into one?
stackexchange/codereview
This is my implementation of calculating CRCs which supports arbitrary polynomials specified in different representations (according to the explanations given here and here). My concerns are: I don't like the weak typing (having to supply the numeric value and its size for both the data and the polynomial; possibility...
stackexchange/codereview
I am a beginner with C++, I am not learning OOP yet, I will start when I finish this project. I'm working on "Educational Management System Project". So I had trouble to code the part of login and sign up, I am not comfortable with this approach, I wonder if there is a solution to simplify this code and reducing if-sta...
stackexchange/codereview
Using JSX syntax I wrote a function that takes either a float or an integer as a parameter and returns a formatted string. I'd like any feedback for refactoring the code. const moneyFormat = (float) => { let answer = []; let firstHalf; let secondHalf; // check if whole number if (float % 1 === 0) { flo...
stackexchange/codereview
Here is the part of working code: function SelectPoints(lat,lon){ var dist = document.getElementById("miles").value; xy = [lat,lon]; //center point of circle var theRadius = parseInt(dist) * 1609.34 //1609.34 meters in a mile //dist is a string so it's convered to an Interger. selPts.length =0; //Reset the arr...
stackexchange/codereview
I'm writing a PCL that uses an HttpClient to go visit a few sites and extract data from them. My initial code looked like this: public static class Download { public async static Task<byte[]> FromYouTubeAsync(string videoUri) { using (var client = new HttpClient()) { string source = ...
stackexchange/codereview
I'm working with an open-source library for processing and parsing genetic data in VCF and Tabix formats. It contains functions and classes that make it easy to read an index file (a Tabix) and load corresponding data from a compressed VCF. It works asynchronously (unsurprisingly), however, and I'm not sure of the bes...
stackexchange/codereview
I have a long-running task. My goal is to create a method that will allow me to: Asynchronously wait for this task to complete While waiting on a task, do some async action once in a while. This 'action' basically tells some remote service that task is not dead and still executing. I've written the following code to ...
stackexchange/codereview
Overview We are learning PHP OOP and decided to create a simple app with 3 database tables, one a basic users table, the other two containing information about the users' favorite food and favorite restaurant. To help help others learn this and other best practices a bit easier, we welcome PRs, issues, and other contri...
stackexchange/codereview
There is a question in a contest but it doesn't have any answer. I solve it but I get time limit for most of test case. Is it possible to improve my code or give a better approach? Question There is a directed graph with vertices \$1,...,n\$ and each vertex has a label which is \$a_i\$ (a number not character). we star...
stackexchange/codereview
Using a Select2, what's the best way to refactor multiple if statements. This code returns Json to a select2 based on what information it gets in the query. The action result is used in many places so it has accommodate different parameter being passed. public ActionResult *********(string query = "", int? id = null,...
stackexchange/codereview
I wrote a script that parses API on schedule (Tuesday-Saturday), downloading everything for the previous day. import requests import pandas as pd from datetime import date, timedelta # # This is what I'd normally use, but since there would be no data today, # # I assign specific date myself # DATE = (date.today() -...
stackexchange/codereview
This is a follow up on c++20 compile time string utility, as suggested by G. Sliepen posted as a new question, so it can be reviewed on its own. The following code has suggested improvements from the original question integrated, another round of polishing, and a bit extra. substr is added as an exercise to conform "st...
stackexchange/codereview
What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the [provided] 20×20 grid? [source] This solution works, and works effectively instantly. The algorithm is \$ O ( n ) \$, as it loops through the entire field a total of four times. However, it seems ...
stackexchange/codereview
The purpose of the program is to add 2 sides of an array starting from the bottom and top of both ends and to find the lowest difference at equal decrements of iteration. The program functions but it's slow. int solution(vector<int> &A) { int n = A.size(); int i, j, rsum, lsum, difference; int currentmindif...
stackexchange/codereview
Recenlty I have finished this primitive console string calculator in C. I need your balanced criticism, I'd like to know what I have to correct, remake and learn. Permitted operations: + - * / ( ) ^ Sample input string: 11 * -10 + 15 - 35 / (35 - 11) + 2^2 = main.c #include "stack.h" #include <stdio.h> #include "calc...
stackexchange/codereview
Because I've waited until now to bother learning the magical JSON functions that modern MYSQL affords, I wonder if my code is optimally written and if there are cautions/limitations to be aware of. My script uses PHP to pass API-borne data to a MYSQL query where it is LEFT JOINed with locally stored product data. The t...
stackexchange/codereview
I had an assignment to create a table that will be stored in ROM (read only) and will be used in some algorithms (to convert numbers to strings). However sometimes a user will want to edit the table a bit before using it in the algorithms. So the user must be able to copy the table to RAM, change it and then use it. W...
stackexchange/codereview
I'm doing a CodeEval challenge, where the object is to find a famous writers name and a year, inside of a random given string. You have a set of rows with names of famous writers encoded inside. Each row is divided into 2 parts by pipe char (|). The first part has a writer's name. The second part is a "key" to generat...
stackexchange/codereview
The complete script works as expected. I am able to download and verify the files. If the file is all ready present verification is retested and downloads if necessary. I'm in the process of teaching myself bash/sh scripting. Is there a cleaner way I can implement the following section of sh script? The files reside at...
stackexchange/codereview
Is there a simpler way to write this ugly if/else statement? It's simply appending a query string to a url depending on whether the variables exist. if (start) { url += `?start=${start}`; if (end) { url += `&end=${end}`; } } else if (end) { url += `?end=${end}`; }
stackexchange/codereview
I am creating a Mac OS X application. This application will connect to a MetaWear sensor over ble, and log the accelerometer and gyro data (I want to store 30 samples for each, per second). Here are some details on my env and the framework of choice, as outlined in my cocoapod file: platform :osx, '10.12.6' pod 'MetaWe...
stackexchange/codereview
I am creating a simple server that accepts a int and returns the value received twice: public class MyServer{ private static int port = 1234; public static void main(String args[]){ try{ ServerSocket serversock=new ServerSocket(port); while(true){ Socket socket...
stackexchange/codereview
I'm working on a script that will be able to send mass e-mails. I'm using cron to run this script. I'm fetching e-mails from queue. I need to ensure that: To one e-mail will NEVER be sent more than one message (it could be executed more than once) One e-mail must have only one recipient (not multiple to) It must to ju...
stackexchange/codereview
Here is my Python implementation of counting neighbours of Game of Life with radius as parameter. def neighbors_count(n2d_array, radii=1): assert n2d_array.ndim == 2 row_len, col_len = n2d_array.shape nbrs_count = np.zeros_like(n2d_array) for row_idx, row_val in enumerate(n2d_array): for col_id...
stackexchange/codereview
I intend to extract a URL search parameter value using a regular expression in plain javascript. The parameter can be in any order in the search query. So is there a better approach than ? const query1 = '?someBoolean=false&q=&location=&testParam=dummy_value&testParam2=dummy_value2&requiredParam=requiredValue'; cons...
stackexchange/codereview
Project Euler #5: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? Here is my solution: class SmallestMultiple { private static final int MAX = 20; ...
stackexchange/codereview
I made a function that converts Roman letters to integers. But I'm not happy with it, as I feel like I used too much code for a such a simple task. Any suggestion on how I can minimize it? values = (('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90)...
stackexchange/codereview
I just start to learn OOP, and it's far more interesting than procedural style. I have a complete working online store written in procedural style. After realizing that my code is becoming very huge and very complex, I'm searching for methods to make my code more maintainable and more comfortable. One solution of cour...
stackexchange/codereview
This is a Leetcode problem - Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If you burst the balloon i you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i. ...
stackexchange/codereview
Objective Determine whether a given word is contained in a 2D Array word search. Question 1. What are the time and space complexities of the current algorithm? Time complexity Linear: \$O(2(r * n))\$ There are iterations through the outer and inner loops for the rows and columns occurring twice, once for the horizont...
stackexchange/codereview
My own CMS is currently using jQuery, but as one of the goals is to have the whole project to be very small, I've decided to write my own basic library. I only really need to select elements and modify them using results from my server (via Ajax). The JavaScript-library v0.01: (Attempt 1) (function(){ a=this.Funct...
stackexchange/codereview
My code is very very slow. Could you give me hints on how I can make it much faster? for (stdext::hash_map<unsigned __int32, CVertex*>::iterator it1 = graph.begin(); it1 != graph.end(); it1++) { for (std::vector<CVertex*>::iterator it2 = it1->second->getNeighbors().begin(); it2 != it1->second->getNeighbors().end();...
stackexchange/codereview
This is my first time writing a somewhat non-trivial declarative + recursive macro in Rust. I drew inspiration from this answer. The goal is to come up with a recursive macro that allows to assemble some kind of node tree. The general interface function is something like parent.add_child(child). The macro should simpli...
stackexchange/codereview
I'm learning web services using Java. I just don't know which method has what advantage over another, like which one is more secure? Which one will be more faster? POST resource is as follows: @POST @Path("postactivity") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public String createAct...
stackexchange/codereview
I saw a guy who fit snake in a qr code and I wanted to do the same thing but with minesweeper. The maximum amount of data a qr code can hold is 3kb. My c program, without any compiler magic, takes up 58kb. A tiny bit over the limit, haha. So before I started performing alchemy with the compiler and compression program...
stackexchange/codereview
I wrote this implementation of a singly linked list but I don't find my code enough simple and compact. Could you help me to simplify it? Includes #include <exception> #include <iostream> Structure of data elements template<typename T> struct Link { T val; Link<T>* next; }; Class of singly linked list templat...
stackexchange/codereview
I'm new to web programming, and writing some web apis to enable users to sync their data between devices. Is it okay to use singleton pattern to prevent reconnecting the MySQL database on every api call? <?php final class MySQLiConnection { private static $connection = null; private function __construct() {} ...
stackexchange/codereview
This is a revision of a previous question that I asked (i.e. Check browser compatibility for RequestAnimationFrame and Vanilla JavaScript .animate() API), with new aspects that I have learnt in Javascript. It is I think better than the previous implementation as it is using switch statement's which will only run if cer...
stackexchange/codereview
Elsewhere, there was a question about finding an elegant solution to a particular problem, and the following solution was presented. I'm curious whether this solution is elegant from the perspective of easy to understand for a Ruby programmer (which I am no longer). merged_file = File.open("merge_out.txt", "w") files ...
stackexchange/codereview
I wrote this small Brainfuck interpreter in C++ where the different op codes are handled in one big switch-case statement instead of something like a tokenizer as Brainfuck is very simple in that regard. Furthermore, I split the logic into namespaces as I wanted to emulate or have the behaviour as if it was a static ut...
stackexchange/codereview
I've a added a click event to each row on a table element. Which I then use the $this context from the event to add some css styling to that clicked row. The behavior is as follows: IF tr doesn't have kpi-selected css applied WHEN tr is clicked on table THEN remove css style from all other tr elements THEN add css styl...
stackexchange/codereview
I am rotating images inside some divs. An image is associated with a link.Eg: image0 is associated with link0, image1 with link1 and so on. image0 and link0 should display in pos-1 image1/link1 and image2/link2 should rotate on page refresh in pos-2 image3/link3 and image4/link4 should rotate on page refresh in pos-...
stackexchange/codereview
First of all, I am very new to programming and also this site. This is a very simple "Rock, Paper, Scissors" game I made in C#. At first, it asks if I want to play the game. If my answer is yes, then I enter my name and the game starts. The program asks me to choose rock, paper or scissors, then the computer randomly p...
stackexchange/codereview
Please review my code. I am trying to implement a thread-safe LRU cache using std::list and std::unordered_map. This is a header-only template class which you can use to keep an object cache. The constructor takes a size as an input parameter and creates a cache of a specified size. Items will be removed based on the l...
stackexchange/codereview
I wrote a small utility function that divides a total into n parts in the ratio given in load_list. Numbers in each part should be positive integers. It supports an optional min_num argument that, when specified, puts at least min_num in each of the n parts before distributing the rest. Please review. def reduce_ratio...
stackexchange/codereview
I'm trying to implement some logic functions essential to control a small power system consisting of 2 Transformers labeled T1 and T2, 2 Generators (G1 and G2) and a bus tie (BT). I'm not going to overwhelm you with the unnecessary details. I need help figure out why my Arduino circuit doesn't work as expected even th...
stackexchange/codereview
I need a code review on my Abstract Factory pattern written in Java. Find the two enums AnimalType.java and DietType.java below. package com.patterns.abstractfactory.three; public enum AnimalType { TERRESTRIAL("\nLeave on land and breath with lungs.\n"), AQUATIC("\nLeave in water and breath with gills.\n"); private ...
stackexchange/codereview
I want to write a class that returns a Stream of permutations of an int[]. public class Permutations { public static Stream<int[]> of(int[] array) { return permute(array, array.length); } public static Stream<int[]> permute(int[] array, int n) { if (n == 1) { return Stream.of(Arr...
stackexchange/codereview
I am new to CMake and got currently a setup of my Visual Studio solution working via CMake. My goal now is to have a professional CMake setup. Here is my folder structure: root_project |─── CMakeLists.txt |─── Project 1 | |─── build | | |─── Debug | | └─── Release | |─── source...
stackexchange/codereview
For an assignment, I had to draw a checkers board, with blue and red checkers, in python. What I have works, but I'm wondering if there's a more elegant and/or efficient way to accomplish this feat? Any and all suggestions are welcome! import turtle def draw_box(t,x,y,size,fill_color): t.penup() t.goto(x,y) t....
stackexchange/codereview
I've been teaching myself Ruby this weekend. First of all, I am aware that there is a built-in sort function. I've written this code strictly as an exercise. I have background primarily in C# and Javascript, so this is a change of pace for me. If you are a seasoned professional with a lot of Ruby experience, my code ...
stackexchange/codereview
I've just finished writing my code to return the prime factors of a number and I feel the GetBestFactors function could be improved. The GetFactors function was hacked together from the code found here:https://support.microsoft.com/en-us/kb/202782. This returns all the factors of a number in a collection. The GetBestF...
stackexchange/codereview
Primary Concerns As long as the stash is not within scope, globals such as window/global would effectively be sanitized of any risky methods, such as eval The API feels complete, am I missing anything? Are there any "risky" aspects to the sever method. Any thoughts with regard to performance or security. I don't think...
stackexchange/codereview
I'm looking for feedback on my solution to the following prompt: Given an array of ints, return the index such that the sum of the elements to the right of that index equals the sum of the elements to the left of that index. If there is no such index, return Nothing. If there is more than one such index, return the le...
stackexchange/codereview
I've built a simple decorator that wraps a function in a general Pygame game loop. It also allows for the programmer to set the tick rate. import pygame import sys pygame.init() def game_loop(tick_rate=60): """ This simple decorator wraps functions with a pygame game loop. Here's an example of usage...
stackexchange/codereview
I wrote a program that can take any English text and transform it into an integer and vice versa. My method I use two dictionaries to map between letters and numbers. I chose base 32 because it is a multiple of 2, so I guessed that would be easy to work with. The pairing is 0 ⟷ 1 ⟷ a ⋮ 26 ⟷ z ⋮ (some other characte...
stackexchange/codereview
I am writing a python code to recursively traverse a directory containing only text files and then print the 10 digit Indian phone number and all its variants. I am very new to python and I have written the following code to print the numbers and this code is working fine. I want to know if there is any other better wa...
stackexchange/codereview
This is my third (and hopefully final) time re-writing this program. It was recommended I use Pathlib and it simplified my code, it's easier to read and understand than the first two monstrosities. I also changed the way it functions, instead of the user providing a text file, the user creates a directory called Repos...
stackexchange/codereview
I've written a userscript that pops up a dialog before you take a moderation action (closing, deleting) with some pro-forma comments, so that you can add one of those before you cast your vote. I'm pretty happy with how I wrote it, but what's clear to me is unlikely to be so to others. Is there anything in this that I ...
stackexchange/codereview
I am learning Rust. I have written a web crawler that would scrape all the pages from my own blog (which is running on Ghost) and would generate a static version of it. Because of this, I'm not interested in handling robots.txt or having rate limiting. extern crate select; use std::io::Read; use select::document::Docu...
stackexchange/codereview
I am using PHP PDOs to parse the results I am receiving from MySQL queries against a database. I am now running into an issue with running out of allocated memory. Are there any suggestions on improving the efficiency of my code or another more efficient way to handle query results other than parsing PDOs? This will r...
stackexchange/codereview
I have around 300 log files in a directory and each log file contains around 3300000 lines. I need to read through each file line by line and count how many hostnames that appear on each line. I wrote basic code for that task, but it takes more than 1 hour to run and takes lots of memory as well. How can I improve this...
stackexchange/codereview
I have been developing a program with C lately, its purpose over the top is to reconstruct meshes from point clouds which are generated by finding the intersection points of numerous rays fired at the image which had previously been preprocessed by a HED neural-network. I'm doing this for a school project and I haven't...
stackexchange/codereview
I am using Kotlin from quite some time now, but I could not able to achieve not-null types for all the properties in Kotlin. After what I learned by watching Kotlin in Google IO and a bit of research, I made all properties not nullable. Please check my code and correct me if any mistakes. Thanks in advance. class Musi...
stackexchange/codereview
Below is my method to find the longest substring having k distinct characters. I have used Set to keep track of distinct characters. public static int maxLengthSubstring(String str,int k) { int i=0; int j=i; int max=0; //use set to keep track of distinct characters Set<Integer> set=new TreeSet<>(); ...
stackexchange/codereview
I am trying to get the hang of Roslyn at the moment, and to implement a couple of code fixes for specific fields/properties that should usually be readonly (in the case of a property, to have no setter). I've started from the "Analyzer with Code Fix (NUGET + VSIX)" template and now have two diagnostics implemented in t...
stackexchange/codereview
I am an undergraduate CS student trying to implement simple unit test framework on C++ as a pet project. The framework has an assertion macro like ASSERT_EQ(var1, var2), which checks whether two variables are equal or not. If the assertion fails, I want to print a failure message to std::cerr and provide as much inform...
stackexchange/codereview
EDIT: This question is followed up by this question. I'm in the process of filtering some very(!) large files (100gb+): I can't download files with a lower granularity. This is a followup from this question. The problem is as follows: I need to filter large files that look like the following (3b+ rows). TIC, Date, Ti...
stackexchange/codereview
The code below is the Index Action from a User Controllers. Basically this code returns a list of users from Azure Active Directory using Azure Authentication Library (ADAL). However I need to show 2 custom properties, in Azure AD, they are called Schema Extensions, they are just custom attributes where I saved custom...
stackexchange/codereview
I built one JavaScript debounce function. I need a JavaScript expert's opinion if this is the correct way to do it, and if not, then what the flaw is in this current function. var debounce = function(inpFun, wait) { var timeout; return function () { if(!timeout) { inpFun.apply(this, argume...
stackexchange/codereview
This is a concept for a compositor. It would help me if you could review how well I expressed my ideas into the functional language. I first divide everything in an areas that each window covers entirely or not: Then I can walk the areas and render each corresponding window. The actual composing of the vectors is a ty...
stackexchange/codereview
I am creating an MVC-Framework to learn more about how PHP and software architecture works in general. My goal is to create a simple website with it. Right now I have trouble on what exactly is the job of the bootstrap file and the FrontController Class. Can you have a look if what I did makes sense to you? My Bootstra...
stackexchange/codereview
I have a private method that is called from the constructor to instantiate a bunch of objects. I can do it two ways. private Monster[,] createMonsters() { Monster[,] myMonsterArray = new Monster[8, 6]; for (int i = 0; i < 8; i++) { myMonsterArray[0, i] = new Monster(SpriteFa...
stackexchange/codereview
I'm trying to resolve this kata from CodeWars. Kata exercise You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). Return true if you can reach position [N-1, N-1] or false otherwise. Empty positions are marked .. Walls are marked W. Start ...
stackexchange/codereview
I decided to learn a Lisp-ish language and I am discovering a very weird and new syntax. The obligatory first program, that also uses all the fundamentals, is the number guessing game. Did I define too few or too many constants? Is my code properly spaced and indented? Is there a cleaner way to exit the loop than err...
stackexchange/codereview
Which form of the method do you find more readable? Version with local variables: public void checkRetrievedIds( List<Integer> expectedIds, List<Integer> retrievedIds ) { Set<Integer> expected = new HashSet<>( expectedIds ); Set<Integer> retrieved = new HashSet<>( retrievedIds ); Set<Integer> difference =...
stackexchange/codereview
I have completed my website and I'm super happy with its design, but I feel that how I reached this point can be made more efficient and genuinely improved. Note: I'm only looking for assistance on how I can get the same output, but with fewer media queries for responsive design I feel that there is a flaw in the about...
stackexchange/codereview
I am a self - taught coder, and have been learning Java / C# for the last 2 1/2 years (inconsistently). I have recently created a snake game in Java with the help of an online tutorial. I have rearranged the program into separate classes & methods. I am skeptical on how good of a programmer I am, and I code messy. I do...
stackexchange/codereview
Let's take the famous fibonacci problem as an example but this is a generic problem. Also, taking scala as the language as it's rather feature-rich. I want to know which solution you'd prefer. we all know that the following implementation is evil as it's not stack-safe: //bad! def naiveFib(n: Int): BigInt = { if (n ...
stackexchange/codereview
I am building an Android quiz app. I want to display a progress bar showing how many questions a user has answered correctly and how many they have left. Questions are split by difficulty level; easy, medium and hard. All my questions are stored in an SQLite database. The questions table is made up of three columns: le...
stackexchange/codereview
Just finished creating my first bot using Discord.js for the chat application, Discord. This is my first bot and first javascript program I have ever created. I'm mainly interested in ways I can optimize the code and make it a bit cleaner. Any help or suggestions is greatly appreciated. Github Repo Main: /* File: Jarvi...
stackexchange/codereview
This is a follow-up to the other post I made (less than an hour ago) about my Google reCAPTCHA C# implementation: Google reCAPTCHA Validator This adds support for error messages, so that you can determine why a reCAPTCHA request failed (if an error was returned). This also fixes a bug if you were to use the ReCaptchaLo...
stackexchange/codereview
In my Azure DevOps Project, I have a Git repository that I would like to copy to another Azure DevOps Project. In other words, I should be able to copy the original repo into other Azure DevOps projects as needed. To import work items into Azure DevOps, I have written the following code. Would you be able to review and...
stackexchange/codereview
Would love some feedback on this. I'm coming from a Java background and kinda feel like I've just done exactly what I would do in Java. Is there a better way? for (i <- 1 to 100) { if ( i % 3 == 0 && i% 5 == 0) println(i +" = FizzBuzz") else if (i % 3 == 0) println(i +" = Fizz") else if (i % 5 == 0) ...
stackexchange/codereview
I just started learning programming a few months ago, and I'm intrigued by Haskell. To learn a bit I tried to adapt some code I have in Java so I can see what are equivalent solutions in Haskell. The problem I had was to see how many different numbers can be “represented” by a string of roman numbers (0, .., 9, where X...
stackexchange/codereview
I have this code that creates unique passwords using the first letter of each word from the file. Before each password is created (written to a file) it is compared to all passwords that are currently in the file, so if the file has 50,000 passwords before a another is written it has to scan through all 50k. A user ca...
stackexchange/codereview
I want to display on a view the EmployeeHistory view model sorted by elements.assignEffDateNext and I want to instantiate and populate the view model from the controller. The code analysis is saying that the IList<IDMSElementDate> EmployeePositionsOverTime should be read only. I kind of understand why. This is what I...
stackexchange/codereview
I have this program that computes a Levenshtein distance of the two input strings, their edit sequence, and the alignment: LevenshteinEditDistance.java: package net.coderodde.string.levenshtein; import java.awt.Point; import java.util.HashMap; import java.util.Map; /** * This class implements the Levenshtein edit di...
stackexchange/codereview
I am passing a vector of strings b and then I am iterating the list to find the smallest string. and question says I need to return all the string of that smallest length. Then I am adding the strings to the list a and then returning the list. public static Vector<String> q(Vector<String> b){ Vector<String> a =...
stackexchange/codereview
I'm trying to print the top 5 most queried strings from a text file. I can't use other third-party libraries to make it easier w.r.t hashmap implementations. I need to improve on these if possible: cyclomatic complexity Memory usage Execution time Page faults import java.io.File; import java.io.FileNotFoundExceptio...
stackexchange/codereview
I am making a game with c++ and sfml for the first time and I would like someone to review my current code before I advance and add more rooms/levels, any input is gratefully appreciated. I was also wondering if I should make a .cpp file for each of my class header files, or is it ok to just put my methods with the hea...
stackexchange/codereview