instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
As some of you might know I've been working my way through the C Programming Language (2nd). I recently finished a rough implementation of the itoa exercise (chapter 3). It's important to note that we haven't been introduced to any advanced subjects like pointers, dynamic arrays etc yet. The exercise is to create a str...
stackexchange/codereview
I'm an experienced programmer (mostly C#, JavaScript, PHP). Go is quite a paradigm shift and I want to make sure I'm starting on the right foot. This is my first Golang package. It's purpose is to be initiated and sent log lines (in the form of map[string]string to AddEntry. It's using channels since the lines could be...
stackexchange/codereview
I'd like someone to double-check my use of Atomic primitives, because multi-threading is hard. What I don't want to do is locking the whole get method, or having too many pre-checks per get() call. private final static AtomicReference<T> REFERENCE = new AtomicReference<>(); private final static AtomicBoolean IS_CREATE...
stackexchange/codereview
I'm working on a report of quality control. I have a list L, which contains the names of files that I should open and import the data into EXCEL, then fill my quality control table by these data. And at the end, I want to know which file in the list has not been opened, that means this file (or this point of control) i...
stackexchange/codereview
I have a lottery simulator on my website that simulates you playing the lottery every week until your death and tells you how much you would have won or lost. It can take a custom number of balls and rewards scheme, as I made it after Camelot changed the rules for the UK national lottery to give people an idea of how t...
stackexchange/codereview
I'm learning Clojure, and decided to write a Conway's Game of Life clone as my starting project. I ended up dicking around for a bit before diving in, and came up with a few functions that I'd like looked over. Mainly, I'm concerned about writing them more concisely and idiomatically. I'm planning on using a 1D vector...
stackexchange/codereview
The following function uses a cartesian system and has an agent who moves on the table like: F - forward, L - turn left, R - turn right. The code works fine but I would like to make it more efficient: import java.util.Scanner; public class HelloWorld { public static void main (String[] args) { int x = 0, y = 0...
stackexchange/codereview
Please comment about code complexity, and coding style, I'm preparing for a code interview, so any comment would be appreciated. Example: Input 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Output: 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 Code: using System; using Microsoft.VisualStudio.TestTools.UnitTes...
stackexchange/codereview
I am currently rewriting a todo app from java to clojure. This is my first "real" clojure project so I'm not sure that what I write is idiomatic clojure code. I have just finished rewriting the domain module and I'd like to know how can I improve on it to have something which is idiomatic. I had some simple classes in ...
stackexchange/codereview
I'm quite a novice in shell scripting so far, but i'm learning and getting quite comfortable in writing shell scripts, but i have a lot to learn. The snippet at the bottom of the page creates backups of a certain users databases. The script checks first if there is more than 7 compressed .gz files in a folder. Fetches ...
stackexchange/codereview
I'm working on a program that generates a maximal geometric progression of at least 3 integers when given a number that the greatest value shouldn't exceed. My current code works, and it's quick(ish) with small numbers, but anything past 100 takes far longer than I'd like, as I need to calculate numbers in ranges from ...
stackexchange/codereview
I'm often opening, from Excel, all Word documents inside a folder. And sometimes during the treatments, Word crash without throwing an error. So I've added a bit of error handling to restart Word and reopen the doc I was working on. I'm just wondering if I'm doing it properly, or if I should go further like : Test th...
stackexchange/codereview
My programs that I have written so far included only a few lines of source code. When I tried to write larger programs, it usually failed because I'm not a master of software engineering. This time, I want to play it safe and publish now from time to time parts of the program, which should be my first, successful major...
stackexchange/codereview
I am learning python by solving python module from HackerRank. This problem is Find the Percentage. You have a record of N students. Each record contains the student's name, and their percent marks in Maths, Physics and Chemistry. The marks can be floating values. The user enters some N integer followed by the ...
stackexchange/codereview
This is a fully functional code that i have just completed today. I just want to know how efficient is this. and how could i improve it or if theres any bugs that i have miss out. import os from AskUser import ask_user as As from random import randint #initialising the board class Board(): def __init__(self): ...
stackexchange/codereview
The code below takes integer n as input, and delivers a list of all primes up to integer n using the Sieve of Eratosthenes. My question is, could you please help me optimize this code? Is it considered poor code to use 'try' flow control? I'd like to optimize the code such that I don't need it. def factorfinder(n): ...
stackexchange/codereview
The method SaveGroupStepPermissions(...) is a database API class. If an error occurs within the method the exception is trapped. Whether this is good design or not is not the scope of this question as I need to adhere to product guidelines. I feel that this method is to complex and too lenghty. The obvious solution is ...
stackexchange/codereview
I've got a CSV that contains users and permissions in the below format, where users can have as little as one or as many as eight different permissions: USER,PERM1,PERM2,PERM3,PERM4,PERM5,PERM6,PERM7,PERM8 jdoe,perm1,perm2 tsmith,perm1,perm2,perm3,perm4,perm5,perm6,perm7,perm8 This is the desired format, with each uni...
stackexchange/codereview
I'm just starting to develop more in C# after being mainly a VB.NET developer and was looking for someone to critique my implementation of a NewtonSoft Json.Net serialiser. Can you provide some feedback on the following points: Is this a good way to build the class (using Unity)? Is it acceptable to be throwing an exc...
stackexchange/codereview
I have a POJO as shown below which will have hostname and other attributes. public class MachineInfo { private String hostname; // getters and setters here } I have my below method from which I need to randomly pick a hostname which is up for more than 10 minutes from machines list. The checkHostUptime meth...
stackexchange/codereview
I need to turn a lot of html elements as editable elements. You will double click on the element to edit, press enter to validate (send a PUT to the RESTapi), press esc to undo. I've written this piece of code. Are there any performance improvements to be made? var editable = (function() { var DELAY = 300, ...
stackexchange/codereview
Disclaimer: The following question is not related to any malicious activity. Only performance testing we are doing. I am working on querying an internal server with lots of requests (~20 million). I need it to be as fast as possible. How the algorithm works: 30 Threads (because I found that more can slow it down) ...
stackexchange/codereview
I am very new to Objective-C as well as objected oriented programming, and in a book I am studying from there is an exercise in which I was supposed to create a class called Rational, that has hidden data members called numerator and denominator, and methods to add, multiply, subtract and divide the Rational objects (t...
stackexchange/codereview
The task: Given a real number n, find the square root of n. For example, given n = 9, return 3. My solution: const findRoot = n => n >= 0 ? n ** .5 : void 0; console.log(findRoot(9)); Is this some kind of trick question? What's there to solve? Did I miss something?
stackexchange/codereview
This class sends "tweet" data to the client in the form of a custom markup language. How can it be improved? It is used in Ajax call and in previous post people have suggested not to echo the result..but this is my primary means of communicating with the server via Ajax responseText. Also <tw_p> is used to denote a pa...
stackexchange/codereview
I am trying to make an algorithm that will find the index of a given substring (which I have labeled pattern) in a given String (which I have labeled text). This method can be compared to String.indexOf(String str). In addition to general feedback, I'm curious what the time complexity of my method is, and would appreci...
stackexchange/codereview
I’m using decorator objects in a Rails app so that I don’t have to do nil? checks in views. Everything is working nicely and it’s easy to test, but I’m suspicious that my test:code ratio is a little high. Am I being too verbose? Is there a better way this could be done? Test suite: # spec/decorators/client_decorator_sp...
stackexchange/codereview
I got an interesting interview question related to JavaScript: In JavaScript please create a storing function called storingFn with the following characteristics: Read Cafefully Save immutable key-values. The values can only be accessed by storingFn and should not be exposed in the global scope. It can't use Browse...
stackexchange/codereview
I am coding an Objective-C MD5 hash "decrypter". Since you cannot decrypt such a hash function, I am approaching it with a brute force algorithm, that tries every single password combination until it found the correct one or not. I would highly appreciate any help to improve the algorithm to make it even faster. I am c...
stackexchange/codereview
Your method should accept a real number as a parameter representing a limit, and should add and print terms of the sequence until the sum of terms meets or exceeds that limit. For example, if your method is passed 2.0, print terms until the sum of those terms is at >= 2.0. You should round your answer to 3 digits past...
stackexchange/codereview
Hi I am new here and I just completed my first working version of a pokedex app with a GUI using tkinter. I used selenium to scrape the data from pokemondb.net, and then used pandas to clean up the dataset then finished it up with a tkinter GUI. The project is still in early stages and can be improved in the front and ...
stackexchange/codereview
This struct is used a lot throughout my programme. This struct is responsible for only things regarding colour, not anything else. I'm largely concerned of the bitwise operations, and the fact that I store four byte values in a uint but access them with bitwise flags. This is a concept I use throughout the programme. (...
stackexchange/codereview
My task was to create a function that returns the level of a user. A user has a certain amount of XP. Each level is level * 10 xp so for example level 1 would be 10 xp level 2 would be 20 xp level 3 would be 30 xp and so on however your XP doesn't stack so if you have 30 XP you would fill the requirements for leve...
stackexchange/codereview
PigLatin Kata PigLatin Kata Create a PigLatin class that is initialized with a string - detail: The string is a list of words seperated by spaces: 'hello world' - detail: The string is accessed by a method named phrase - detail: The string can be reset at any time without re-initializing - ex...
stackexchange/codereview
I was solving this Leetcode challenge about Hamming Distance. Would love feedback on my syntax and code style. Here's the challenge description: The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distanc...
stackexchange/codereview
I wrote a program to proxy MDNS requests in a local network to the DNS server. This is useful because in some private networks, host names ending in ".local" are configured in the DNS server. But ".local" is actually reversed for MDNS. Some systems have problems resolving these host names because they only try to resol...
stackexchange/codereview
This is exercise 3.2.23. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that creates an array of charged particles from values given on standard input (each charged particle is specified by its x-coordinate, y-coordinate, and charge value) and produces a visualizatio...
stackexchange/codereview
Currently I check whether a string contains all words from an array like this: function contains($string, array $array) { $count = 0; foreach($array as $value) { if (false !== stripos($string,$value)) { ++$count; }; } return $count == count($array); } Example call: $string =...
stackexchange/codereview
open Core.Std;; let print aofa = let s1 = ( Array.length aofa ) - 1 in for i = 0 to s1 do for j = 0 to (Array.length aofa.(i)) - 1 do printf "%d " aofa.(i).(j); done; printf "\n"; done; ;; let rec fact i = if i <= 1 then 1 else i * fact (i - 1) ;; let rec permuta...
stackexchange/codereview
I have code in the this example: legacy_id phone_type phone_number 1 f 1234567890 1 b 1233854100 1 f 4110256565 2 f 0707070770 2 b 7895120044 I want the data to end up like the following: legacy_id f_phone_number_1 b_phone_number_...
stackexchange/codereview
As request of Simon's comment: Direction.java package net.woopa.dungeon.datatypes; import java.util.Random; public enum Direction { NORTH, EAST, SOUTH, WEST; private static Random rnd = new Random(); static public Direction randomDirection() { return Direction.values()[rnd.nextInt(4)]; } ...
stackexchange/codereview
This is the first time that my code is being reviewed after two years of learning of Python as autodidact. I've never took a course or a class, but I've only read books and seen some videos on youtube. I've rewritten from scratch the 2048 game, trying to make the code more readable and performant possible. Cell.py fro...
stackexchange/codereview
I have known about unit testing for a while now, but I am just now finally understanding how to implement it. I think that my initial implementation is a little rough so I could use some feedback. I have implemented these tests in order to verify that a new feature of my strategy game is working properly. Previously,...
stackexchange/codereview
Say we have this method which is my main concern for this question. It's really not optimal way to get values out of it. Each time I'm running through list twice for to just get one field value for NotificationSettingsDto private NotificationSettingsDto notificationSettingsCustomPairToDto(List<CustomPair> notificationS...
stackexchange/codereview
Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 1 of 3, Core: Newspaper Bill Calculator CLI with Python (1 of 3, Core) Post 3 of 3, Database: Newspaper Bill Calculator CLI with Python (3 of 3, Database) ...
stackexchange/codereview
I'm a first time user of jQuery (and a huge fan already). I am trying to make the comic picture of an xkcd page onclick to the explanation page. Here's what I've done. $("#comic").click(function(){ return window.open("http://www.explainxkcd.com/wiki/index.php/" + document.URL.split("/")[3]); }); Is this e...
stackexchange/codereview
I'm trying to enhance the execution speed of my below code. I am using only vanilla JavaScript. I would be willing to bring in additional libraries and plugins as long as they will enhance the overall speed of the code. The goal is to have the absolute fastest execution time of the below code. Currently, it executes f...
stackexchange/codereview
BEFORE YOU READ: this link should be included when you just don't like the format of the question and for those that read this question for the first time, the link may give you the idea what happened here. The rest after the line is untouched. I was asking for such structure on SO, but got only link to boost::multi_i...
stackexchange/codereview
I wrote this little helper to render a table, however, working with nested content_tag is messy. def semantic_table(table_headers) content_tag(:table, class: 'ui basic striped table') do (content_tag :thead do content_tag(:tr) do table_headers.each { |h| concat content_tag(:th, h) } ...
stackexchange/codereview
What? I have designed curvesort, an algorithm that adapts to "smoothness" of data. For example, if the data resembles a sine wave, it is likely that curvesort will sort it fast. This post is about a parallel implementation of the algorithm. Code ParallelCurvesort.java package net.coderodde.util; import java.util.Objec...
stackexchange/codereview
I have a method that returns a URL to send a user should they pass a login. My problem is two of these links are hard coded one of which is attempting to pass a variable to the model of that controller. My question is two fold: A. Is this safe B. Is there a better way to do this without hard-coding things like this? ...
stackexchange/codereview
What I'm wanting to do is create a String readFile(Path filePath, Charset encoding) method, that returns the entire contents of a given file. I'm wanting the equivalent of Guava's Files.toString(file, encoding), but without calling the Path.getFile() method (as this method only works with the default filesystem provide...
stackexchange/codereview
I've written the following query for SQL server: SELECT YEAR(Meeting_Date) year, MONTH(Meeting_Date) month, COUNT(project) meetings FROM meetings WHERE Meeting_Date BETWEEN CAST(DATEPART(year,DATEADD(m,-6,GETDATE())) as varchar(4)) + '-' + CAST(DATEPART(month,DATEADD(m,-6,GETDATE())) as varchar(2)) + '-01' AND DATEADD...
stackexchange/codereview
I wondering if anyone could give me feedback on whether or not this is a secure way to implement AES/RSA hybrid encryption and signatures in python 3 with the PyCryptodome module. All of the encoding and to/from hex format is just there because that's the format I intend to transfer it in. """Hybrid AES/RSA encryption,...
stackexchange/codereview
I wrote this simple SQLiteOpenHelper in order to use in one database various tables containing String records (each record having a String identifier, and associated String fields. When you create a table, you have to call the createTable method with a table name and its number of fields. Table fields are then created ...
stackexchange/codereview
My goal is to create a simple restful api that will be accessed by an AngularJS front end. Even though it's fairly simple, I'd like understand how to make it more reliable, secure, and best-practices compliant. The whole api is contained in a single file, I'm not overly concerned about organization at the moment (unles...
stackexchange/codereview
I am a first year CS student. We are currently learning Java and my latest assignment was to create this random number game. I am hoping to get some feedback on code style etc so that I know what not to do in the future and so that I can avoid getting into bad habits from the start. I don't know all that much so any ex...
stackexchange/codereview
I frequently encounter the need for creating services that concurrently process messages from Redis queues. So I decided to share the knowledge I learned and help others easily bootstrap such a service. I would like a second opinion from code reviews of the library. Please do contribute if you feel like improving it! G...
stackexchange/codereview
I am in the process of learning basic C++ and one of the practice questions I came across was to write a function to open a file in C++. I did understand how to use the streams but I think I went overboard a little bit by making sure that it works. I would appreciate any feedback on my code. The objective was also to k...
stackexchange/codereview
This is my solution to K&R Ex 1-18 which requires us to remove all trailing blanks and spaces from a string. I specifically wanted to use a separate function for processing the input (via gtLine()) to promote code re-usability. Please tell me ways in which I could have made my program shorter/better. Also, please point...
stackexchange/codereview
This is just the server part of a chat program. The user of the server can receive and send messages to all the clients connected to the server. Everything works fine but since I'm a beginner I don't know if I should avoid something or not, what I should improve, etc.. The server class of the app: import java.io.Buffer...
stackexchange/codereview
What I need: I need a lookup table. Once the keywords are all found, then the value of the std::unordered_map is returned.And I don't care about the sequence of the strings in the std::vector. I think std::unordered_map<std::vector<std::string>, int> could achieve this goal. Any better method to achieve this goal? Or a...
stackexchange/codereview
I am trying to write a generic Python script that do the following types of tasks: Load .npy file (the .npy file is of shape (m_samples, channels, row, column), which corresponds to m_samples images, and here the channels are always 1 Check whether a given path exists Iterate against the .npy file, and save each image...
stackexchange/codereview
I thought of this implementation, and I want to get feedback from you.. what design would you use for printing first 100 prime numbers? I used the fact that, if the number is not divisible by any prime less than itself, it will be a new prime. ArrayList<Integer> list = new ArrayList<Integer>(); list.add(2); // ...
stackexchange/codereview
Just for practice in the mathematical side of programming, I decided to rewrite the math functions, with the addition of the root() function, which the Math library does not provide, but can be easily done with Math.pow(x, 1 / y) where you want to find out x to the yth root. I also wrote this to review the Newton's Met...
stackexchange/codereview
#include <iostream> #include <complex> #include <vector> #include <cmath> /* adapted from https://stackoverflow.com/questions/55421835/c-binomial-coefficient-is-too-slow */ template<typename T = int, typename U = unsigned long long int> inline U computeBinomialCoefficient(const T& n, const T& k) { if (n == k || k...
stackexchange/codereview
I've written a class that allows me to easily create sprites on the screen, and then do things like: setting an image or an animation; move the sprite as a platformer or as a top down game; and test for many things like collision and orientation. So far I've found this to be very useful, and it has made it really easy ...
stackexchange/codereview
Is there any better and compact way to write this code: String output = "NAME OS ACTIVE\n" + "---- -- ------\n" + "ABCD Windows Yes\n" + "EFGH Windows Yes\n" + "1234 Windows No\n" + "5678 Win...
stackexchange/codereview
This is the third iteration of the Fast search for the longest repeating substrings in large text (Rev.2) code review. Special thanks goes to G. Sliepen who conducted the first two reviews. Functional specification Having a large text and already built suffix array find the longest substrings (limited by the number of ...
stackexchange/codereview
I know I should use services and patterns to refactor this controller action, but I can't imagine one that could fit/be appropriate for this problem. It seems a strategy or template, but a strategy is supposed to be changed if needed; in my case, it should be always the same: Get the customer If doesn't exist store t...
stackexchange/codereview
This is my second jQuery script: a universal tooltip for my entire web page. It took me a couple of days to research and make it work. Now, I need help from the experts to optimize my newbie code. This is one of the ways I can show the tooltip: <a class="tooltip" data-tooltip="this is the text for my tooltip" href="#">...
stackexchange/codereview
I would love some feedback on the following code for BFS traversal in a binary tree. Is there a cleaner way to write this? abstract class Tree[+T] case class Node[T](value:T,var left:Tree[T],var right:Tree[T]) extends Tree[T] case object End extends Tree[Nothing] def bfs_v2[T](node:Node[T]):List[T] = { def en...
stackexchange/codereview
I'm still new to programming. (First exposure was school about a year ago), and for some reason this problem really gave me a lot of problems trying to solve it. Can you help me understand what I could have done different/better here? import java.util.*; public class Lab10 { public static void main(String[] args) t...
stackexchange/codereview
I'm currently trying to learn C from the K&R book, reading through and attempting the exercises. I came across exercise 1-12 yesterday and was a little stumped but managed to complete it. I was wondering if someone on here would help me improve it, and also guide me on how to approach testing something like this too. T...
stackexchange/codereview
The following code extracts command line parameters and modifies argc and argv parameters of the. After all parameters are read remaining values (especially after --) are remaining. Please keep following questions in mind while reviewing: Is it good practice to modify argc and argv? How to make clear to the caller the...
stackexchange/codereview
I want to get information from two websites and display it on 'real-time' in the console. To get the information from the website I am using BeautifulSoup 4. I have read, that the bottleneck of scraping websites is the connection or the website itself. So I wanted to use multithreading, so the read can be done 'simulta...
stackexchange/codereview
In my current project I found the need to concurrently track the progress of multiple concurrent components, and having all of them output their (debug) information into a single console window made things very unorganised. So I wrote this little library so I can now display each component's output in a dedicated conso...
stackexchange/codereview
I am willing to switch to OOP concept, but before working on that I would like to know whether what I have working so far is OK, or if any major change is required? For every form I create 3 files: for front end html a js file as a mediator between client and server a server side php file which handles data services. ...
stackexchange/codereview
I have an array that contains n arrays and each of these arrays contain a different number of string elements. Each string contains a key word like evar#, event# or prop# (where # is a number). This is my goal: return all the key words from a string that is different with at least one of the other arrays return the ke...
stackexchange/codereview
I am inserting elements into the map container. For this I am using the same statements multiple times in the below function. Is there any way I can write a generic function for this? So that even at the later point of time, when required, I can insert new elements. bool EMRMgr::GetParams() { EmIOStruct em...
stackexchange/codereview
I have implemented a play fair cipher. The code works fine but I would like to improve the clarity and/or performance of the code. First a quick description of how it works. You are given a string to encode along with a key. The text can only contain alphabets (i.e. no spaces or punctuation). Also this cipher is case-i...
stackexchange/codereview
I am a beginner in programming languages, so I apologise if my code is badly formatted or doesn't make any sense. My program gets an image and a RGB color range as input and it counts how many pixels are in each group. A group only contains pixels connected directly, not diagonally, so for each pixel, it searches for v...
stackexchange/codereview
This is a tiny class that creates backup copies of a file so these can be diff'ed to spot the changes compared to last run; used when generating code and so far has proved to be very helpful. Basically, I reuse the async disposable logic because it doesn't really make sense to write it twice; the documentation simply d...
stackexchange/codereview
Reverse the string to get out as This is durga @ no. 1 position. Is below solution memory optimistic. How can we achieve the same without using a string function like i used strlen. <?php $string = "position 1 no. @ durga is This"; $reversed = ""; $tmp = ""; for ($i = 0; $i < strlen($string); $i++) { if ($string[$...
stackexchange/codereview
I've taken my previous block building game and added some performance improvements, and commented some things that needed to be commented for better explanation. /** Here are few instructions before you start... * IMPORTANT (ON KHANACADEMY ONLY): When you make changes to the code, all tiles will be black. * Just hi...
stackexchange/codereview
I have a command called sprinkle. I'm not going to explain anything about it, because I want whoever that reviews the code to also tell me how much of the command documentation they understood. Here is what I need help with: Is the documentation good enough? Is it too verbose? Does the constant domainName help you und...
stackexchange/codereview
3 elements forms arithmetic sequence, when difference between any two consecutives of them is the same. In our task we are given array A. Any pair of integers in this array is called slice (eg. (B,C)), when 0 <= B < C< N, where N is an array length (0<=N<=60). A slice (B,C) is called arithmetic, when the sequence: A[B]...
stackexchange/codereview
Please review the code readability, I would like to have an easier to follow code. Thanks using Microsoft.VisualStudio.TestTools.UnitTesting; namespace ArrayQuestions { /// <summary> /// https://www.geeksforgeeks.org/inplace-rotate-square-matrix-by-90-degrees/ /// </summary> [TestClass] public clas...
stackexchange/codereview
I really hate messy code, but I seem to be rolling in it. I just want to see if anyone has some helpful advice on how to tidy this up. <table> <tbody> <tr> <th>Zona</th> <th>Baptismos Mulheres</th> <th>Conf. Mulheres</th> <th>Batismos Homems</th> <th>Conf. Homems</th> </tr> <?php $currWeek = $CONF->getSetting('current_...
stackexchange/codereview
I wrote a version of decorator pattern in c++ as I wasn't able to find any good source of decorator pattern implementation in C++. I want to know if I implemented it correctly. Here is the code- //implementing the pizza example in c++ #include "bits/stdc++.h" using namespace std; class Pizza{ protected: string de...
stackexchange/codereview
I'm building a server for serving static content, and uploading images there. Everything works, but I'm not expert in nginx and server configuration, so maybe someone sees some improvements for this. Here is my nginx config: server { listen 80; server_name localhost; location / { proxy_pass http:/...
stackexchange/codereview
I'm very new to the programming world and have been working exclusively with console window applications in C# thus far. I've created a program which took me way too long to produce but I'm very proud to have completed it exactly as I set out to make it. It does what I wanted it to do, however the code is separated int...
stackexchange/codereview
I wrote this cat clone in C++. It does two things prints the content of file if only one file is given. concatenate and print contents of file if more than one file are provided. I am especially concerned with the overloading of << for the class CLI. I mainly wanted to gain some abstraction with this. Below is the co...
stackexchange/codereview
My solution runs properly and I have tested it against various test cases. Is this the best approach? #include<stdio.h> #include<math.h> int primefactors(int); int main() { int num; printf("Enter a no:-\n"); scanf("%d",&num); printf("%d",primefactors(num)); return 0; } int primefactors(int n){ f...
stackexchange/codereview
If you came here because of the title, chances are your server isn't down. But if by some miraculous reason it is: A while ago, I posted a program that would ssh and ping all the servers at work. I got some very good feedback and went ahead and rolled with it. Here's what I came up with: It now is much more readable, ...
stackexchange/codereview
This is considered as my second python project, I made the password generator where user has to input length of password minimum 5. I made the code that it will guarantee at least one lowers case, one upper case and one special character is included in the password. please review and comment. import random def letter...
stackexchange/codereview
The zlib library is a venerable piece of C software. The copyright for the decompression routine goes back to 1995, with the last rewrite in 2002. It is used daily by millions. To be perfect, the decompression routine should not invoke undefined behavior, even if passed a maliciously crafted buffer. I have the opportun...
stackexchange/codereview
I'm really new to programming, currently following several tutorials and guidelines. After a couple of days of studying, I've learnt the basics of Java and conditionals and took on my first program. It was written all out of my head. The program is a sort of gambling machine. Each turn, the player has to guess a number...
stackexchange/codereview
I've implemented the Egg Drop Problem using Python. As described in the code, I'm trying to find the highest floor of a 102-story building from which I could drop an egg without it breaking. The approach I took here is by using a binary search method, where I initialize the upper bound as the building height, the lower...
stackexchange/codereview
I'm new to coding and this is a text based adventure game with combat. Sleep and choice functions based on idea from https://codereview.stackexchange.com/a/52292/179642. Map idea from Codecademy battleship tutorial. The actions in the fight function are not in a loop because attacks reduce the opponent's hp but healing...
stackexchange/codereview