instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I am a beginner in C and wrote this code to implement ARP. 3 threads are present - one to respond/receive any ARP packet targeted to me, one to refresh the ARP table on a periodic basis, and one to transmit packets present in the buffer. An ARP table is implemented in a hash table. The sensitive areas are: A reply nee...
stackexchange/codereview
I am making a small database and these are the following files. The scripts are working. How can I improve my scripts? Are there any places where a problem could occur? I have yet to write tests for this. Let me know if you need further details. models.py from django.db import models from django.contrib import admin fr...
stackexchange/codereview
Here is code that returns the first N prime numbers: function [primes] = findFirstNPrimes(N) % Accepts an integer, N. % Returns the first N primes. primes(1) = 2; % first prime i = 3; % numbers from i and on to be tested while length(primes) <= N % 1 x N array of i's, N - cu...
stackexchange/codereview
Currently, I have this and it's working for all cases: import math import os import random import re import sys def caesarCipher(s, k): st = [] for i in range(0,len(s)): if 65<=ord(s[i])<=90: temp = ord(s[i])+k%26 if (temp>90): temp-=26 st.append(chr...
stackexchange/codereview
I have been coding in Java for about a month now and I'm seeking advice for my program on things I can improve. This project was mainly made for me to incorporate all the new things I learned and utilize them effectively. I appreciate any feedback :). About the program itself, it takes in a string and reverses it. It a...
stackexchange/codereview
I have a URL in this format: http://localhost:57279/AssociateCaseDetails?UId=176948&caseID=1123 I need the values of UId and CaseID: var UId =window.location.href.split("?")[1].split("&")[0].split("=")[1]; It’s working, but is there a better way to access the same, given the same URL?
stackexchange/codereview
As a hobbyist programmer I have been reading "The Art of Multiprocessor Programming" (Herlihy, Maurice; Shavit, Nir) and converting the Java spin locks into C++ - I have enjoyed this and learned a lot. I have implemented the CLH spin queue lock (due to Travis Craig, Erik Hagersten, and Anders Landin) but I feel unhappy...
stackexchange/codereview
I wrote a Python program that can take as argument either a string or a filename, with these options being mutually exclusive: #!/usr/bin/env python import argparse import sys def parse_command_line(): parser = argparse.ArgumentParser() parser.add_argument('-t', '--text', dest = 'input_text', help = 'Text')...
stackexchange/codereview
I am writing a pretty simple REST service in ASP.NET WebAPI with Entity Framework and I decided to use it as an opportunity to learn N-layered enterprise application architecture with some unit/integration tests coverage. I've spent a few days on reading articles about the topic and that lead me to creating a part of t...
stackexchange/codereview
This is a HashMap implementation written in Python. All the methods are based on the java implementation of a HashMap. Any and all critique is welcome. This implementation is just a rewrite of some java HashMap methods. Yes, it's basically a wrapper class for pythons dict. This implementation is a simple exercise to se...
stackexchange/codereview
Let me preface this by detailing some of my design philosophy. The intent is to view the board from the perspective of the active player. Player moves are also factored into the design. When determining move logic, all that needs to happen is comparing against '0'. For checking the whiteness or blackness of a piece, or...
stackexchange/codereview
For the first time, I tried to use threads by myself in order to implement a parallel sieve of Eratosthenes. The trick is that each time a prime is found, a thread is spawned to eliminate all the multiples of this prime number from the boolean vector (the one that tells whether a number is a prime or not). Here is my c...
stackexchange/codereview
I'm studying functional programming, and I have the following problem to solve. It's an simplified version of Caesars Cipher: You need to write a function, which will take string encoded with Caesar cipher as a parameter and decode it. The one used here is ROT13 where the value of the letter is shifted by 13 places. e...
stackexchange/codereview
I've started out working on a larger project using Angular for the first time. For visual feedback, I'm using Waves (Github) (you can see a demo page here). The standard way to use Waves is to include the script along with its CSS on the page and once the page has finished loading, call Waves.init(); to bind to all el...
stackexchange/codereview
A \$Z^m\$ number system includes integers in the interval \$[0, m)\$ when \$m > 0\$ or \$(m, 0]\$ when \$m < 0\$. The code defines a trait Mod to represent numbers in this system and the +, -, and * operator for it. use std::ops::Add; use std::ops::Mul; use std::ops::Sub; struct Mod<T: Modulo<T>> { modulo: T, ...
stackexchange/codereview
The set-cover problem is explained here. I am using lists that are being treated as sets. As I found lists were easier to manipulate in python than sets. The first part of the algorithm uses input validation. import json from copy import deepcopy import random s = input("Input list of integers (no repeating elements)...
stackexchange/codereview
For development I'm using timer classes that are based on Win32 functions like QueryPerformanceCounter() or the time stamp counter of Intel-compatible CPUs. However, for self-contained little test programs that can be posted here (or put in a place like PasteBin and linked) I'm looking for a replacement that does not r...
stackexchange/codereview
My kids got a dice game for Christmas. I'm trying to mathematically analyze it. The first step is to come up with a list of all possible positions. Each player in the game has a certain number of chips. A valid position is when more than one player has chips. If only one player has chips, they win and the game is over ...
stackexchange/codereview
I have a csv file with 3 fields, two of which are of my interest, Merchant_Name and City. My goal was to output multiple csv files each with 6 fields, Merchant_Name, City, name, formatted_address, latitude, longitude. For example, if one entry of the csv is Starbucks, Chicago, I want the output csv to contain all the i...
stackexchange/codereview
I try to find the center of all the red pixels contained in an image using Haskell and repa. My problem is, that the code is not fast enough, probably because I read the image with repa-io which returns an Array Z DIM3 Word8, but I was not able to figure out how to filter the repa array by how red the given pixels are....
stackexchange/codereview
I have the following class. The aim is to have a few methods that deal with the type of the gift, the dwarf who is packing the gifts and the time he will take. And finally, the reindeer, which is supposed to do the work. class kdo_pack(): def __init__(self, maxsledge = 12, remainingplace=0): self.maxsledg...
stackexchange/codereview
I've created a Game of Life implementation in JavaScript with the goal of having it be as fast as possible, with the rendering I'm satisfied (see picture bellow), however the next state calculation is really slow and I'm out of ideas how to speed it up even more. Current state of the implementation Rendering Screenshot...
stackexchange/codereview
I have made a Rock Paper Scissors game. It works fine but I would like to know how can I improve it further. #include <iostream> #include <algorithm> #include <string> #include <random> #include <array> #include <map> #include <limits> namespace { enum Winner { Tie, Player, Computer, WinnerCount }; enum Items ...
stackexchange/codereview
I have a data frame called data with lots of columns, and Country is one of them. I created a new logical column called train, which is true when the row belongs to the train set and false otherwise. The data frame is already sampled. Now I want to be sure that there are no countries in both train and test sets with t...
stackexchange/codereview
Current code (ES6): getSelectedItem() { let result; return ((result = this.getItems().map((s) => { return Util.isItemSelected(s.toJSON()) ? s.toJSON() : false; }).filter(Boolean)) && result.length) ? result[0] : null; }, s is a Backbone.js Model (hence the need to .toJSON() on it). Apart from a ver...
stackexchange/codereview
I have written some code to suspend someone's enrollment to a course. A course may have multiple presentations. module Enrolments class Suspend attr_reader :enrolment, :responses, :comment, :user_id attr_writer :event_service, :suspend_enrolment_presentation_service def initialize @responses = [] ...
stackexchange/codereview
I have a pair of General Ledger accounts to scan for data. I need to find a keyword or phrase from the descriptions and then collect certain bits of data from those lines. The source tables (there are two) are on separate tabs and the data from that needs to populate 5 other tables of data for analysis. This is the cod...
stackexchange/codereview
I've created a working price toggler, that also has an upsell remover/adder. While it works well, I'd like to understand how I could do it better, because I'm having to essentially run two compound if/else statements to account for the duration toggle and the upsell toggle. const pricing = document.querySelector('#to...
stackexchange/codereview
I have written a simple download accelerator in java which downloads the same file in multiple threads and then combines them all. I would love some feedback on my design. How the same implementation can be better written. Idioms, conventions, anything that comes to your mind. I hope I have not included a lot of code h...
stackexchange/codereview
I'm a Python programmer / teacher who was a CIS major in college. I'm going back to school to get my masters in CS probably, and the first course is a prerequisite Intro to Programming in C / C++. I've decided to work through the K&R book to prepare myself, and this is quite the learning experience! For this particul...
stackexchange/codereview
In React, it is quite common for me to have something similar to the following. async componentDidMount() { try { this.setState({ isLoading: true }) const { data } = await axios.get('...') this.setState({ data }) } catch(error) { handleError(error) } finally { this.s...
stackexchange/codereview
I am doing Kickstart's problem Wiggle Walk. I have tried to code with matrix, dictionary and nested dictionary but the time exceeds the limit in each submition. Can anyone help me optimize it better or is there any algorithm which I may have overlooked. The problem statement is Problem Banny has just bought a new p...
stackexchange/codereview
Can you provide some advice on how I can simplify this code? I am a beginner with Python, and I'm pretty sure that my code can be much simpler. I think the check() function is far too complex. But I have no idea how to simplify it, and still check which player has won the game. def check(): win = 0 if gameTable...
stackexchange/codereview
I've implemented a BackgroundWorker in my WPF app. My code is pretty ugly though. I've been told to write as little as redundant code as possible. IS there some generic Method I could employ to reduce the amount of code? //BackgroundWorker Databases private void worker_updateDatabases(object sender, RunWorkerCo...
stackexchange/codereview
So, I fixed my problem with a public ViewModel for my MainPage like this: MainPage.xaml.cs: private static MainPageVM Data = new MainPageVM(); public MainPage() { this.InitializeComponent(); SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; this.DataContext = Data; this.SizeCh...
stackexchange/codereview
At my new job, with new young developers, we are seriously discussing improving code structure and performance. (They keep more than 80 lines of code in a method). However I've read more tutorials, and based on my experience, I think I should use some method to wrap that code by its conditional and call it back but tho...
stackexchange/codereview
In my very specific scenario, I need to get an NSDate holding the next time the hour will be 7 (either AM or PM). On the case that this is the first time to do this, I need to jump extra 12 hours (e.g., if I got Apr 1st 7AM - to jump it to 7PM). After playing with playgrounds I was able to achieve what I believe solves...
stackexchange/codereview
I am developing a simple Chained Flow (should I call it by this name?) that uses waterfall as main operation behavior. Basically we will have a Flow and he will have some dialogs with functions to be executed. So, when you call start on Flow (passing the name of the dialog) some Waterfall objects will be created taking...
stackexchange/codereview
I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Advent of Code (the 2nd part of Day 2): https://adventofcode.com/2017/day/2 I'm doing the 2nd part of Day 2. You can only access the 2nd part once you solved the 1st part. To access the 2nd pa...
stackexchange/codereview
I decided to write a tiny class to automatically write and delete a file given filename and content. It is intended to make testing IO less verbose. I include a small example usage. temporary.py import os class Temporary: def __init__(self, name, content): self.name = name self.content = content ...
stackexchange/codereview
I wrote this recursive function to get all constants from a class and its subclasses. Can it be simplified? private static IEnumerable<FieldInfo> GetPublicConstants(Type type) { var subtypes = type.GetNestedTypes(BindingFlags.Public); foreach (var subtype in subtypes) { foreach (var constant in Get...
stackexchange/codereview
This is my first hand crafted makefile in quite a while. I thought it might be useful for anyone who wants to review the Knights Tour - Improved Refactored Recursive Breadth First Search. I believe there is a lot of room for improvement on this makefile. The C++ source code as well as the makefile can be found on git...
stackexchange/codereview
I would like to connect this "JS" to Bugzilla (example: bugzilla.mozilla.org or landfill.bugzilla.org). I started to learn JS language today and I would like to ask you: How can I not do bad things in global scope? How should I use functions (in var or not)? quicksearch = document.getElementById('quicksearch_top')...
stackexchange/codereview
Let's say you have a book. A book can have an author, an editor, a proof reader, or several other credits. Which credits are available should be dynamic (someone might not want to have the "proof reader" credit, or want to add something not available "out of the box"). Each credit can have one or many people. I would n...
stackexchange/codereview
I have written a class that is intended to execute a unit of work to be run in a separate thread. The intended use case for this class is running business logic off of the user interface thread so as not to lock it up while waiting for long running processes to finish. Here is the class: import javafx.beans.property.Ob...
stackexchange/codereview
I'm trying to solve this problem with Python 3.8. In my code, I used 3 nested for loops to check every single point and storing the largest area with each set of points. This program works fine, but it's \$ O(n^3) \$ time complexity, and I'm wondering if there are any more elegant/efficient solutions. Is there a more e...
stackexchange/codereview
I have a lookup table "RequestTypes" that has the following data: ID Type ---- ----- 1 Leave 2 Loan 3 BlahBlah Using EF, and whenever the need arise to check the type of the request, I used to do something like: if (row.RequestType.ID == 1) { // request is leave } else if (row.RequestType.I...
stackexchange/codereview
I wanted to get some feedback on this way of initializing a connection to a MySQL database. File includes/db.php: <?php $config_path = __DIR__ . '/../config/database.ini'; $db_ini = parse_ini_file($config_path , true); $db_info['db_host'] = $db_ini['db_data_source_name']['host']; $db_info['db_user'] = $db_ini['db_gen...
stackexchange/codereview
I'm learning Rust now and created a program to solve the task General Fizzbuzz on Rosetta Code. For example, given: 20 3 Fizz 5 Buzz 7 Baxx where the first line indicates the upper bound and every line after that indicates the divisor and the corresponding word, the program should return: 1 2 Fizz 4 Buzz Fizz Baxx 8 F...
stackexchange/codereview
I have been working on a web application that produces an image out of colours. Having multiple divs works, but the load time is slow and until the image loads it's time-taking. I would like to make a table like image with lots of colors extracted from an image and display them inside a web page. I don't know which lan...
stackexchange/codereview
This is my first time writing a basic program/game in any programming language. It is supposed to a be a Nim game vs a computer with these basic parameters: Use prompt() to prompt moves and input. Use console.log() draw the board. The board should look like this: Pile A: ooooo Pile B: ooo Pile C: ooooo It has been ...
stackexchange/codereview
I've written a script that deletes a member of a hash if an array within the has contains all the other elements of another array within the same hash. It works but it looks a little messy. Is there a better way to do this? def title_contains_blocks(candidate, titles, index) test_group = titles.dup test_group.delet...
stackexchange/codereview
This is a thread I started from here. I organized my code to make it more organized. Everything works well, but I have not made all the changes from the last link (namely namespace since I am exactly sure why or what to do). Overall I just wanted to show my generic single linked list I made and see if there are any er...
stackexchange/codereview
Simple task - deploy war-file from TeamCity agent to remote web-server. I realized it with Fabric, because of it make readable output, and give opportunity to login via SSH with RSA-key. Also - during deploy - build agent must make some additional steps - create backup, stop-start Tomcat service etc. URL to deploy to c...
stackexchange/codereview
Print the following pattern, when you invoke inverse_cascade(1234) 1 12 123 1234 123 12 1 Solution: def inverse_cascade(n): def grow(n): if n < 10: print(n) else: grow(n // 10) print(n) def shrink(n): if n < 10: print(n) else: ...
stackexchange/codereview
I made myself a simple budgeting application. Each transaction is stored in the transactions table: CREATE TABLE transactions ( -- Foreign key into the "categories" table, not shown here. (In reality this -- has a NOT NULL constraint instead of a default, but this makes the -- example data easier to enter.)...
stackexchange/codereview
I coded a server-client (kind of) chat, and I need your review as I'm sure it is a mess. I used lots of tutorials and tips form different websites and forums which were posted at different times (maybe now it's a lot easier to write what I want) and slapped them on Visual Studio. It's not like I wanted it to be a chat,...
stackexchange/codereview
As detailed in this SO question, I'm using custom logic in a BTreeSet to automatically sort a foreign data type as elements are added to the container. Note that the Data type is used from another module in the actual implementation, so I can't just implement Ord for it, necessitating this approach. I'm concerned that...
stackexchange/codereview
I initially posted this on Stackoverflow but was recommended to try here instead. I'm looking for feedback on why the implementation of my ClientFactory is probably bad, from a Dependency Injection-point of view. Or if it is actually okay to use in production? My code below works. I know how to implement a named/typed...
stackexchange/codereview
I am generating a searchable and sortable data table using bootstrap. All works fine. I am looking for the best approach to get it. Can anyone can please update/suggest the right way, if you find anything better? jsfiddle var tableMaker = function (columNames, parent, data) { var table = $('<table />', { id...
stackexchange/codereview
I am learning jQuery/JavaScript best practices and am attempting to put them into practice. My overall goal is to have lots of small, independent .js files which contain specific functionality and will not intrude or collide with other files, then concat/minify them for production as one file; basing some concepts off ...
stackexchange/codereview
I wrote a method to select the filters (two or more) based on the true/false conditions. Here is the method I used for selecting the multiple filters: public T SetPropertyTypes<T>(bool residential, bool commercial) where T : IPage, new() { // Residential Property Type Check logic if (residential && (Elemen...
stackexchange/codereview
I have several json models which represent same logic model. e.g: {"title":"title1","years":"31"} and {"name":"title1","age":31} at the moment I make 2 different classes which implement same interface public class NameModel implements Person { @SerializedName("name") private String name; @SerializedName("age") pr...
stackexchange/codereview
I have a function f(i, j) that accepts two std::size_t arguments and I want to make a constexpr std:array out of its values on a 2d grid, (i = 0, ..., rows-1; j = 0, ..., cols-1) in, say, column-major order. The code: #include <array> #include <tuple> #include <type_traits> template<std::size_t rows, std::size_t cols>...
stackexchange/codereview
I've inherited an Access database and am looking to start using it to do reporting. I've written a query that gets me the information I'm looking for, I'm just hoping someone can have a look over it and tell me if I'm doing it the wrong way or not. Anyway, the query takes information from 3 tables: sites - more detail...
stackexchange/codereview
I'm trying to write unit tests code for a java class. The class tests an array for sorted (either way) or not. Here is the Unit Tests code: public class SortedOrNotTest { @Test public void test() { int[] A = { 32, 32, 32, 32, 32, 32, 32, 32, 34 }; assertEquals(true, SortedOrNot.isSorted(A)); ...
stackexchange/codereview
I want to write a search that raises an error if the list supplied is not sorted. class BinarySearch attr_accessor :list def initialize(orig) raise ArgumentError unless sorted? orig self.list = orig end def search_for(n) s_list = self.list offset = 0 loop do mid = s_list.leng...
stackexchange/codereview
Based on Dynamically call lambda based on stream input: Try 2 This fixes most of the points pointed out by @Morwenn. It has been generalized so anybody can call it. The only extra part needed by the code is a function to retrieve values from a stream. This is passed as a template argument to callFunctor() see the exam...
stackexchange/codereview
Link to the old question. I tried to learn some new things from the answers and here's what I did: Used Qt Designer so that in Config.h, all member variables and widget positioning are gone User can't set the lower bound higher than the upper and vice versa Replaced obsolete qrand with generators from the C++11 <rando...
stackexchange/codereview
I'm currently working on a Scala HTTP library, fetch, mostly because I have yet to find one that suits all my needs. As part of this library, I need a generic key / value store, which I intend to use both for request / response headers and URL query parameters. This store uses type classes for value parsing and formatt...
stackexchange/codereview
This is the first mini-project I have completed by myself with Python 2.7. I wrote a simple program that calculates the area of different two-dimensional shapes and it works. I want to know what you think of it and also want to know how it can be improved and if I did something wrong, so this is my code: def circle(pi...
stackexchange/codereview
Can someone help me to create a generic method that validates common fields/variables comes from multiple objects, if that is possible? The below code validates some bunch of variables/fields from a schema object, so here the requirement is I have two different schema objects which has common Fields/variables, Is it po...
stackexchange/codereview
I am creating a social network and part of the features allows people to upload a profile pic. I want to know how secure my code is. From start to finish. <form action="upload_profile_pic.php" method="POST" enctype="multipart/form-data"> </form> include 'includes/header.php'; if ($_SERVER['REQUEST_METHOD'] != 'POST...
stackexchange/codereview
I am trying to implement the Euler–Maruyama method and use it to solve the Ornstein–Uhlenbeck process. I am basing my code on the wikipedia page where a python implementation is shown. More generally I'm trying to get to grips with stochastic differential equations in c++. This is my code #include <iostream> #include <...
stackexchange/codereview
Before I begin using this code in vital systems, I wanted to quadruple-check that it was soundproof. I plan to implement this as part of a larger program, obviously not by itself. Are there any clear flaws (output is incorrect) or optimization issues in this code? #include <iostream> using namespace std; int main() {...
stackexchange/codereview
Here is a caching code of a nodejs / typescript app using lru Cache module from https://www.npmjs.com/package/lru-cache. For various reason i need to setup separate caches: one for homeCache another one for detailThreadCache... but this is just the beginning I may need to set up more. This code is working, but how woul...
stackexchange/codereview
I want to make this code better. It works now but I think it can be better. I have a working sample on jsfiddle. When the page loads I have the End IP Address disable until the data is entered. Then I take the values of the input with id attribute txtstartIpAddr and use it as the value for the input with id attribute t...
stackexchange/codereview
I written my own calculator script in javascript! It is a basic one, but works really well. I am just wondering if there is any way to make this script more efficient & clean. On first look, I feel like I did some redundant stuff in it, however I am a beginner and in no right to judge the code on my own. window.onloa...
stackexchange/codereview
I've been learning Java lately and had some great feedback from the previous threads (hangman and guess a number games). I was challenged by a user to try to get this code done, so I'm posting it here for further review. Basically my weakeast (among many) points are exception handling and proper documentation. What do ...
stackexchange/codereview
I have method that fetches sorted and filtered data from Mysql Database, Firstly I had done It by using Java. Now I did it by Mysql but I don't like the way the code looks I have entity that named Order and It looks like this public class Order implements Serializable { private int orderId; private int userId; ...
stackexchange/codereview
I require a code review in terms of correctness, style consistency, efficiency, code readability, and "pythonic"ness. class Node(object): def __init__(self, data=None, leftchild=None, rightchild=None): self.data = data self.leftchild = leftchild self.rightchild = rightchild class BinarySear...
stackexchange/codereview
Recently, I was asked to develop a way to easily create a branched narrative, where the user can select options to progress the story in their own path. After a couple hours of fiddling around with different options I managed to produce this simple code. ### STORY BRANCH MANAGEMENT class Branch: def __init__(self...
stackexchange/codereview
I am using MVVM pattern with databinding. I have written tests. But I want them reviewed. The test is related to JUnit test on the ViewModel. FeedViewModelTest.java @RunWith(PowerMockRunner.class) @PrepareForTest({Observable.class, AndroidSchedulers.class}) @PowerMockIgnore("javax.net.ssl.*") public class FeedViewModel...
stackexchange/codereview
import socket,time s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('',0)) port=s.getsockname()[1] s.setblocking(0) lines=[] while True: try: data, addr = s.recvfrom(1024) if addr not in clients: clients.append(addr) if not lines: for client in clients: ...
stackexchange/codereview
I have a school project to create a program that works the same as the Linux cat. The code works, but I just need find out where I can Improve it or handle errors. The program has 3 .c files and 1 header file. I'm also not allowed to use system functions; I have to use read(), close(), open() and write() and while loop...
stackexchange/codereview
In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2 I am getting correct output but want to reduce time complexity....what other logic or enhancement I can use to optimize the code import java.io.BufferedReader; import java.io.In...
stackexchange/codereview
I have MySQL data that I am rendering in an HTML table using PHP. This is the full code of my table and PHP. It does output fine and looks how I would expect but I am wondering if there is a better way to write this code. Also, the 'Delete' button specifically, is there a better way to output the button itself as right...
stackexchange/codereview
I have just started coding. Anything to help simply or improve the code? This is fully finished and ready to play, though the ball bounces off the wall directly behind the paddle, rather than off the paddle itself. Edit: After playing around with the game. One of my friends pointed out that whenever I scroll down on t...
stackexchange/codereview
I've created some methods to help me convert PDF to text and then text to a JSON object. I've never done this before and I'm using this exercise as a way to improve my knowledge of Ruby. The following code does what I want, it works. It just returns a very ugly object. Right now I'm trying to craft some regular expres...
stackexchange/codereview
I'm working on a project (it's a language), and for that project, I decided to go with a low-level C++ style, so that means making my own data types. I recently got done making my own string class implementation. This is actually the first time I've made a string class before, so I may be doing a lot of things wrong. A...
stackexchange/codereview
I'm starting to learn the object oriented aspect of PHP. In this regard I made a small "exercise" of sorts "translating" one of my PHP functions into OO mode of PHP. I'm asking if there are there any recommendations you can give me concerning my predicament. Example of non-OO PHP: <?php function pristup($servername, $u...
stackexchange/codereview
Here I am trying to avoid hardcoding in flash messages by using I18n. Also, I have tried to use a CSS selector for submitting the form to make the tests less brittle (I don't really care that much about what the text on the button is - more what happens when submitting). Is this a good approach for making tests less br...
stackexchange/codereview
In F# the Railway Oriented Programming pattern can be implemented synchronously using the Result<'t,'terr> type as result value for functions, so they can be foreward piped like: let result = func1 |> Result.bind func2 |> Result.bind func3 |> Result.bind func4 I would like to implement the same patter...
stackexchange/codereview
I'd like to eliminate the code duplication in the following two methods by moving the common code into a separate method callable by both. The comments indicate the blocks of code that have a differing implementation in each method. def compute_totals_h(self, size, bad_codes): with open(self._in_file_path, self._FI...
stackexchange/codereview
I am writing a Settlers of Catan server in Haskell for fun. Currently I am passing around state manually. I want to learn more about the State monad and want to incorporate it into my project. However, my GameState has multiple data constructors that I pattern match on to yield different functionality. Three of such da...
stackexchange/codereview
After understanding HashMaps, I decided to implement my own using 3 classes HashMap, LinkedList, and Node. I knew how to implement LinkedList from before. Can you please give me feedback on this. Will this be an acceptable implementation for a technical interview? Also do we actually need to implement the data structur...
stackexchange/codereview
I made a program that lets the user input text into a text box. The user can choose a number to rotate each alphabetical character by that number, and the output box will diplay the converted text. Here is how it runs: Among the code is # if event.key == pygame.K_RETURN: # print('\n'.join([''...
stackexchange/codereview
I am currently developing a puzzle game that has sequence numbers. The player has to fill the grid with sequence numbers in ascending order. Starting from 1 the player can move horizontally or across and can skip a square in between if it is empty or blocked. To generate the puzzle automatically, my code is doing the f...
stackexchange/codereview
I'm currently trying to improve my coding skills, so I'm trying to code a Tic Tac Toe game. At one point a "win check" is needed.I'm using this code to check: public void CheckWin(States state) { if(fieldA1.GetState == state && fieldA2.GetState == state && fieldA3.GetState == state) ReportWin(currentPlay...
stackexchange/codereview
The problem that this is based on is something like the following: A matchmaker is working with six clients: John, Joe, Charlie, Jill, Leslie, and Katie. John is compatible with Jill and Leslie, Joe is compatible with Jill. Charlie is compatible with Jill, Leslie, and Katie. How should the matchmaker match them to hav...
stackexchange/codereview