instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I have created a little console tool that simply does commands that you enter. The commands are stored in a txt file. Right now I only got 2 commands: getTime and getCommands. Pretty simple, but I'm not sure I'm doing anything the most optimal way, which is why I am asking here. I was thinking about creating a whole c...
stackexchange/codereview
I perform an if-check (commented in the code) to determine whether a user can access certain actions or not. The user will be redirected to the index page if they try to access the login.action while already logged in. I have this kind of if-check in many of my Action classes (containsKey() or !containsKey(), depending...
stackexchange/codereview
I have a text file containing the following data. ascon1 201707011 John 77.5 11.5 11.5 11.5 ascon1 201707012 Grld 70.0 11.5 11.5 11.5 ascon1 201707013 Josh 79.5 11.5 11.5 11.5 ascon1 201707014 Jess 67.5 11.5 11.5 11.5 ascon1 201707015 Jack 97.5 11.5 11.5 11.5 I need the data to look like this. ascon1 201707015 Jack...
stackexchange/codereview
I've implemented a simple Maybe type around std::function that implements function composition where any function in the composition can fail (causing the entire composition to fail) - in essence, a Maybe monad where operator<< implements bind. For example, // one binary function that cannot fail. std::function<int...
stackexchange/codereview
I made this c# hangman game... I would like to know what you all think about it. This is a pretty basic but still gets the job done let me know what you think. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace idontknow { class thehangedman { public bool st...
stackexchange/codereview
I am interested in any kind of possible improvement to this method of testing a Rust program with user interaction in an end-to-end manner (simulating user input and asserting a certain program output given a certain user input), I also added an example usage of this framework with a number guessing game for clarity. T...
stackexchange/codereview
I wrote a basic C++ template to manage shared resources like textures and shaders in a 3D engine. The idea is that the cache itself holds weak references to the resources (through std::weak_ptr) and turns it into strong references (through std::shared_ptr) when the resource is fetched from the cache or constructed if i...
stackexchange/codereview
I am trying to improve the efficiency of my code, The Question is: Given a value n, where n is in the range [0 .. 500], return the number of digits equal to 1 in the decimal representation of the number \$11^n\$. Naturally when dealing with a larger power (where n is a large number), this reduces the efficiency drastic...
stackexchange/codereview
I made a simple linked list in C with the following functionalities: Create(creates the list); Find(searches for an element in the list); Insert(inserts a value at the beginning of the list); Destroy(destroys the entire list). It only uses integers (for simplicity), and I want to know for possible errors and how to imp...
stackexchange/codereview
I have the following snippets. which formats error messages based on a map. I can do it as a simple function call the function for transforming the error. or create a class and handle it in that way. Functional doesn't require a an object instantiation and the message are exposed so that can imported in test to verify ...
stackexchange/codereview
In my game, I need to detect whether any buttons/keys are pressed at all before I try to process any input. This is easy enough for keys since the XNA library provides a GetPressedKeys method on the KeyboardState class: private void ProcessKeyboard() { keyboardState = Keyboard.GetState( PlayerIndex.One ); if (...
stackexchange/codereview
I am working on a 2D tile based platformer and was hoping to get someone to review my collision detection. I've only included the X collision check since the Y is essentially the same. Any suggestions/criticisms are appreciated. // Corrects X movement if a collision occurs. private void checkXCollision() { ...
stackexchange/codereview
Here, is my implementation of Iterative Closest Point algorithm in C++. The code is written using the Eigen library. I have tried to implement an efficient coding methodology best to my knowledge however, I believe there are still improvements that can be made in terms of vectorizing the code and getting rid of for loo...
stackexchange/codereview
I have this below Data Structure. The output will be like m - n - o - p - q - r - s -t Please review the below code and let me know if any optimization can be done. public class Application { public static Node root = null; public static Node temp = root; public static Node anotherTemp; public stat...
stackexchange/codereview
I have a script I need to "duplicate" and modify to allow it to delete certain images based on properties I give this app/script. Currently the script just moves/sorts the images into folders based on numbers (e.g. each folder has 5000 images before a new folder is created and more images propagated). The requirement o...
stackexchange/codereview
This question has been superseded by C++11 lock free collection similar to std::forward_list - follow-up 2 Thread safe and lock free collections are very hard to write, so I'd appreciate any feedback, especially regarding bugs. The code below is a self contained cpp including some tests. This question is a new iteratio...
stackexchange/codereview
I've created a Java class, Date, in which I basically create date strings and set dates. Is there anything I can do besides adding comments to improve/shorten my code? I've tested all of my methods to see if they work correctly, and they all work as planned. I haven't done tests that force the IllegalArgumentsExcepti...
stackexchange/codereview
I am working on an online newspaper/blogging application with CodeIgniter 3.1.8 and Twig. I use the Twig template engine for the front-end views. I have put together this simple contact form which uses a controller, a view, and no model. The controller: class Contact extends CI_Controller { public function __const...
stackexchange/codereview
The task: Write a method that takes in a string. Your method should return the most common letter in the array, and a count of how many times it appears. Model solution: def most_common_letter(string) most_common_letter = nil most_common_letter_count = nil idx1 = 0 while idx1 < string.length letter ...
stackexchange/codereview
Please take a look at this little snippet of code and explicate on whether there are an efficiency enhancements that you'd make for it. It standards a row of a pandas.DataFrame by adding zeros to it so that the total length of the datum is the same as the longest datum in the column Sample "solubility.csv" file for tes...
stackexchange/codereview
I'm trying to put together a workflow for building Clojure applications with Boot in CIDER. To test this workflow, I've written a small example application using Seesaw. My project structure looks like this: example ├── build.boot ├── dev │   └── user.clj ├── .dir-locals.el └── src └── example └── core.clj ...
stackexchange/codereview
I've been a procedural PHP programmer for a long time but I'm getting to learn OOP and would like some advice. I'm designing a class which currently is composed mainly of simple getters/setters, but I'm not quite sure if I'm designing my class in the best way possible. The getters require accessing a database to pull t...
stackexchange/codereview
The function itself is just returning as void. But, the point of the posted code is not about what the function is returning. It is the code related to using T-SQL and C# to return data from a SQL database that I would like reviewed. Especially the way the using statements are structured. public void GetOffice(int ...
stackexchange/codereview
Probably a dumb question but just can't seem to make a decision here. I'm building a C# class library that I intend for other developers to use. Let's say one of these classes contains a method that accesses a remote resource and maps it to an object: public class FooClient { public async Task<Foo> ShowAsync(strin...
stackexchange/codereview
Use these links to understand the code I'm posting below since although it looks like PHP it is not: Function Reference Language Reference I have been making a programming language for some time now as a good learning experience etc and improving my programming skills. I'm making a full clone of the original Pengo. ...
stackexchange/codereview
I wrote this simple app for creating a Stock Exchange platform. It is written with a flask framework. My main concerns are regarding the user_page route which feels too long and not DRY enough, But on the other hand, I can't find a pythonic elegant way to clean it. I would really appreciate your comments. I am not sure...
stackexchange/codereview
This is more like a share and a request than a question. I converted Eric Lengyel's code, which calculates tangents of a mesh for the purpose of texturing and normal mapping, to support SIMD. For this I used DirectXMath library from windows SDK. I don't know if this is actually faster than regular floating point versio...
stackexchange/codereview
The following is my code for printing all the substrings of an input string. For example, with "abc", it would be "a","ab","abc","b","bc","c". Could someone please review it for efficiency (and possibly suggest alternatives)? void findAllSubstrings(const char *s){ int x=0; while(*(s+x)){ for(int y=0; y<...
stackexchange/codereview
I'm making a little script to run on the background and notify me when I received a new email in a mailinator inbox. I want to eventually daemonise it, but for now it just runs like a regular script. Could you give me some pointers about the code itself, the code structure and so on? I'm not sure if I should have my fu...
stackexchange/codereview
The module measures input clocks. It requires some reference clock. There can be from one to five input clocks to measure it. Output values are usual unsigned ones. As expected, it should be reset before starting. If it is used in Vivado, the user can choose the number of ports to show, depending on the number of input...
stackexchange/codereview
I've been working on a little problem where I need to compute 18-digit numbers into their respective prime factorization. Everything compiles and it runs just fine, considering that it actually works, but I am looking to reduce the run time of the prime factorization. I have implemented recursion and threading but I th...
stackexchange/codereview
Today I encountered something that I have been wondering about in the past a few times before. How can I refactor a method that has this format: private boolean isRectificationUpgradable(Rectification rectification) { final boolean validType = rectification.getType() == RectificationType.VH || rectific...
stackexchange/codereview
I managed to get this code working. But I would like to find out how to tidy it up. Please give me some guide. In index.js, I have this code: var API = require('./../controllers/rounds.js'); var getToken = function() { var promise = new Promise(function(resolve, reject){ API.getToken(function(err, token) {...
stackexchange/codereview
This is a question from GeeksForGeeks Given an array of integers, find a combination of four elements in the array whose sum is equal to a given value X. Input: First line consists of T test cases. First line of every test case consists of an integer N, denoting the number of elements in an array. Second line consists...
stackexchange/codereview
I have this function that I hope to be a good alternative to the recursive (thus performance expensive) approach. #define _free_all(node, yes_no) \ do { \ Tree *__i; for (__i = node; __i; __i = __i->yes_no); \ free(; node != __i; __i = __i->parent) { \ free(__i->value); \ ...
stackexchange/codereview
This function serves me as a testing-utility to check if the result is really numeric and sometimes as input-validation if there are a lot of operations before I would find out (with an Exception) if it's not-numerical. But I feel like the .dtype.kind in ... is too complex. I've written this function a while back and ...
stackexchange/codereview
I'm new to Observables. I'm using them to check if the user is logged in or not in the constructor of my root page. I have nested many Observables in order to do this, and they are working fine, but I think that there is a way to flatten all of these nested Observables. I just want you to review the code and let me kno...
stackexchange/codereview
I have a black & white video as a tensor with the shape [Time, Width, Height] with popcorn noise and I would like to reduce the noise by naively convolving along the time dimension. Using a Pytorch forum post as a starting point, I wrote the following function: import torch from torch import nn # dummy input tensor in...
stackexchange/codereview
I'm implementing a communications protocol in an embedded system and the protocol uses a subset of the ASN.1 BER (Basic Encoding Rules). In a nutshell, this class simply represents a TLV triplet (Tag, Length, Value) in which the Tag is some label identifying the type of data, the Length is the length of the Value (in ...
stackexchange/codereview
I'm still learning PHP OOP, so I'd like to seek for some expert advice or criticism regarding this code I created. In this script, I created the objects I need to process the user input from a form. While the $homepage object is responsible for displaying the whole webpage. My questions are: Is this consider clean cod...
stackexchange/codereview
Basically I have a 2d list containing movies. Movies are specified by name, version and description. For example ['Jaws', 1, 'Movie about sharks'] - where Jaws = name, 1 = version and Movie about sharks = description. My result is a dictionary which contains a map between name and description. But name should be updat...
stackexchange/codereview
I implemented the following function: the ruler function 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, . . . where the nth element in the stream (assuming the first element corresponds to n = 1) is the largest power of 2 which evenly divides n I'm giving it a vague name in the event that students try to cheat and s...
stackexchange/codereview
I wrote this method in order to generate a sequence number based on a specific pattern: public string LatestNumber(Guid id = default(Guid)) { var number = ""; if (id == Guid.Empty) { var items = myList.ToList(); var lastNumber = items.Any() ? items[items.Count - 1].Number : ""; var ...
stackexchange/codereview
I need to delete all the orphaned SIDs in the ACLs of about 20 shares (between 100GB/6TB) and change full control of users groups to other permissions (modify or read/execute). I have done this script but I'm pretty sure it's easy to improve. Any advice? $root = "\\192.168.1.1\folder" $log = "C:\log.txt" #log creation...
stackexchange/codereview
I've been been working on a vertical histogram that prints an asterisk in place of a number in a certain range (say 1-10... and so on). My code is working as required. Is there a better, simpler or more efficient way of doing it? If so, would you mind explaining or showing me better code if you have it handy? import ja...
stackexchange/codereview
DO NOT RUN THIS EXAMPLE BLINDLY, IT REMOVES ALL FILES UNDER argv[1] Hello, This little programm should read all files from a given directory and do some work with them. New files are constantly written into the directory by an outside process. For the duration of the processing, the file should stay in the input direct...
stackexchange/codereview
I know this may be a silly question (I'm just learning about recursion, and I think there are still things that are still not clear to me.), but... is this a good implementation of a recursive function to find the maximum number in an array? #include <iostream> #include <cstdlib> using std::cout; using std::endl; /* ...
stackexchange/codereview
I've been thinking of using this: template <typename T> inline T from_string(const std::string& s){ std::istringstream iss; iss.str(s); T result; iss >> result; return result; } in my code. Then I thought "I shouldn't construct istringstreams all the time", and made it into this: inline std::istringstre...
stackexchange/codereview
This question is a follow-up of this one; where I present a software to plan and manage drone races. I might come with a new question about the SQL part in a few days as well. The code can still be browsed on GitHub. Since then, on top of the changes in documentation that I made in my own answer, I included the gettext...
stackexchange/codereview
Suppose we are given a C++ vector. We want to specify a variable amount of indices and select elements from a vector being indexed. I have two implementation: (A) one relies on C++11 initializer lists, and the second one (B) on va_list and macro mess. Arrangement B is however funkier to type because it requires no typ...
stackexchange/codereview
I'm an HTML beginner. I've created my very first HTML + CSS single page from template given to me on a course I attend at a university. The code is probably very bad. It would be really nice if someone could tell me what to notice, how to make things different, what to learn and what path to choose. Below you can see t...
stackexchange/codereview
I trying to implement Huffman Codes on C. And, since my previous attempt failed, I decided to approach the issue more responsibly. So I'm asking for feedback on my implementation of the priority queue on C. First of all, the design of structures and interfaces is important to me! Also, how easy would it be to implement...
stackexchange/codereview
How can I optimize the performance of the code below? Destruction of the condition variable at the end of main blocks, not sure why this behavior is occurring. Is it possible to remove some of the sleep statements and while loops? What are other general best practices for proper implementation of this type of program. ...
stackexchange/codereview
Brief: This is a question geared towards optimization and general better coding practices. I'm self-taught in VBA so I'm cautious of bad practices, but they do come up. My Reasoning: I break the links (break_links) because these new files would be sent out and I don't want the external references to cause errors withi...
stackexchange/codereview
In order to better understand functional programming in Javascript, I thought I'd try to recreate (as well as extend) some of the higher order functions on the Array object. These methods don't intend to be identical but to have the basic functionality. Any tips/suggestions/feedback would be greatly appreciated! // Arr...
stackexchange/codereview
I created a function for creating a new user in AD, assigning an o360 license and enabling mailbox, however, my code is very chaotic and I do not have a much experience with PowerShell. Could you please advise on any improvements, code optimization or generally what could be done better? Function CreateUser{ #$GroupsAv...
stackexchange/codereview
I recently dived into Ruby, so I want to improve this code. Is this good enough? def ranksystem logfile = IO.readlines("some_logfile.log") logfile.each do |value| value.gsub!(/[\n]+/, "") end logfile.delete("") logcount = Hash.new(0) logfile.each do |v| logcount[v] += 1 end ...
stackexchange/codereview
Background I'm attempting to write a physics simulation code, one portion of which involves simulating the triggering system of some equipment. The equipment works as follows: environmental noise (which we may model as a Gaussian-distributed random variable) is taken in as data in numChannels independent streams at som...
stackexchange/codereview
Recently I have discovered one thing, which makes me feel frustrated. The Perl is lack of syntax sugar for strings, to do the same things, those are applicable to lists. The implementation I posted here would require to be rewritten to work for lists. Thus, I had to re-write the code to Python to work for list as effic...
stackexchange/codereview
I took a crack at solving the problem of finding the averages of all subarrays of length k. Here is what I came up with. I would greatly appreciate your feedback on my code. #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; vector<double> findSuseqAverages(size_t k, ...
stackexchange/codereview
One of my friends told me that my validate.php file has some problems with SQL injections. Please feel free to commit it on GitHub. <?php session_start(); error_reporting(0); include("../config.php"); $conn = new mysqli($hostname, $username, $password, $db_name); $query = mysqli_query($conn,"SELECT * FROM `Admini...
stackexchange/codereview
I have the following code which builds up a dictionary of endpoints that I iterate through later on. Is this the cleanest, most scalable and performant way? I was thinking of adding a list as a key to the library file with keywords but I didn't think that was maintainable. The code works in both scenarios, and as menti...
stackexchange/codereview
This code simulates a polygon (say a triangle) with a person at each vertex, every person is looking at the next adjacent vertex/person. They all start moving towards each other with a constant velocity "trying to chase other". I could not understand this conceptually so I created an applet in Java to help me understan...
stackexchange/codereview
I have a set of predefined templates for messages, where you can insert different arguments to make it more specific. In order for the messages to be looking good I needed a way to capitalize the first letters of each sentence because you might pass the argument fully lower-cased while in some messages that argument h...
stackexchange/codereview
I want to create a container that has an AutoList object list. I wonder if my container is correct. class Auto{ string model; int co2; public: Auto (); Auto(string m, int c); ~Auto(){}; string GetModel(){return model;} void SetModel(string s){model = s;} int GetCo2(){return co2;} voi...
stackexchange/codereview
For a school project, I am creating a text-based adventure game in C++. I have shown my code to my teacher and he is stating my code is not entirely logical in sequence and that I should make my if statements inside functions because there are so many. I need help as to know how to make these changes. Note that this i...
stackexchange/codereview
Is there any way to improve this code? Using ES6 style i am using latest stable version of node.js. const UserSchema = new mongoose.Schema({ date: string; dateObj: { year: number, month: number, day: number }; project: string; task: string; hours: number; }); let data = new Data(); data.date = new Date(bod...
stackexchange/codereview
My ASP Core web application was recently upgraded from NET6 to NET7. Almost zero problems except one, which still puzzles me. With the "old" NET6 version, once an user log then app in (without the "remember me" flag), his/her access was granted for several hours. I never measured exactly how lasted, but I remember pret...
stackexchange/codereview
I have a complicated Dagger 2 use case on Android, where I have a lot of dependencies, but some of them are really slow to construct. Like 2-3 seconds slow. My solution was to create an RX Observable that will be provided through Dagger's injection mechanism to other components, instead of waiting for the slow compone...
stackexchange/codereview
Given a folder typically containing ~250,000 small (20-100kb) files in HTML format (they open as single-sheet workbooks in Excel) and a list of ~ 1 million filenames, I need to open all the files that match the list and Do Stuff. Overview of Main code Loop: "Test 1 Start" to "Test 1 End" Once we get to the main file lo...
stackexchange/codereview
(Last Post) Mail Crypt CLI encrypted email wrapper for Gmail I've spent the past few days re-writing the logic of my program as a library to improve the structure and readability of my code. The idea behind MailCrypt is for it to be a python based client/library that allows you to locally encrypt messages and send them...
stackexchange/codereview
The following is a shopping cart class. The initial version of this was pulled from a production application. Since then it has changed a bit but I'd love to hear your feedback on this. Due to having multiple files, the full source can be found here. Cart.php <?php namespace maldoinc\utils\shopping; use maldoinc\util...
stackexchange/codereview
So I've been working on a simple little hashing algorithm for Python that I like to call PRBHA-10 for short, or Pseudo-Random-Based Hash Algorithm. This is a hash algorithm in Python that is meant to be simplistic and secure. As you could see from the title, the algorithm implements a system with seeding the pseudo-ran...
stackexchange/codereview
I am relatively new to programming and OOP in PHP. I tried to create a Simple Login Register Script using my basic knowledge of OOP. I'm sure my code can be better in a lot of way. I'm trying to code better and learn new things. Be harsh, please find out as many small noob mistakes as you can. Suggestions and Feedbacks...
stackexchange/codereview
In short - I've started with C# not so long ago (which means you find a lot of poor written code here) and now I'm aiming to create a dialogue system. Though my code is working as it supposed to, questions are: How to make everything not this lame and improve the code Suggestions about improving performance Overall ad...
stackexchange/codereview
I wrote a memory bus struct in golang to allow systems to interact with each other without knowing anything about the receiver. This is for a game engine. I know it's not good to write games in garbage collected languages like golang, but I enjoy writing in golang so whatever. But since golang has a garbage collector ...
stackexchange/codereview
I wrote an application that has a modular structure. Each module communicates with different remote servers. Time for execution of a task in each module varies. So communication should be asynchron. Plus some restrictions like flexibility, scalability and so on are put. So i decided to use CompletableFutures to build ...
stackexchange/codereview
When integration testing Rails applications HTTP request helpers can take a string or a named route as the first argument. I find myself writing: test "user visits edit page" do homer = users(:homer) get "users/#{homer.id}/edit" assert_response :success end But I can also write: test "user visits edit page" do ...
stackexchange/codereview
I am trying to solve a programming problem on a coding platform. When I execute it on my PC, it works perfectly, but when I submit the code on the coding platform, it throws a "Time Limit Exceeded" error. Can someone check my solution and help optimize it? Given a number N, the program must print the pattern as descri...
stackexchange/codereview
I have here some code which is working but it seems to be a lot of coding to do here. I would really appreciate if someone could make this simpler. <!-- *********************************************** --> <div class="widget search-w"> <div class="wrapper"> <div class="big-icon search icontap"><a class="widg...
stackexchange/codereview
The following is the story of a UserCredentialsDto that arrived at one of my endpoints and how it finds its way through all the layers namely REST Layer Service Layer Repository Layer Persistence Layer The example below is very simple and one could argue that anything more complex goes towards over engineering but I...
stackexchange/codereview
After dipping my toes in PowerShell for over a year i think it is time for creating a real cmdlet. My first mission was creating a regular PS script to take in a .csv and create a wifi account using the Aerohive REST api. Although it works, i find the script bloated and ugly, and want to swap large code block for prope...
stackexchange/codereview
I'm going through the 99 Haskell problems and I have a few question about the solution I implemented for Problem 23. It asks: Extract a given number of randomly selected elements from a list. This is the code I came up with: -- Extract a given number of randomly selected elements from a list. import System.Random ra...
stackexchange/codereview
Several days ago, a question on this topic was posted to SO. The problem turned out to be the OP's test cases did not reveal a deficiency in the code. This challenge caught my attention. Writing the following has provided entertainment for a number of rainy hours. I've had a look at several "Review" postings (looking f...
stackexchange/codereview
I've been working on this elevator program for quite some time now and finally finished it and made it work and I'm pretty proud of myself, but I'd like to see ways how to refactor my code so I can learn for the future. By refactoring I mean, making the code look better, maybe by using less lines of codes. public class...
stackexchange/codereview
I've made a simple game for testing math facts (think practice for elementary school-age kids). It displays a random addition, subtraction, multiplication, or division problem, and feedback on if the right answer was entered. For now it works interacts with the user via prompt(), but I plan to add a GUI later. You can ...
stackexchange/codereview
I just wanted to ask if this is a secure code (doesn't really matter if it's optimal or not) The code if(!$_SESSION['logged']){ if(!$_POST['inputlogin']||!$_POST['inputpassword']){ require 'cpanellogin.php'; die(); } else{ $con=mysqli_connect("localhost","root","","librarydb"...
stackexchange/codereview
I am trying to improve my coding skills in Java by taking existing code, studying it, and adding on to it. In this code example, I took code from Connect Four game in Java and edited it. The most major edit I created for the game was that I created a GUI for this game. From looking at the code, are there any suggestion...
stackexchange/codereview
I wrote a script for Python 2.78 which is supposed to download and save a file from a given URL using the requests library. In case that a connection to the server can be established and a valid response is received, the response (e.g. a HTML file) should be downloaded to hard disk. If the server gives a bad HTTP respo...
stackexchange/codereview
I'm starting to learn Clojure, and would like feedback on some code I wrote to manage database migrations. Any recommendations to make it more robust, efficient, idiomatic, elegant, etc... are welcome! (ns myapp.models.migrations (:require [clojure.java.jdbc :as sql] [myapp.models.database :as db])) ...
stackexchange/codereview
As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8. The structure is the following: Class for exception throwing. The Card interface. The Hand class. The HandTest test class. public final class ExceptionUtils ...
stackexchange/codereview
I was looking at some Linq queries with multiple join statements. I was thinking that they could be cleaned up using extension methods that hide away the join / where statements. For example: (from myObject in _context.MyObject join myObjectGroupName in _context.MyObjectGroupNames on myObject.TaskGroupNameKey equals my...
stackexchange/codereview
So I saw a need for and came up with a class implementation to group constants, which I'm calling a Constant Class. I wondered if there existed other similar implementations or if there is a flaw in what I'm doing. My team is currently finding it fairly useful and thought we should see what other people thought. Also t...
stackexchange/codereview
Last time we posted here we were overwhelmed by the useful feedback. We've had another go at OOP/programming - this time in Java. Very different than Python! As before we have lots of concerns at the macro level (is our choice of objects any good?) and the micro level. We'd be grateful for any suggestions for improveme...
stackexchange/codereview
I was hoping I might get some feedback and ideas for improvement on this, particularly the WebRouter class. #include <native/native.h> #include <rapidjson/writer.h> #include <rapidjson/stringbuffer.h> #include <cppconn/driver.h> #include <cppconn/connection.h> #include <cppconn/statement.h> #include <cppconn/prepared_s...
stackexchange/codereview
We are being needlessly curtailed by the standard-supplied function containers, a lot more flexibility is possible. Try any_function, which can contain an arbitrary functor without having to specify it's signature. namespace { template <typename> struct signature { }; // template <typename> struct class_ref; // temp...
stackexchange/codereview
I decided to give the maximum sub-array sum problem an interesting go, however I will assure you that it doesn't perform well, and that I would never put this in production. I'd like a review on this, if possible, it would be cool to see the running time, I'm sure it's upper bounded by at most \$O(n^3)\$, but it may ac...
stackexchange/codereview
I completed an algorithm problem just as a personal study, and I can't help but feel like my solution is a bit needlessly complicated, although I can't figure out a better way to do it. Here's the problem : Given a number N, and a list of users currently on a stage, find out the failure rate of each stage up to N, an...
stackexchange/codereview
From SICP Exercise 2.69: The following procedure takes as its argument a list of symbol-frequency pairs (where no symbol appears in more than one pair) and generates a Huffman encoding tree according to the Huffman algorithm. (define (generate-huffman-tree pairs) (successive-merge (make-leaf-set pairs))) ...
stackexchange/codereview
I started studying programming in January of this year and found a free online course that teaches Ruby. Below is my solution to the Eight Queens problem. I wanted my solution to be able to return any valid n-queens puzzle solution in a non-specific order. I'm looking for feedback such as: On the continuum of good or ...
stackexchange/codereview