instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I want to improve my implementation for the following problem: You are given an array of n integers. A sub-array is "Negative" if sum of all the integers in that sub-array is negative. Count the number of "Negative sub-arrays" in the input array. Note: Subarrays are contiguous chunks of the main array. For example i...
stackexchange/codereview
Looking at the SDL library. Looking to load images from file into an SDL_Surface using the SDL2 Image API to do this I need to implement the SDL_RWops object class in terms of a C++ stream. The reason I want to use SDL_RWops and use a C++ stream is so that I can do a tiny amount of wrapping and use the standard C++ ope...
stackexchange/codereview
I want to solve for n in the expression (binomial coefficient): \$y=\frac{n^2+n}2\$ let y = (Math.pow(n, 2) + n) / 2; I know the \$y\$ value, but I want to compute \$n\$. Here is what I have so far, but I would want to know if there was a way to compute the value rather than look it up. In this example, I have to loo...
stackexchange/codereview
I decided to learn more about how interpreters work and made a simple Scheme interpreter in Python. I'd like to hear some advice on how I could have written this better, or on the mistakes I've made. Parser.py (I thought about putting the Tokenizer and Atom classes in different files, but they are too small for that. M...
stackexchange/codereview
I know the following code are horrible, so I'd like a review. Criticism are welcome. I want to know what went wrong, and how I can avoid the same mistake in the future. Version 1 const unsigned int set_max {32}; std::vector<unsigned int> base; base.reserve(argc-1); for (int i = 1; i < argc; ++i) { unsigned long tmp;...
stackexchange/codereview
I am new here and learning Laravel 5 on my own. I want to get reviewed on the following routes.php code. My question are: Have I made any mistakes by doing this? If yes, then what could be the possible solution? Have I followed the proper convention? Do I need to optimize my code? If yes, then how do I optimize it? ...
stackexchange/codereview
I recently gave an interview and was asked the following question. I posted this here Finding path in Maze also, and someone suggested I should try Code Review. So here it goes. A maze is a group of linked Places. Each Place has a North, South, East, and West Place adjacent to it. There are two special pre-defined Pla...
stackexchange/codereview
From Hackerrank: Given a string S, find the number of "unordered anagrammatic pairs" of substrings. In other words, find the number of unordered pairs of substrings of S that are anagrams of each other. Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Inp...
stackexchange/codereview
I've just started teaching myself Scala to get my feet wet with functional programming, and I'm messing with around with some classical cryptography. The following code produces monoalphabetic simple substitution encryption, but I'm still trying to wrap my head around both Scala itself and functional style, so I'm sure...
stackexchange/codereview
I have cleanly separated functionality of a message bus - namely the diagnostics (optional), sending, decoding and the bus driver, I need to now bind this together and have done so with a MessageBus class. It feels anemic though, with a lot of pass through methods. On the flip side it is necessary for coordinating Star...
stackexchange/codereview
I'm learning object-oriented programming in Python. I've created a class RepositoryMaker that contains all methods required to create a Git repository. The idea is to be able to create a single instance of this class with a constructor that only requires pertinent info to create a new repo. My code looks like this: cla...
stackexchange/codereview
I am trying to implement a helper program for a paper RPG game. In this game, there are a lot of "roll tables". Basically, those are tables which associates the result of a dice roll to a concrete result. For example, you could have something like that: 1 | Roll is 1 2 - 5 | Roll is between 2 and 5 6 - 7 | Roll is ...
stackexchange/codereview
A while back this question proposed a constexpr compile-time Sieve of Eratosthenes. It also linked to another SO question about compile-time computation of CRCs. I've found a place where I'd like to precompute the hash of a few C-strings, so I used those previous questions as a base. I'm implementing the one-at-a-time ...
stackexchange/codereview
I am working on a Boid simulation with 10,000 boids. I've successfully utilized geometry shaders and an array<GLfloat[3], MAX_BOIDS> for vertices to enhance display performance. Currently, I can display 500,000 boids moving randomly at 60 FPS. However, the neighbor search is a bottleneck. With a naive search, I'm deali...
stackexchange/codereview
I'm new to VBA programming so the following code may look terrible which is why I want ways to understand how to better optimize it and other future codes. Sub Sequence() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Application.DisplayAlerts = False Dim unique_string1, unique_string2...
stackexchange/codereview
I've recently started working on a java project, and the main purpose of it is to get better at Java. I've decided to make an IRC bot for twitch. But after some hours of progress I already see my Bot class growing. And that leads me to believe that I'm learning bad habits or I'm just doing it all wrong. So I would love...
stackexchange/codereview
I have created this prime number generator. I want it to be as fast as possible, but I am wondering if there is a faster way (there must be). #include <stdio.h> #include <stdbool.h> #include <limits.h> bool is_prime(const unsigned long long); int main( void) { puts("2\n3"); for (unsigned long long n = 5;...
stackexchange/codereview
This is a follow-up question based on the original one. Could you please see the updated and refactored version and point at things to be improved in term of logic or efficiency? I have now know as I have been made aware about the Greedy Algorithm; Math.Max and binary shifting which deal more gracefully with the task, ...
stackexchange/codereview
I have written an application for lawyers' offices. There is an API to fetch info about court cases. I have implemented API calls for front end when user enters particular case; one tab is filled with info from this API about this case's state in court. This code is run from a daily cron job; for all the cases in my ap...
stackexchange/codereview
I have a string of Hebrew text which also contains":", "-", & "|". Attempting to replace "-", "|", and ":" with a space. How can I do this efficiently? string my_string = "עַל־פְּנֵי:על־פני|על־פני"; string[] replace_chars = new string[] {":","-","|"}; foreach (string char_change in replace_chars){ if(char_change ==...
stackexchange/codereview
This code takes an item as an argument and deletes all occurrences of the item in the linked list. It works well with my testing. Is there anything that I am missing? Can this code be improved further? void LinkedList::DeleteAllOccurences(int key) { Node *temp = head; Node *prev = head; while(temp!=NULL) { ...
stackexchange/codereview
I am writing a Model to read, write and store settings. I think my code is pretty good, but I am not 100% sure. Any advice on how I could possibly improve it is welcome. import ntpath import yaml class Settings: def __init__(self, paths=None, default_path=None): """Load, write and store settings ...
stackexchange/codereview
I have a couple questions about this program Should I implement runnable instead of using thread class? I like the idea of the consumer and producer being thread objects, it seems simpler to me, but I have seen people argue the benefits if runnable interface. Are static methods in the main class considered good/bad c...
stackexchange/codereview
This is a second rev of this SE Question. How can I add more validation to this .ico file downloader? It works but I need a way to check the integrity of each step: Check Default location ( checked length is greater than 20 ) ( broken for test.com ... why ? Check Google API ( validation already added ) Scrape page for...
stackexchange/codereview
The following code compares two dates and checks if they are within 15 minutes of each other, with a tolerance of a second. All of the test cases below pass with the existing solution. The question is can it be improved by making it more efficient and/or elegant given the following test cases. TestId, whenCreated, when...
stackexchange/codereview
Just published (GitHub) a C# example for object Validation, for this purpose I decided to use the .NET Reflection and tried to use Generics. I would really like to improve coding, can you please give me for your feedbacks / reviews / improvements and also new features to implement ? Here's the code: using System; using...
stackexchange/codereview
I'm trying to process a large dataset (300GB, myfile.txt in the script) line by line using multiprocessing. I want to define a 1% random sample based one variable (contained in unique_ids_final.txt). My first step is to define the sample and then I want to read the data file using multiprocessing. I would like to impro...
stackexchange/codereview
I am new to Spark and Scala and I have solved the following problem. I have a table in database with following structure: id name eid color 1 John S1 green 2 Shaun S2 red 3 Shaun S2 green 4 Shaun S2 g...
stackexchange/codereview
The exercise is asking to make wider stripes similar to the previous exercise. I've included the exercise and code from it along with code that I've been messing with to get the desired result. I know it can be done easily with loops, but the point of the exercise is to use what has been already introduced in the book....
stackexchange/codereview
My final version is a direct translation from Python. Thanks to build-in support for generator, its speed is almost the same as Python. As I quite like using generator and list comprehension in Python, I am not sure I get the right way in Racket. Moreover, I've only found explicit support for generator in Racket these ...
stackexchange/codereview
I want to inform the Receivers about new contracts we have this week. After I sent the Emails, the Information about sent contracts are stored in MS SQL Database. To avoid that someone become the same Email about contract more than one time I perform this steps: I have the Collection with new contracts as the input I ...
stackexchange/codereview
I'm pulling data from a list of images and passing it into an information container after click. After looking at my logic I assume there is a better way to do this. Any ideas would be helpful. var getData = function() { $('.guest-image').html('<img src="' + $($this).data("image") + '" />'); if ($($this).data("know...
stackexchange/codereview
I have recently been teaching a JavaScript module on a games programming undergraduate course and I made this game as a learning exercise and as an example for my students to study. I have made games before but never in JavaScript. Could you have a look at my style and let me know if there are any obvious improvements?...
stackexchange/codereview
I'm new to python, and I wrote the following code. Please review, critique and enhance. This project compares quicksort, mergesort and bubblesort write/test the partition routine for quicksort. (20 points) The rest of the code is given. write/test the merging part of the mergesort. (20 points) The rest of the code i...
stackexchange/codereview
First I explain the data to give context: We have the following folder structure: atlas caballo cabeza etiquetas cabeza01-es-latin.txt ... cabeza20-es-latin.txt original cabeza01.nrrd cabeza01.png ... ...
stackexchange/codereview
I am working on a project where the hotspot is some code that is supposed to find an offset, such that the squared differences between a reference vector and a given vector becomes minimal. The core function is this: #include <vector> #include <map> typedef std::vector<double> vect_d double sqDiffSum(const vect_d& ref...
stackexchange/codereview
I found this question in an old exam in computer science. I solved it in a good way, but I'm not convinced that my solution is the best solution. I believe that there's a better way to solve it. Given N Columns that are lined up, The horizontal distance between two adjacent columns (The lower edges) is exactly 1 met...
stackexchange/codereview
What are the best practices to writing clean, expandable game code? I always end up getting overwhelmed with my games because the code gets very unorderly. I use OOP (java), but I still feel like my code is unorganized. I will get examples below. The blocker class is basically like a pipe in flappy bird. It moves aroun...
stackexchange/codereview
I've been a .NET Developer for almost 4 years. I'm stronly learning and trying using design patterns and following SOLID principles for 3 months right now (I know - a little late, but better late than never). I have complex business logic for saving some metadata in database (mainly jsonb object to postgresql database...
stackexchange/codereview
This is a wrapper for an API. For now all it does is get a certain document or search for relevant documents from a document store -- although I plan to build out more features later. I'm new to PHP and want to both improve my PHP skills and develop "idiomatic" PHP style. It depends on HTTPFUL, which, for now, is being...
stackexchange/codereview
So I was playing with writing FizzBuzz in Elixir; this is my first, naive implementation: defmodule FizzBuzz do def getFB(n) do cond do rem(n,15) == 0 -> IO.puts "FizzBuzz" rem(n,3) == 0 -> IO.puts "Fizz" rem(n,5) == 0 -> IO.puts "Buzz" true -> IO.puts "...
stackexchange/codereview
I got a keylogger Powershell script to protocol my input, since I'm quite paranoid if someone uses my PC. However, some letters (I have an anti-ghosting keyboard) are swallowed if I type them in fast. Does anyone see a bottleneck here? I believe it's either the fact that: it can't recognize keys pressed at the same ti...
stackexchange/codereview
I am trying to solve the lowest common ancestor problem in Rust. It is guaranteed that the id's of the tree are unique. It is also guaranteed that the two nodes which we are looking for in the tree actually exist. My code is below. use std::rc::Rc; use std::cell::RefCell; use std::collections::VecDeque; // Definition...
stackexchange/codereview
NOTE: I am beginner in Python I learnt the Heap sort today and tried my own implementation using Python. Can i get feedback for my code and areas of improvement. I have tried to add comments inline, but if still something is unclear, then i will add more comments. def max_heap(listmax): i = 1 # if there is on...
stackexchange/codereview
I implemented the caesar cipher along with a writer/reader and a command line interface. package caesar import "fmt" // ShiftOutOfRangeError denotes a shift which is as great or greater than the character count of the alphabet, zero or negative. type ShiftOutOfRangeError int // Error return the formated error messag...
stackexchange/codereview
I wish to use this sample to make my code more readable. Could you share with me your ideas on method naming, variable naming, if-statements etc. It would be great if you have any URLs. private boolean areEngineersHappy (List<Engineer> engineers) { int notHappyEngineers = 0; int happyEngineers = 0; for (Engineer ...
stackexchange/codereview
I wrote a little ruby script to download issues of PragPub magazine and send them to my Kindle via email. I would love to get some feedback on it. One part, specifically, where I feel like there might be a better way is where it downloads the file and writes to disk. It used to do this: open(filepath, 'wb') do |file| ...
stackexchange/codereview
I have a list of dictionaries and its elements has id and parent_id fields. Main purposes: If the parent_id field of an element is defined, it should be returning the rest of elements except itself. If the parent_id field of element is not defined, it should be returning the rest of elements. In other words, its all c...
stackexchange/codereview
I've created a MiniStack to assist in removing recursion from routines using a manual stack. Obviously if the stack is an object it lives on the heap and its creation and destruction takes a significant amount of time. Therefore any heap based option is out for loops that create and destroy the TStack. Is there anythi...
stackexchange/codereview
I have written this code for an Edx course called CS50x (a beginner course). This problem set required me to write a program which: loaded a dictionary into some sort of data structure (I choose to implement a trie) and which could take an input text and search for misspellings uses a file with an already implemented ...
stackexchange/codereview
The following code gets years (dates), 1 and 2 years back (for example 2017 - 2016) and 1 and 2 years into the future (for example 2019 - 2020). Now PHP is not my expertise so I would like to get some help cleaning this up. Is there a different approach I should use when doing this? //Filter jaren $year = date("Y"); $...
stackexchange/codereview
This is my first real program, though it has gone through a few major revisions. Anyhow, I am sure that there is a lot I could have done better, cleaner or safer. Can anyone see anything I really need to work on or fix? #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <time.h> #include <getopt.h> #in...
stackexchange/codereview
The problem of 3sum is described as: Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Here is my code, am I right to say its complexity is O(N2), and how can I further optimize my code? Here I am using Has...
stackexchange/codereview
I've just tried my hand at Quicksort, and I seem to have gotten it working (thanks to Stack Overflow). However, is it "true" Quicksort? And is it decently written? public static void sort(List<Integer> arr, int left, int right) { int i = left - 1; int j = right + 1; if (right - i == 0 || right -...
stackexchange/codereview
Here is my code for "Reverse Binary Numbers" in C. Problem Your task will be to write a program for reversing numbers in binary. For instance, the binary representation of 13 is 1101, and reversing it gives 1011, which corresponds to number 11. Input The input contains a single line with an integer \$N\$, (where ...
stackexchange/codereview
As a part of library implementing websocket Guice scopes I need to maintain an object related to each HttpSession called sessionContextAttributes. Currently sessionContextAttributes is stored as an attribute of a session, which means the access and initialization needs to be synchronized: ConcurrentMap<Key<?>, Object> ...
stackexchange/codereview
I have an array of hints. Sometimes, this array could contain an empty string. Occasionally, the array might contain only empty strings, in which case I want the whole block to be skipped. This is what I came up with: <% @hints.each do |hint| %> <% unless hint.empty? %> <p>Please observe the following hints...
stackexchange/codereview
Let's assume I have 2 objects Product and Volume. 1 Product must have at least 1 Volume which means: Product ----> 1...* Volume. I want to keep the consistence of Product at its creation, in other words, I want to block the user to create products without any volumes. I have a ready working code, but nonetheless I want...
stackexchange/codereview
This is from a high performance server that needs to block anyone who is doing more than limit requests per seconds seconds. You call check and if it returns true you process the request, otherwise you block it. It maintains a circular queue, initialized to 0, of the last times the event was triggered. I use time() bec...
stackexchange/codereview
I wrote a very simple Python interface for C++ that uses the Python 2.7 C API. At the moment it can: Manage reference counts/deal with "stolen" references (PyObject) Load Python module Invoke a function (templated) and get result Convert between intrinsic Python and C++ types Notes I am not an expert in template meta...
stackexchange/codereview
I was given the following instructions Using the below HTML, using ONLY CSS, JavaScript or jQuery create the following (see attached gif animation): <div>This is a cube</div> <div>This is a triangle</div> <div>This is a big, green circle</div> Rules: The HTML cannot be modified in any way For the animation portion,...
stackexchange/codereview
There are a lot of numerical properties to be invoked many times with an expensive calculation. Let’s say for the sake of example, they expose a Factorial: public class Analysis { public double n10 => F(10); public double n100 => F(100); double F(int n) => n <= 1 ? 1 : n * F(n-1); } I was looking ...
stackexchange/codereview
I have the following working code, but it is too slow because I have to run the same code for several files inside a folder. Please help me avoid the nested for loop or make it more efficient. columnNames = {33:"boy", 24: "girl"} events = [{1:"bo", 2: "irl"}, {1:"oy", 207: "gir"}, {1:"bboy", 2: "girly"}] def create_ga...
stackexchange/codereview
The code seems to work, but, I always get the "Time Limit Exceeded" error (the time limit defined is 6 seconds). I even tried reducing the number of iterations but am still running short on time. I am basically trying to find the number of 5's and 2's, to obtain 10. #include <iostream> int number_counter(long int x, i...
stackexchange/codereview
I'm working on a program that uses the RIOT API League of Legends for collecting player data and calculate how skilled a player is by using a grading system (as of right now it just the average of the last ten games for each skills). Realize I used a lot of class, what is a better way to do it? import requests #ASKI...
stackexchange/codereview
An embedded project my team is working on is having issues with sensor drift over time. To solve this, I thought it might work to use a high-pass filter, since the portion of the signal that we care about is generally at a significantly higher frequency than the drift. I'd like feedback on if this is a good general app...
stackexchange/codereview
The goal here is to notate and produce essential PDF reports. The For loop takes an id number and puts it into specified calculator worksheet. The workbook is set to automatic calculation so all of the necessary values update. Then it copies the result then saves as PDF a set of worksheets labeled Report The code works...
stackexchange/codereview
I have been slowly evolving some code for Git and VSS interop based on a quest I started a while ago And the code is now working, some parts have been updated without test (such as the init) and I am not 100% sure everything is doing what it should/is the best way and some parts seem really round the houses! Its certai...
stackexchange/codereview
I was wondering if someone could please point me in the right direction with this bit of JavaScript I have been working on. I have made this form that currently has onblur JavaScript validation and additionally I am to make it dynamic so that when a user selects an option from a dropdown option form a div is shown with...
stackexchange/codereview
I have code that sorts two lists related with each other """ list1 reperesents customer list2 reperesents amount of products they have brought """ list1=['a','c','e','i','o','u'] list2=[12,23,45,10,7,2] list3=[] for i in range(0,len(list1)): list3.append([list1[i],list2[i]]) print list3 """ [['a', ...
stackexchange/codereview
I needed a function for sorting two corresponding arrays. So I wrote this code to sort N corresponding arrays! The really "metaprogrammy" way to do it would be to use std::sort with a custom zip_iterator, but since zip_iterator's operator* returns a "proxy reference" type which is not Regular, and std::sort doesn't see...
stackexchange/codereview
I have a list of images in a folder where num denotes the index of image and I used num to run the iterations in a "for loop". The code is supposed to segment brain part from the brain CT images. Here is the link for region growing algorithm. How do I increase the performance of my region-growing algorithm? % CORD_XY(1...
stackexchange/codereview
This is a question from the book "Cracking the Coding Interview". Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer NOTE: One or two additional variables are fine An extra copy of the array is not This is not the efficient code, but I want to pre...
stackexchange/codereview
I wrote a Python program that performs an integration of data using Simpson's rule. The program takes the areas to be integrated from a foo.ref file, with the following syntax: # peak m/z charge window LAG_H4N4F1S1 4244.829467 1+ 0.06 LAG_H4N4F1S1 4245.832508 1+ 0.06 LAG_H...
stackexchange/codereview
I have a need to express something like this: while(bytesToWrite > 0) { // get the NEXT location to write from a Key/Value collection of locations // read a packet from a file at the specified location // write some bytes to the packet bytesToWrite -= bytesWritten } This was my first attempt: var di...
stackexchange/codereview
I have a DelayQueue, and the goal is to collect statistical information from the collection in O(1) time and space from getStatistics(). The stream for loop does not provide it. However I thought of keeping statistics updated on add of a transaction. But this will not guarantee that at the time when the getStatistics()...
stackexchange/codereview
I have created a function which returns the number that corresponds to the given row and column from the pascal triangle. I have used the formula for this: n! / r! * (r-n)! The code: def pascal(c: Int, r: Int): Int = { def factorial(number: Int): Int = { def loop(adder: Int, num: Int): Int = { if(...
stackexchange/codereview
I am currently developing a Unity-based multiplatform game (PC, iOS, Android) in a small team. This is the code we have created for the character actions inside the game. I am looking for feedback on the code itself as well as tips on how some Unity features could be used better. This is my first time developing a game...
stackexchange/codereview
I have written a template for a C program implementing a simple test framework. If the program is run with the first parameter "test", all subsequent parameters will be interpreted as a sequence of test cases (without the test_ prefix) to be executed. If no other parameters are specified after the first parameter "test...
stackexchange/codereview
Is there any way to make that code shorter? I still want to use jQuery. I don't want to use any validation script. $("#form").submit(function (e) { var tmp = $('#select-1').val(); var tmp1 = $('#select-2').val(); var tmp2 = $('#select-3').val(); var error = $('#error-1'); var error2 = $('#error-2'); ...
stackexchange/codereview
I made a tower-defense game in Python with Pygame called "Bunny and Badgers". You're a bunny and must kill the badgers before they come into the castles. You can use W, A, S, D and the arrow keys to move around and press a mouse button to shoot. You can also use a joystick to control it. The game dures 1 minute and 30 ...
stackexchange/codereview
I asked for feedback on my Dice class and I was suggested that I should separate logic from view. I decided to completely refactor my project and I'd like to share a small piece of it (the Dice class and connection between logic and view) and ask for feedback again. So lets start with logic::Dice namespace logic { ...
stackexchange/codereview
My usual disclaimer, I'm new to Python and scripting and I'm still studying the PEP8 guide, so please forgive any huge failures with respect to syntax, formatting and style. I'm open to any suggestions in regards to pretty much anything so let me have it! That said, I've been building little games to learn so far, but ...
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 new in Go and for study I have to hold a presentation about concurrency in Go. I think the Golang Tour - Webcrawler exercise is a nice example to talk about that. Before I do that, it would be nice if anybody could verify if this solution fits. I assume it is correct but perhaps I have missed anything or any of yo...
stackexchange/codereview
I am using the ancestry gem to organize my post categories tree. I have 8 parent categories, and they all have many child categories. To retrieve an array of child categories, I use: parent_category.children I defined these relations in my category model: has_ancestry has_many :posts has_many :users, through: :...
stackexchange/codereview
I'm a Python noob. This is the code I'm using: for i in argv[2:]: # argv[1] isn't required by s.py if ' ' in i: argv[argv.index(i)] = '"%s"' % i args = ' '.join(argv[2:]) os.system('s.py '+args) Is there a more elegant way to do this?
stackexchange/codereview
I've created a module that implements a basic "Document at a time" algorithm for inverted index querying (more background here). There are many algorithm improvements possible, but I'm now interested in feedback on the structure of the Erlang code, specifically: Unneeded verbosity / code Erlang 'style' mistakes Thing...
stackexchange/codereview
I have a main-class that takes a list of sources and returns two objects for each source; one with the required data and one analytics tool. The Analytics-class has different methods depending on what source it is. The Data-class extracts data from different paths and cleans the data in different ways depending on the ...
stackexchange/codereview
A while ago I was experiencing 'flakiness' on my home ADSL line. I run a Linux server in my basement, VOIP, and a few other things (like Netflix) and I was experiencing a few minutes of network downtime every few hours. This was dropping very important things, like the kids watching cartoons, and my phone-calls with my...
stackexchange/codereview
I am following the Odin Project and building the Library project. It is very simple, just render a list of Books and we can add and delete books from the list. However, I feel the code can be improved hugely, as it is getting too messy and I am not sure if I am using the class in the right way. This is the JavaScript: ...
stackexchange/codereview
for clarity: moved here from stackoverflow after being pointed to Code Review being the better place for this question I love async/await and Promises since I got my hands on them. And I might be overdoing it, but it feels like there should be a good and readable way to utilize async/await to get a little closer to a f...
stackexchange/codereview
First of all: Hi, my name is Henrik and I am a mechanical engineer, who loves to code in his free time. To get better in programming I wrote a genetic algorithm compined with a list planning algorithm (giffler thompsoon algorithm) to solve the fjssp (i have encountered this problem in my master thesis 2 years ago). Alt...
stackexchange/codereview
I randomly decided to write a program that tests the Birthday Problem/Paradox. The gist of the problem/paradox is that if you have a group of people in a room, how many people are required for there to be a 50% chance that 2 people will have the same birthday? Near 100% chance? It turns out only 23 people need to be in...
stackexchange/codereview
I find IndexedDB cumbersome and want to wrap the functionality with rxjs observables. I've come up with an angular2 service that seems to fit the bill, but I'm wondering if I'm using the observables correctly or if there might be any subscriptions I'm missing (plnkr): Usage: this.localDbService.set('storeName', key, v...
stackexchange/codereview
I am still learning Laravel and I am in the process of creating a small shopping website. On the left hand side there are a series of filters that appear depending on what products have come back from the search, to allow the user to filter their search further. For example, if none of the products searched for return ...
stackexchange/codereview
Helo everyone, I need to review on function swapNode in doubly linked list. It works but I want to make it clearer and better. Are there any errors like memory leak in my code? #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> struct node; struct list; typedef struct node node; typedef s...
stackexchange/codereview
I'm making an Angular web app to solve a pain with traditional messaging my friend and I had, of sending batches of messages (on multiple different topics) to each other every few hours and not having a UI optimized for that style of conversation. I have a few concrete questions (and of course welcome anything else use...
stackexchange/codereview
I appreciate any feedback on where I might alter or improve my code for this project. This is an old attempt at implementing a Hierarchical State Machine in F#. I'm from a C#/OO background mostly. module FSharp.HSM open Option open System.Collections.Generic exception NoTransition exception NotInitialized exceptio...
stackexchange/codereview
Because the throughput of my radio and device is limited, I wanted to compress my control string. I decided to compress the command into an 8 bytes (quasi) string (throttle high, throttle low, pitch, roll, yaw plus/minus, yaw value, checksum, stop byte) and after parsing in four variables: Pitch (between -45° and 45°)...
stackexchange/codereview