instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
FizzBuzz was fun, and I got great feedback and learned a few things (which I hope I put in practice here), but only scratched the surface. I wanted to explore the LOLCODE language a bit more, so I implemented a little rock-paper-scissors, to play with functions, parameters, return values.. and user input. Unfortunately...
stackexchange/codereview
This is a follow up to my previous Code Review, and I have incorporated feedback I received in this revision of the code, along with some other improvements. I would appreciate your feedback on this code, specifically the practice of placing project-wide constants in config.h, the count_missing_letters method which use...
stackexchange/codereview
Recently I was studying about the benefits and uses of std::optional in C++17 (Bartek's Blog) and there I saw a line that said "std::optional can be used for Lazy Loading of Resources" . Upon digging a little bit, I saw that C++ does not have native support for Lazy evaluation. So I just gave it a try and wrote the fol...
stackexchange/codereview
I'm new to Python 3, and I tried to test if my palindrome code works and passes most of the edge cases, so I created the following 2 Python files. When I ran the python3 test_palindromes.py on the terminal, it shows that 2 tests passed. And I was wondering if that is sufficient for my palindrome function. I think I hav...
stackexchange/codereview
I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using join for string concatenation. I've read about...
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've been working with binary files with this last assignment and part of it was to determine the maximum and minimum byte. Initially this was 2 functions but a bonus portion was to make them into 1 function through usage of an enum, I imagine to reinforce their utility. I would like to know if there are better ways of...
stackexchange/codereview
The primary purpose of this program is to practice catching if the user enters data that does not correspond to expected input. Note if the user enters their name as "123", this is valid as it can be used as an identity, however if users enter only spaces (i.e. " ") or just a newline char then their input will be re...
stackexchange/codereview
I made this random password script. It works, but i think it is kind of bloated. The part where random characters are being added is the area where I think it needs work. I don't want to declare if and else statement for every combination of lowercase list, uppercase list and digits list(I am taking input from user whe...
stackexchange/codereview
I'm new at PowerShell and I like it. I had the change to write a script that uninstall Erlang and RabbitMQ and I want the same script to then remove the Erlang folder and the RabbitMQ folder. But in order to do so I need the script to respect the tasks order. My way out was to use Write-Verbose (line 13) so the scri...
stackexchange/codereview
I am facing a issue with an API to handle dates in Java. I am not a very experienced programmer and my English is very bad. Problem I'm working in a large project with many subsystems, and I want to make a Date Utility library to manage all dates in the system. Requirements Platform The front end is a JSF page with Ri...
stackexchange/codereview
I have input of a string containing a single number (like: \$3\$) or a range (like: \$1-5\$). Sample input, all together, looks like: "1-5,3,15-16", and sample output for that input looks like "1,2,3,4,5,15". Output doesn't need to be sorted. I built something to parse this, but it's ugly. How can I improve this? from ...
stackexchange/codereview
I'm attempting to implement driver-layer (shared library) from top-level app to hardware. In the first, I extracted interface functions, which further will be called from "extern "C" SHARED" wrappers to separate class IDriverInterface. In the second, I want to hot-test some functions before the correct implementation a...
stackexchange/codereview
I have a class ConfigFile that reads some values from a JSON using Boost and stores them in variables. Everything is done in the constructor: ConfigFile::ConfigFile(const std::string& configFileNamePathIn) { PTree tmpPT; std::string path; /// reading aws config file /// json::read_json(configFileNamePa...
stackexchange/codereview
For example, given 15 integers 70, 75, 32, 4, 64, 98, 73, 52, 36, 88, 96, 58, 79, 39, 75 How can we obtain is 72? 4 operators can be used for the 15 integers to get the equation to the answer of 72, which are + - * /. Divison is only allowed where there is no remainder. A few answers will be 4+32+36+39+52-58-64-70+73...
stackexchange/codereview
I am trying to detect the content/mime type of a given Buffer/string. In other words, I am trying to guess what on earth is a given string. My approach is somewhat brute-force: /** * Check if valid url encoded. * For now I set the value as true * @param {String} body * @returns {Boolean} */ const isValidFormUrlEn...
stackexchange/codereview
I cooked up a FFT code in c++ for calculating with arbitrary data size. The czt function is copied from GNU octave's czt.m. Here's the code, #define _USE_MATH_DEFINES #include <vector> #include <algorithm> #include <exception> #include <cmath> #include <complex> #include <future> #include <chrono> #include <random> #in...
stackexchange/codereview
Of course the recursive version is trivial: hanoi n = solve n 1 2 3 solve 0 _ _ _ = [] solve n from help to = (solve (n-1) from to help) ++ [(from,to)] ++ (solve (n-1) help from to) However my iterative version looks terrible with a lot of code repetition: hanoi n = map rep $ solve [1..n] [] [] where rep (x...
stackexchange/codereview
I'm making a Minecraft clone and have made an Object Pool. Looking for some advice on how I have implemented it. Uses m_availableObjects as a O(1) way of searching for the next available object. Thank you in advance. constexpr int INVALID_OBJECT_ID = -1; //Internal Use - Object Pool template <class Object> struct O...
stackexchange/codereview
My first program using Classes, it should allow you to set the price of three different pumps, times how long you pump, then calculates what you owe, and updates the amount of gas left in the pump. Working on an associates degree and my teacher doesn't give any critique so anything you all could point out would be help...
stackexchange/codereview
I feel that my app could be more efficient but I am not sure what else I can do. I feel like I could be reusing more. If you could give me some tips on how I could improve this, I would really appreciate it. public class Main { /** * @param args * @throws InterruptedException */ public static void mai...
stackexchange/codereview
This is my first foray into (modern) Fortran in order to learn a bit more about the language, and I'm attempting the following problem: taking the path of an arbitrarily-sized text or binary file given as a command line argument, output to stdout the contents of the file in reverse (i.e. the first byte becomes the last...
stackexchange/codereview
I redirect all my requests to index.php via htaccess and the code below is in my index.php. I want to ask if my code is properly set for a custom 503 page for an unsuccessful MySQLi connection trial. Is it also proper to use these metatags? <meta name="robots" content="noindex,nofollow,noarchive"> <?php $mysqli = new...
stackexchange/codereview
For fun, I have been working on this game I called Star Catcher. It's a very basic game where stars are falling and you try to catch as many of them in your bucket before you miss 10. It's a real mess of code that I just threw into one file, basically. The animations seem to be working fairly smooth for me on my comput...
stackexchange/codereview
I have a search form where users can enter ValidFrom and ValidTo dates, There are three conditions: ValidFrom and ValidTo NOT NULL Action: Get values between two dates ValidFrom is NOTNULL and ValidTo is NULL Action: Get values where date is greater than ValidFrom ValidFROM is NULL and ValidTo is NOTNULL Action: get v...
stackexchange/codereview
The function asks the user for a value to search for, then deletes all matching values in the list. The program runs flawlessly, but I can't figure out a simple/elegant way of separating cases for 'first node', 'last node', and 'intermediate node'. Please help me make it more elegant and readable. I'll post the relevan...
stackexchange/codereview
I made this snippet for reviewing my DS textbook. Is it okay to write iterative loops in function _upheap and _downheap? Any other suggestions or feedbacks are welcome. Thanks. # heap.py # by kidkkr # Mar-14-2017, 07:29PM class Heap: __slots__ = '_data' def __init__(self): self._data = [] def __...
stackexchange/codereview
I was given a homework assignment to code a console Guess the Number Game, where the user should guess a random number. Also, I had to code a simple menu with switch where I can change a random number origin/bound and attempts amount. Please, give me some tips how could I improve the code and where I'm wrong. P.S. I mu...
stackexchange/codereview
I have written the following code to practice parallelizing a PyTorch code on GPUs: import math import torch import pickle import time import numpy as np import torch.optim as optim from torch import nn print('device_count()', torch.cuda.device_count()) for i in range(torch.cuda.device_count()): print('get_devic...
stackexchange/codereview
I'm writing a tool to create shortcut menus for an application that I maintain built on the Access runtime. I compile this app into an *.accde file, so much to my chagrin, all right click menus are disabled. After some research, I've been able to develop this tool to add the menus to the database. This code is called ...
stackexchange/codereview
I have recently adjusted the way I create my mysqli connections. Initially I would include the connection file and use if($mysqli->connect_error)... in my main script. Now I check if there is an issue with the connection within the connection file. If there isn't an issue then I just check that the variable name for th...
stackexchange/codereview
I suppose this is a two-part question. The first part is just a simple implementation of a Binary Tree (BTree), with pre-order, post-order, and in-order searches implemented by default. The second is the AmorphousBTreeCreator(amorphous because the trees sit in a sort of limbo until they are assembled into their final f...
stackexchange/codereview
I wrote a program, that gets a certain array and replaces each value in the array with the distance from it to the closest zero value. Time complexity is \$4n\$ => \$O(n)\$. (please correct me if I'm wrong, though). But I can't figure out what's my space complexity. The task was to make it as efficient (by time and spa...
stackexchange/codereview
I'm trying to develop a text-based game. Here is the concept-demo version. class Arena { public static void battle(Hero h1, Hero h2){ h1.setHp(h1.getHp()-h2.getPhysical_attack()); h1.info(); } public static void main(String[] args) { System.out.println("Entering Arena ..."); ...
stackexchange/codereview
I have taken the code from a tutorial of Microsoft webpage. Of course, the example is for illustration only but I wanted to organize it and make it clear in order to understand it a little more. Here the link: https://docs.microsoft.com/en-us/windows/desktop/winsock/complete-server-code It almost the same but structure...
stackexchange/codereview
I am implementing A064604 - OEIS for positive integers up to 10 billion. I am finding the divisors in \$O(\sqrt N)\$. So, the overall time complexity of running the formula right now is \$O(N\sqrt N)\$. How do I improve on this? Pastebin import math def factors(n): return set(reduce(list.__add__, ...
stackexchange/codereview
I am trying to write a Haskell application that parses a bunch of complex numbers from a Mathematica output and then produces a PPM image. The end product looks like this: The code to create this is as follows: module Main where import PPM import System.IO import Control.Applicative as A import Control.Monad.ST impor...
stackexchange/codereview
Lately I've been working on a small C++ Entity-Component-System framework. Like most other ECS frameworks the internal data is presented as a table where an entity is a simple row index and each Component type maps to a column index. In contrast to many other C++ ECS frameworks that usually map the Components to the in...
stackexchange/codereview
I've been studying the event sourcing pattern and trying to come up with a set of classes or minimal library I can share across projects. Below you can find the implementation of this main parts of this pattern including the EventStore and Repository. I'd be thankful on getting a review on whether this is what the patt...
stackexchange/codereview
In a table there is a number of column (chambre) and a number of row (alveole). If these matches in a list in an other sheet then it checks if it the date is between two dates on that second sheets. If it matches those 3 things, then it puts the sheet My code works if I add DoEvents in every For, else Excel and VBA sto...
stackexchange/codereview
When is it better to instantiate the sftp client globally vs inside a function as shown below? What considerations favor one method over the other? For a long running service that polls indefinitely, would it better to instantiate globally so I don't need to instantiate a new client on each run? Also, is there any diff...
stackexchange/codereview
Is this the best way to encrypt/decrypt data? And Is it good to store Generated InitVector and CipherText in database as Base64 String which is converted from byte[]? import javax.crypto.SecretKeyFactory; import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.PBEKeySpec; import javax.crypto.*; import java....
stackexchange/codereview
I implemented a simple maze generator as practice and I wonder what can I do to improve my C++ skills. I saw this implementation and used it as an inspiration for some parts of my code link. I am a little bit confused about usage of the 'inline' keyword. Should the definition of an inline declared method be in .cpp fil...
stackexchange/codereview
I repeat here this answer on Stack Overflow. I first posted an answer with not finalized code, as a simple description of the solution I could think, without any test. But later I remained interested, so I worked to make it (hopefully) perfectly functional. To precisely define what it is meant to do, let me cite my pre...
stackexchange/codereview
Trying to recognize objects real time using TensorFlow Object Detection API OpenCV using ssd_mobilenet_v1_coco_11_06_2017 model in GPU. # What model to archieve. MODEL_NAME = 'ssd_mobilenet_v1_coco_11_06_2017' # Path to frozen detection graph. This is the actual model that is used for the object detection. PATH_TO_CKP...
stackexchange/codereview
I'd really appreciate some general formatting/style/performance tips, as well as any ways I could improve this code in general that I wrote for an assignment (title) that's due at the end of the week. The code passes every test input given (leap years and such), so the logic is all set. I had the HashSet as a List or...
stackexchange/codereview
I recently took a self-assessment question to assess my Python ability for an online class. The problem was to return the frequency of a word occurring, as part of a tuple. Implement a function count_words() in Python that takes as input a string word_string and a number number_of_words, and returns the n most frequ...
stackexchange/codereview
One of my frameworks uses the ISettingConverter interface as an abstraction for serialization. public interface ISettingConverter { [NotNull] object Deserialize([NotNull] object value, [NotNull] Type targetType); [NotNull] object Serialize([NotNull] object value); } It is implemented by the abstract S...
stackexchange/codereview
What my program does I'm trying to estimate for how many minutes in average a football(soccer) match will be in different game states depending on implied goals of both teams. Problem domain For our purposes there are three possible game states: Home team is ahead, e.g. 1-0 Both teams are drawing, e.g. 2-2 Away team i...
stackexchange/codereview
I've wrote a pretty useful method to prevent multiple requests per single get url. There is a well known pattern - to store promise and return it for each next request. But there is too much copy/paste for my taste. So, please check my solution. Maybe you can give me advice to make it better or maybe point at any mista...
stackexchange/codereview
I have an implementation of a Quantum CNN on the MNIST dataset but right now, the code is just a bunch of standalone functions that call one another: # Dataset preparation (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() # Normalizing the data between range of 0 and 1 x_train = x_train[..., n...
stackexchange/codereview
I am trying to print out the squares of n numbers, n which is a value retrieved from the user. I want to know if there is a better way to do this: #include <stdio.h> int main(void){ int i, n; printf("This program prints a table of squares.\n"); printf("Enter a number of entries in table: "); scanf("%d"...
stackexchange/codereview
I want to differentiate between comments I make for (1) myself, (2) team members, (3) on business rules, (4) on watchout notes for hardcoded constants, (5) on ideas for improvements, and (6) on general flow of the code. Right now all my comments look the same. I'm open to any other tools. I don't know how bookmarkin...
stackexchange/codereview
The idea of the game is that the player and the computer take turns entering either 1, 2, or 3, and that number is added to a running total. Whoever goes over 21 loses. I need to develop a strategy that lets the computer always win. I have a strategy worked out, but I was wondering if there is a more efficient way to d...
stackexchange/codereview
I am developing this angular app and it has big forms with 100 + fields. I was thinking about using [(ngModel)] without reactive forms, so that it's easier to do validations and I only have to provide the same JSON to the web service endpoint. Is this a right approach? Reactive forms export class ProfileEditorComponent...
stackexchange/codereview
I just faced a problem where I needed to know if extra data was present in a given collection after a Take operation took place. Specifically, this is related to generating @odata.nextLink values in an OData-enabled API only if there is remaining data on the server: the user should not receive a "nextLink" if no more d...
stackexchange/codereview
The idea is to implement the observer pattern, with a separate notification method for each observed property of the observed object. Let me start with a simplified use case: class Point { val observers: ObserverSet<PointObserver>() val x by observers.observe(0f, PointObserver::xChanged) val y by observers....
stackexchange/codereview
I'm trying to parse a char* into an int without using atoi(). I walk through the string, check if it's a valid digit, then add that digit to my integer by multiplying by 10 and adding the digit. I am not accepting negative integers. Here's the code I'm using: #include <stdio.h> #include <stdlib.h> #include <string.h> ...
stackexchange/codereview
I'm reading the book Head First Java and got an assignment to re-create the 99 Bottles of Beer song according to those lyrics found in the URL. I've had to do this with a Java while loop. class SecondBeerSong { public static void main(String[] args) { int beerBottles = 99; String word; whil...
stackexchange/codereview
This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner? format ELF64 executable 3 segment readable executable entry $ prompt_user: mov edx,prompt_len lea rsi,[prompt] ;<------ String mov edi,1 ; STDOUT mov eax,1 ; s...
stackexchange/codereview
As working on a little private programming challenge, I tried "Rock Paper Scissors" without arrays or if-statements. It works as intended, though, I am sure this can be done a little bit more optimized. Especially in the context of Math/Programming. What I try to achieve: Create 2 Players, one Computer one Human. The...
stackexchange/codereview
Back on track with my C++ saga: The standard deviation of a list of numbers is a measure of how much the numbers deviate from the average. If the standard deviation is small, the numbers are clustered close to the average. If the standard deviation is large, the numbers are scattered far from the average. Th...
stackexchange/codereview
Edit: How should I interpret the silence? On a scale from 0 to 10 where 0 means "Bloody awful" and 10 means "Nothing to complain about". I'm mainly concerned about readability and things I don't seem to be aware of. If the code is readable, I won't need to explain it. #!/usr/bin/python import os import sys import sub...
stackexchange/codereview
I've written a simple web service which allows a user to shutdown or reboot a system from the LAN. Although written to be used on an RPI which lacks a power or reset button, it can be used on any Linux system. Aside from the missing secure login (I'm assuming everyone on the network can be trusted at this moment), I'd ...
stackexchange/codereview
I have some PHP code where I use variable functions to call the right function. I need to build a chart array (for example), and the chart array that comes out has a fixed format. But the data that goes into the chart or table comes from varying places in the underlying objects. An example: private function buildChartG...
stackexchange/codereview
I have a function that returns rows from my database, and it works fine, but I was told that it was poorly written, and there is a lot of unnecessary code in it. I'm wondering if there is a simpler, easier way to rewrite this function. function gd($query) { global $connect; $fetch = mysqli_query($connect, $que...
stackexchange/codereview
I perform a mean blur on a number[][]-array (called grid in the code). I iterate the array, and calculate average values from adjacent "cells". The kernel size defines how many adjacent values are used for average calculation. /** * Performs a mean blur with a given kernel size. * @param {number[][]} grid - Data grid...
stackexchange/codereview
I've implemented a wrapper for AES 256 CTR mode using the cryptography.hazmat module, I am wondering if there are any vulnerabilities in my implementation, specifically about the counter and its encoding. Here is the code: from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.cip...
stackexchange/codereview
I was solving this sorting problem, and I was wondering if I can get any code review and feedback. You can find this problem online. # Find Kth Smallest Element in a Range # # Prompt: Given an unsorted array of whole integers in the range # 1000 to 9000, find the Kth smallest element in linear time # ...
stackexchange/codereview
This is the implementation of both Deterministic Finite Automata (DFAs) and Nondeterministic Finite Automata (NFAs) on r7rs scheme, using only SRFI 1. The file automata.scm contains the implementation of the procedures to make a DFA (make-dfa), make a NFA (make-nfa) and run either one on a string (automaton-run). The f...
stackexchange/codereview
These two functions search for directories with a certain prefix that contain no files of a given type. Does the code adhere to Ruby standards and conventions? Am I doing something the hard way or the "non-Ruby" way? Should I use more/fewer/different comments? def find_empties(directory, dirprefix, fsuffix) empty_...
stackexchange/codereview
The goal is to print the highest version and second highest version of the list of files. The version is based on the first three digit places of the version. For example, version 2.3.0.1 version is just 2.3.0 (ignoring the last digit). Once it can print the highest version and the second highest version of the list, i...
stackexchange/codereview
So I have tried the famous string permutation algorithm. Example for those who are not familiar with the algorithm: ABC -> ABC, ACB, BAC, BCA, CBA, CAB public static HashSet<String> stringPermutation(String s) { HashSet<String> perms = new HashSet<String>(); stringPermutation(s.toCharArray(), perms, 0); ret...
stackexchange/codereview
Over the past week, we tried to make our AngularJS model layer more powerful and reduce complexity in our controllers and template by using the object-oriented programming pattern and the CoffeeScript class keyword. You can see the result here: http://plnkr.co/edit/c1uxN6ZorQzOVizlzU5Y?p=preview This is our Base class ...
stackexchange/codereview
I wrote some code to execute remote commands over ssh, using expect, from c++. The code works but is a bit of a mess of c / c++ since there doesn't seem to be an idiomatic way to achieve much of what I wanted in pure c++. I appreciate that there are nominally some security concerns with the way I'm using passwords, but...
stackexchange/codereview
I have a young friend of mine who is starting to learn Python in school and asked me to give him a little assignment. I am in no way a teacher nor a Python expert, but I accepted. At first I thought it would be fun to start with a bit of parsing for the operation's input, like: Enter your operation : 3+3 But it seemed...
stackexchange/codereview
I would like some help refactoring this code. This is to improve some of the nonfunctional attributes of the software to improve code readability reduce complexity to improve the maintainability of the source code. package Game; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListe...
stackexchange/codereview
I've finally got a solution for a "weekly streak" bucketing system I've been working on but unfortunately it's resulted in a very large switch statement. I'm running through a handful of dates and determining by a range of seconds (the length of a week) which bucket that date belongs to. It's obvious to me that this co...
stackexchange/codereview
I made this code to take user input, making a specific-sized array and printing user-inputted numbers after being sorted. It works well but I was wondering if there was a way to "shrink" it down. It seems a bit redundant to me but I don't know how to change it without messing it up. Or is it fine as it is? .data array:...
stackexchange/codereview
i am trying to create a semicircle menu with animations and texts. Currently i try to position the texts in the semicircle which is only working with a specific window-width and browser. This is my current approach: https://codepen.io/Jxner/pen/xxGBKYJ .menu { padding: 0; list-style: none; position: relative; m...
stackexchange/codereview
Please give me any comment about these codes. Does it enough to prevent SQL injection? What I have to do to make the code better? <?php /** * Description of MySql * @name MySQL PDO * @version 1.0 * @author Yauri * */ class MySql { private $mPDO; public function ...
stackexchange/codereview
Explaining the idea and first steps Today, I had the idea to do a website which displays my current position. I searched in the App Store for an App and found one named SendLocation. This App provides an interface for sending GET requests to an server with some geometrical data. This is how the data gets send: http://y...
stackexchange/codereview
I use a lot of lambda expressions in C#, so I've decided to create some similar functionality in JavaScript. Since jQuery is included in my projects, I'm using $.grep() instead of Array.prototype.filter() to support older browsers without including shims. The two examples below corresponds to Where() and FirstOrDefault...
stackexchange/codereview
Jenkins DSL doesn't support collect and inject from what I can tell (I get missing method exceptions when I try), so I implemented my own map & reduce functions to use. I'm not sure if there's much to say about this small snippet of code, but I'd love to hear from some groovy or FP folks. def map = { collection, f -> ...
stackexchange/codereview
I am trying to write a cleaning service API using the Django REST framework, but I think how I defined this model is not robust enough for production and in turns will make any application using this API have a very slow response, example of what I'm saying is that the model has no indexes defined whatsoever. Running a...
stackexchange/codereview
I'd like to simplify this Scala code: private def getToken() = { val token = getTokenFromDb() token match { case Some(x) => token case None => { val remoteToken = getTokenRemote() remoteToken match { case Some(x) => { writeTokenToDb(x) remoteToken ...
stackexchange/codereview
i'm using an external API that posts products and orders into a marketplace, and it provides a class that in each request i have to specify an endpoint, user and password (token), it's something like this: if($env == 'testing') { $endpoint = 'testing'; $user = 'testing'; $pass = 'testing'; } else { $end...
stackexchange/codereview
Use case: I want to automatically save data in the storage when a property of an object that implements INotifyPropertyChanged changes. Therefore I subscribe to the PropertyChanged event and call a method that saves the object. Problem: It can be that a lot of properties change over a short period of time and that is a...
stackexchange/codereview
I made a very basic social network Java program. I was wondering if my design could be improved. I have 2 classes (+ 1 driver) : Person and Graph. I would like now to add a new method hasAccount(Person person) in the Graph class to check if a Person is on the graph. However, so far I don't have any data structure that ...
stackexchange/codereview
I have recently been brushing up on my statistics and calculus and wanted to implement Linear Regression, the code will be for a calculus/statistics library I am working on (I know there are libraries for this but I am trying improve my both coding and math skills). The following code works as intended. However, I feel...
stackexchange/codereview
I am new to Ruby on Rails. Can some one please help me with this question? How would you modify the following to be consistent with Ruby's style? class Add_dash def dashesHere(word) attachTheDashes = "--" + word + "--" return attachTheDashes end end
stackexchange/codereview
I'm a beginner developer in Python and I need some tips to improve my code, in performance (speed) and hardware usage. Is it possible to improve? And I have a question: is it possible to keep the browser (chrome/chromedriver) open after execution? The objective: to automate scheduling at the Italian Consulate, through ...
stackexchange/codereview
I have JSON files of size data_large(150.1mb). The content inside the file is of type [{"score": 68},{"score": 78}]. I need to find the list of unique scores from each file. This is what I'm doing: import ijson # since JSON file is large, hence making use of ijson f = open ('data_large') content = ijson.items(f, 'it...
stackexchange/codereview
I used the following Stack Overflow questions as references for writing this code: Select columns from result set of stored procedure What is the equivalent of String.Join on TSQL? The idea behind my stored procedure is to give an explanation of why a particular worker is unsuitable to care for a particular patient u...
stackexchange/codereview
I have Implemented Unique_Ptr with move semantics for the sake of Learning. Any suggestions, feed backs are highly appreciated. // author @asad_nitp #pragma once namespace Smart_Pointers { template<typename T> class Unique_Ptr { T* m_ptr; public: explicit Unique_Ptr(T* ptr = nullptr) noexcept : m_ptr(...
stackexchange/codereview
I made the bellow macro to create a time line in excel. It shows the working days, the week numbers and the month together with the year. First I start with projectstart date and projectend date. As these dates can be any working day and I want my timeline to start on a monday and end on a friday, I find the firstmonda...
stackexchange/codereview
I need to perform some expensive calculation, such as determining a Fibonacci number: /// Calculate the Nth Fibonacci number (inefficiently) func fib(n: Int) -> Int { n > 1 ? fib(n: n-1) + fib(n: n-2) : n } My project contains a number value types that need to perform calculations like fib based on their properti...
stackexchange/codereview
I have ported the code from my previous question "Generate a random numbers class" to C++14 and made a few modifications. How can I improve it further? #include <iostream> #include <random> template<typename T> class Random { template <typename U> static auto dist() -> typename std::enable_if_t<std::is_integra...
stackexchange/codereview
I'd like some feedback on the readability, style, and potential problems or issues. In particular I'm not too happy with how I handle ratelimits. import json import requests import pandas as pd import matplotlib.pyplot as plt from dateutil.relativedelta import relativedelta from datetime import date from flatten_json i...
stackexchange/codereview
I am practicing a problem in "Cracking the Coding Interview". The problem is to remove duplicates in a linked list without the use of a buffer. I interpreted this as not using a list or any large data structure such as a hash to store unique nodes. My algorithm is inefficient I think. It iterates an anchor across the ...
stackexchange/codereview