instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
This is a follow up question to this question: https://stackoverflow.com/questions/4573526/what-could-be-causing-a-cannot-access-a-disposed-object-error-in-wcf I have created a WCF service and it is up and running. When I used it, I was closing the connection after each time I got a response in a finally. Trying to us...
stackexchange/codereview
I am filling a bag full of scrabble tiles. There should be 100 tiles in the bag of these letters: A-9, B-2, C-2, D-4, E-12, F-2, G-3, H-2, I-9, J-1, K-1, L-4, M-2, N-6, O-8, P-2, Q-1, R-6, S-4, T-6, U-4, V-2, W-2, X-1, Y-2, Z-1 and Blanks-2. These numbers/letters should never change. I have a working solution, but i...
stackexchange/codereview
I have been teaching myself Python (as well as Tkinter) and today one of the sites I was reading, asked us to write a program to covert one value from Fahrenheit to Celsius, once - an easy three line program. As you can read in the comments for the program below, I wanted to expand on this. This program is one of the m...
stackexchange/codereview
I'm wondering what the best approach might be. One approach is to chain cachedPromise and "regular", thus, if cachedPromise fails, we call a regular one (and caching results). The second is to have a wrapper function, something like a decorator in python, and being able to wrap any promise-returning function when neede...
stackexchange/codereview
Write a program that should read a file formatted strictly like this below: $ cat sample bingo=2 bingo2=939 bingo3=text The left and right side of = are consecutively parameter name and its respective value. The values can be integer or strings. Each parameter is separated by a newline. The parameter name and...
stackexchange/codereview
I'm trying to practice some C++ and I wrote a simple queue to solve the Producer-Consumer Problem. class Queue { public: Queue() : mutex(), cv(), queue(), process(true), consumer(&Queue::dequeue, this) { } ~Queue() { process = false; consumer.join(); } void enqueue(int i) { std::lock_guard<std::mutex> lo...
stackexchange/codereview
I created this basic metaball visualization in JavaScript. While it does look nice, it is very slow if you increase number of balls and/or make drawing area larger. I think that the performance is so bad because it iterates through every pixel every time the frame is updated but I cannot think anyway how I could update...
stackexchange/codereview
I recently had to install VNC on mass across a lot of computers on a domain and needed some info about their PC, for example: Host name Username MAC Address IPv4 Address Domain name Once all of this info is gathered, it is compiled into a text file and uploaded to a FTP server. To save files from being conflicted wit...
stackexchange/codereview
I've been writing code for some time but never had the need (or opportunity) to write C/C++ code. Did a small project to learn some C++ and would appreciate feedback on code, testing, project structure and building. Project Layout . ├── CMakeLists.txt ├── src │   ├── personnummer.cpp │   └── personnummer.hpp └── test ...
stackexchange/codereview
I'm currently using this method to test a string if it valid JSON. The JToken class depends on Newtonsoft.Json.Linq. public static bool IsValidJson(this string stringValue) { bool returnValue = false; string value = null; if (!String.IsNullOrEmpty(stringValue)) value = stringValue.Trim(); if...
stackexchange/codereview
I'm new to R and have created a dictionary function. A user will input a phrase into a text field and the server will read it and see if there's a match in a back-end data table and if so, output the abbreviation of the phrase. This dictionary data table does not have a 1 to 1 mapping. The dictionary has logical_word a...
stackexchange/codereview
I have the following if statement: if ($scope.current < $scope.questions.length) { $scope.current += 1; } if ($scope.current == $scope.questions.length && $scope.chapter < $scope.all.length - 1) { $scope.current = 0; $scope.chapter += 1; } if ($scope.current == $scope.questions.length &&...
stackexchange/codereview
I have coded a speedreading training bash script. My targed was to make some experience with bash in a funny way. It essentially does the following: Prints to screen a random number consisting of a default number of digits Erases that number after a default time interval Waits for the user input if the user enters a...
stackexchange/codereview
A small script to calculate total units of distance between two vector entities. Especially useful in games and grid snaps, inventory snaps etc.. typedef struct COORD { int X, Y; } coord; int get_dist (coord entity1, coord entity2) { int minuendX = max(entity1.X, entity2.X); int minuendY = max(entity...
stackexchange/codereview
The setup of Backbone: 1 Collection, 3 Models, 1 View for the collection, 1 View per Model. HTML: <div id="showit"></div> Template: <script id="item-template" type="text/x-handlebars-template"> <a class="item" href="#">{{book.name}}</a> <br/> <span>Liked :{{book.likes}}</span><br/> </script> Backbone JS...
stackexchange/codereview
I am trying to make an IOS tool similar to Android's ValueAnimator... more or less This is useful for situations where you simply want a value to "animate" over time, but rather than necessarily attaching that value to some view property, it is available to use as you wish. Imagine applying it to an audio filter, for ...
stackexchange/codereview
Coming from this question https://stackoverflow.com/questions/58131614/how-to-convert-json-string-into-complex-clos-object-using-cl-json-library I've finally come up with the following solution. I use cl-json custom handle functionality json::*object-key-handler* to always know the last key (parent slot name) we run...
stackexchange/codereview
I'm writing a program that takes an input image, and generates a set of unique colors, and repaints the image using only those colors. It takes a long time, and I'm hoping to improve the running time. It's on GitHub, if you want more context. This is an example of the output, running from left to right: This is the ma...
stackexchange/codereview
Intro: I am learning about the model view controller (MVC) architecture and I am looking for feedback from more experienced/knowledgeable people so I can check if my understanding is sound, and learn about where I can improve. Background (optional): I have separately implemented a simple metronome app. While developin...
stackexchange/codereview
Semester is a simple enum class. data class YearSemester( val year: Int, val semester: Semester ) { constructor(string: String) : this( string.split("-")[0].toInt(), Semester.valueOf(string.split("-")[1]) ) } The point is that I don't want to split the String string twice. So to say: da...
stackexchange/codereview
I wrote this C program to open a Mach-O executable/framework and parse the external symbols along with their respective framework/library. A few things I would like to get better at: Memory management: Did I appropriately alloc/free memory? Conventions: Were my functions/variables properly named? Flow control: Are th...
stackexchange/codereview
I am trying to test #initialize of class Author: # lib/author.rb class Author attr_reader :name, :filename, :website def initialize(name, filename, website) @name = name @filename = filename set_filename_from_name if filename == :auto @website = website end end In reality there are 8-9 propertie...
stackexchange/codereview
Question is taken from Leetcode and solution works for their test cases. I do see a scope of improvement and make it more functional (getting rid of vars and mutables data structures). Please suggest improvement to help me. Problem Given a string, find the length of the longest substring without repeating characters. I...
stackexchange/codereview
I've taken a coding challenge as part of a job interview and the recruiting process. Sadly I didn't get through it and couldn't secure the job. I am wondering if anyone can help me out here and show me how it could've been done better. The problem described by interviewer was: The purpose of the class is to register a...
stackexchange/codereview
I wrote the following scripts to extract data from BigQuery and InfluxDB using the bigquery cli and the influx cli. The code works as expected. I included all files for completeness, but I'm primarily interested in feedback on the bash scripts config_query.sh, extract.sh and run.sh. You can also comment on the python f...
stackexchange/codereview
As part of the "a tour of Go" section on golang.org, I was trying to make a (formerly singlethreaded) web crawler parallelized using goroutines. I got it working but it doesn't seem to "flow" right; there's a bunch of duplicated code. Looking for advice as to how it can seem a bit more Go-literate. package main import...
stackexchange/codereview
I've made a code that does exactly what https://sapin.herokuapp.com/?n=5 would do. Here's my code ; import sys def firtree(tree_size): fir = [] width = 1 minus = 2 foot_width = 1 for i in range(1,tree_size+1): for j in range(1,i+4): fir.append("*"*width) width = widt...
stackexchange/codereview
I decided to do a bit more in C# by writing two methods that find duplicates, one being a naive approach, and the other one utilizing the LINQ capabilities of C# as a form of learning and training. Below is my code, and I would appreciate any critiques of it in terms of style, design, and if there are more succinct way...
stackexchange/codereview
I have a site were we sell unique items. When a user clicks to buy an item we have to reserve it. This prevents other buyers from purchasing the item while the first buyer is checking out. When a buyer clicks the "Buy" button, he is redirected to the orders controller. The orders controller executes the following steps...
stackexchange/codereview
I am working on Leetcode challenge #3 (https://leetcode.com/problems/longest-substring-without-repeating-characters/) Here is my solution using sliding window and a dictionary. I specifically added start = seen[s[i]]+1 to skip ahead. I am still told I am far slower than most people (for example, given abcdefgdabc, I am...
stackexchange/codereview
Based on the true condition, I am making some operations. But I want to simplify the below HTML code in a better way. @{ bool savingHtml = (Request.QueryString["savehtml"] == "1"); string activeTab = Request.QueryString["from"]; } @if (savingHtml) { if (activeTab.ToLower() == "index") { <div c...
stackexchange/codereview
Project Euler problem 10 is to find the sum of all primes less than 2 million. I have written a program that does this, and it works, but it takes an excruciatingly long amount of time. What I'm asking is if there is any way I could optimize this to make it run much faster. I wrote it in an app on my iPad called Python...
stackexchange/codereview
The question was on Leetcode 1584. Min Cost to Connect All Points. My answer to this question is: class Solution { public int minCostConnectPoints(int[][] points) { List<int[]> list = new ArrayList<>(); for(int i = 0; i < points.length; i++){ for(int j = 0; j < points.length; j++){ ...
stackexchange/codereview
I was asked to generate every possible single word of three letters, so I wrote this script. How good is my code? Would it be better doing it using recursion or would that be over-engineering? const getAllPossibleThreeLetterWords = () => { const chars = 'abcdefghijklmnopqrstuvwxyz' const arr = []; l...
stackexchange/codereview
I recently got in really deep on a question to find the overlapping meetings and I rewrote a bit of the code and added some things to the code, and I would just like a general review of my code and what I could do to make it even better, maybe performance wise or whatever. Here is my LINQPad 5 Code Dump, you should be ...
stackexchange/codereview
I'm having an issue defining a base class and child classes, which handle initialization differently. I want it to work in ES6 but allow babel to transpile to ES5, and currently babel does not have a backwards compatible translation for new.target so I'm looking for something "close enough". class Complex { construct...
stackexchange/codereview
I'm developing a macro that converts a text file, hence the attempt for a funny title, or cringy, opinions may vary! Context and Objectives I was assigned a project to replace a old legacy program whose our contract is about to expire. This program accepted a text file for input and splits it into a new file based on a...
stackexchange/codereview
I've created a website that displays weather and currency rates for London and New York. The following is an abstract from my cityConfig.php script. Is this a good approach for adding variables from each city into an array? // Define arrays // $cities = array(); $currencyRateHeadings = array(); $currencySource = ...
stackexchange/codereview
I have written a small wrapper class for using PHP Mcrypt for encrypting and decrypting text data. This class generates a salt for hashing the key and encrypts the given data with the generated key hash. The encrypted data get stored with the initialization vector and the key salt into a container class. The container ...
stackexchange/codereview
I am trying to implement the Iterable interface on an object, where the hasNext method on iterator will depend on mutable object state. This state is mutated by explicit function call after call to each next. Basically I am doing such implementation to keep it consistent across multiple implementation. First implementa...
stackexchange/codereview
I just wrote this template to detect if a given element is found inside a container: template <typename Iterator> bool is_contained(Iterator begin, Iterator end, decltype(*begin) object) { for (; begin != end; ++begin) { if (*begin == object) { return true; } } return...
stackexchange/codereview
I've written a script in Python using rotation of proxies which is able to fetch different titles from a website traversing different pages. I've tried to write this scraper in such a way so that it will try using proxies randomly until it can get the titles from that webpage, meaning it will use every single proxy cyc...
stackexchange/codereview
https://leetcode.com/problems/network-delay-time/ There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it takes for a signal to travel from source to target. Now, we send a signal ...
stackexchange/codereview
I'm making a scraper/web crawler using Kivy when I run the code it works but I'm not sure if what I'm doing is Pythonic because all the language I can find is about using the Kivy library. I'm unsure about putting the functions to bind the widgets to inside the build method. Is there a better way? class MainApp(App): ...
stackexchange/codereview
As a follow-up to this question that was an attempt to add basic translation capabilities in an old c++98 program for the sake of the community, I'm posting here the first iteration of my code after applying some of the points that emerged from the previous question: #include <string> #include <iostream> // Not nested...
stackexchange/codereview
I came across a nice video on 3Blue1Brown's channel that highlights a very indirect way to find the digits in Pi. I'd suggest watching the whole video, but briefly: The setup is as above. A "small" body of unit mass is at rest on the left and a "large" body on the right is moving towards the left (the initial position...
stackexchange/codereview
Being new to VBA, and many years removed from college programming courses in Java, I'm seeking opinions about design, implementation, readability and general better practices using VBA to tackle complex problems. There are probably other programming languages much better suited to this problem, but I'm limited by the ...
stackexchange/codereview
I need to prepend N spaces to a string to make it 10 characters in length. I came up with the following method, but since it is going to be called often, I want to ensure it is optimized. Could this be made more efficient? public static string PrependSpaces(string str) { StringBuilder sb = new StringBuilder(); ...
stackexchange/codereview
Made some adjustments to the previous code thanks to the helpful and thoughtful review by @G.Sliepen. Problem statement: This program should ask for the total number of shops that will be visited. At each shop, ask for the number of ingredients that need to be purchases. For each ingredient...
stackexchange/codereview
Just looking for an initial steer on my AngularJS implementation. Background Started work on a clients new site which uses a popular CMS as the backend and AngularJS has been chosen as the client side framework. Functionality Build a simple control that will manage alerts generated from the CMS. If the alert has bee...
stackexchange/codereview
I have implemented a metaclass in Python 3 that, apart from the usual instance constructor (i.e. __init__), enables you to define a class constructor (as a class method that I called __init_class__). The metaclass extends abc.ABCMeta so it supports abstract classes, i.e. the class constructor is not called if a class i...
stackexchange/codereview
I've implemented a stored procedure for a search process SQL Server 2008. I'm not sure if everything I created is correct. Also I'm wondering if this code has any leaks or vulnerability on SQL Injection. Here is my stored procedure: USE [TestDB] GO /****** Object: StoredProcedure [dbo].[Search_Dictionary] Script Da...
stackexchange/codereview
I have this little piece of code which determines the base URL of PHP: $root = $_SERVER["SERVER_NAME"]; if(basename(__FILE__) !== trim($_SERVER["PHP_SELF"], "/\\")) { $root .= "/" . basename(__DIR__); } This is working for me, but are there other solutions for this "problem," or are there any cases where this woul...
stackexchange/codereview
I wrote a Python program that draws the Mandelbrot set fractal. However, the program is very slow. I would appreciate any feedback on the program, but I would especially appreciate feedback on how to improve the performance of my program. from PIL import Image, ImageDraw import numpy as np def FractalFunc(x, c): r...
stackexchange/codereview
I have the problem, my methods become slower and slower after many data. My methods can generate 100 rows with 20 columns around 1-3s, but after that my methods become slower and slower. And for another information, i'm still using NPOI ver 2.4.1 in ASP.NET Web Form (Target framework 4.6.1) Here's my code: this is the ...
stackexchange/codereview
I'm creating a client-side pie chart in XSLT 1.0, without extensions or external dependencies (i.e., cannot use FXSLT, EXSLT, JavaScript, etc.). The code is slow; at least fifteen iterations are necessary to get the correct precision required for the angles used by the pie chart. (I'm looking for help that doesn't invo...
stackexchange/codereview
I am building an application that opens Wireshark services (Wireshark has several services) in order to to different things on Wireshark files like edit, change format, statistics, etc. Each option usually uses a different service, so I want to build my classes with inheritance. I was wondering if what I want to do is ...
stackexchange/codereview
This is a single function in C#. It works fine. My concern is that although I've made the code as short and as multi-functional as I can, what it's doing seems very unclear. It looks like the sort of thing I'm going to come back to in six months and hate myself for writing. Its purpose is to build and execute generic "...
stackexchange/codereview
I made a template pipe and filters to replace an old pipe and filters implementation that used inheritance and had a very heavy base class. #include <iostream> #include <boost/bind.hpp> #include <boost/function.hpp> #include <list> template <typename Data> class pipeline { typedef boost::function<Data(Data)> filte...
stackexchange/codereview
I have an IRepository class that I use a lot. But I noticed that for many of my repositories I do not implement most of the methods. Also, I usually don't have a TKey that I want to specify if I'm not using the GetById method but the current design forces me to specify it. I was thinking of changing the interface o...
stackexchange/codereview
This is what I've come up with to construct a name using a javascript object and immutable.js: const getFullName = ({ user }) => { if (!user || !user.get('response')) { return ''; } return `${user.getIn(['response', 'firstName']) || ''} ${user.getIn(['response', 'lastName']) || ''}`; }; As ...
stackexchange/codereview
Explanation is in the function. Please point out any egregious errors: create function api.ConstantTimeCompare ( @x varbinary(8000) = 0x00 , @y varbinary(8000) = 0x00 ) /* What? Compares two variable length binary strings byte by byte in constant time. When? Cryptography. Why? Given the strings 0...
stackexchange/codereview
I have this method that will give a random prime for a given range (min inclusive an max not inclusive) all comments are welcome: public static int randomPrime(int min, int max) { if (min < 0) throw new IllegalArgumentException("min must be positive."); if (min >= max) throw new IllegalArgumentE...
stackexchange/codereview
I implemented a simple voting widget like the one used on Stack Exchange sites, to use for other purposes (see live on bashoneliners.com), as a reusable package, dubbed UpvoteJS. Here's how it works: Upvote.create('topic-123'); <link rel="stylesheet" href="https://janosgyerik.github.io/upvotejs/dist/upvotejs/upvotejs...
stackexchange/codereview
Could I code differently to slim down the point of this Python source code? The point of the program is to get the user's total amount and add it to the shipping cost. The shipping cost is determined by both country (Canada or USA) and price of product: The shipping of a product that is $125.00 in Canada is $12.00. inp...
stackexchange/codereview
I was just wondering if there was a better way to write this block of code in php. I have a string with values separated by commas. I need to prepare that string to pass it on to the query using IN clause. $sql = "SELECT domain, items FROM rep_skills WHERE report_id = $id "; $data = $conn->query($sql)->fetch_object(...
stackexchange/codereview
I'm getting familiar with python and I'm still learning it's tricks and idioms. Is there an better way to implement print_html() without the multiple calls to html_file.write()? I only separated the HTML for clarity instead of putting the entire string inside write(). In get_car(), is there a way to avoid using if/e...
stackexchange/codereview
I'm working on extending the functionality of a photo gallery by adding a thumbnail display, I have multiple if statements set up to adjust the position of the thumbnails. Obviously this is not ideal, I'm trying to put my head around how to use a for loop to iterate the width multiplier and curSlide position. Ideally I...
stackexchange/codereview
This tool adds a new OS user, create directories and configuration files for Apache + NGINX, MySQL (MariaDB) database and user. I tried to take into account the comments from my previous post. Hope - this look little better. Tool is big enough, so - will not post all it's code here, just few main parts - I'm sure, ther...
stackexchange/codereview
I am working on a survivor problem: Complete Question Text: Take a second to imagine that you are in a room with 100 chairs arranged in a circle. These chairs are numbered sequentially from One to One Hundred. At some point in time, the person in chair #1 will be told to leave the room. The person in chair #2 wi...
stackexchange/codereview
Given You’re given the pointer to the head node of a linked list, an integer to add to the list and the position at which the integer must be inserted. Create a new node with the given integer, insert this node at the desired position and return the head node. A position of 0 indicates head, a position of 1 indicates ...
stackexchange/codereview
How can I improve my code and make it more idiomatic? package pascal func NextRow(prevRow []int) []int { x := make([]int, len(prevRow)+1, len(prevRow)+1) x[0], x[len(prevRow)] = 1, 1 for i := 0; i < len(prevRow)-1; i++ { x[i+1] = prevRow[i] + prevRow[i+1] } return x } func Triangle(x int) ...
stackexchange/codereview
I am trying to solve this question. The essence of the problem is this: Given a list of school classes with start and end times, find the total number of non-overlapping subsets. I've written up a DP solution that I think is optimal in terms of time complexity - \$n * \log(n)\$. ''' https://www.spoj.com/problems/ACTI...
stackexchange/codereview
I have a list of lists (many tokenised sentences). For anyone who doesn't know what tokenised sentences are, my list is like so: list1 = [['hello', 'my', 'name'], ['this', 'is', 'stack', 'exchange'], ... ] I have a list of key words as well, key_words. For every sentence in list, I want to check if it is in key_words...
stackexchange/codereview
I am new to Go and the web token / JTW concept. In order to learn Go and learn about web tokens, I am making my own implementation in Go (never to be used, of course). If a user gets authenticated (assume that part is secure), I generate a web token, [header].[payload].[signature]. The header contains a timestamp of wh...
stackexchange/codereview
I needed to write a small program to convert floats from any base to any other base. The thing is, it got big. I know there are other ways to implement the conversions (such as doing subtractions instead of divisions), but isn't there a more simple way to do the whole process? I feel like I'm missing something. Any opt...
stackexchange/codereview
I am provided a bunch of dates in the format (YYYYMMDD) such as: date='20170503' My goal is to convert that date into the number of days in the given year. For example, it would convert: 20170130 to 30 20170201 to 32 20151231 to 365 Here is my solution: import pandas as pd my_date = pd.to_datetime(date, format='%Y%m...
stackexchange/codereview
This is my first game, I need to know how I could improve this code: main.cpp #include <SFML/Graphics.hpp> #include <SFML/Audio.hpp> #include <iostream> #include <sstream> #include <math.h> #include "Menu.h" int main() { const int screenX = 600; const int screenY = 400; sf::Vector2f paddleSize(10, 60); const int ba...
stackexchange/codereview
As my applications rely on VT-100 emulation, I found that I had to do quite a few workarounds to determine the number of visible characters in a string with embedded VT-100 control codes. So that led to the design of this 73 byte snippet. Function would be called as follows; xor edx, edx ; ARG1 - DX = 0 ...
stackexchange/codereview
Is this authentication mechanism vulnerable to SQL injection? If so, how could one exploit it, and what is the most effective way to mitigate this? if (isset($_POST['userid']) && isset($_POST['password'])){ $username = $_POST['userid']; $password = crypt($_POST['password'],'34l5kj'); $query = "SELECT * FROM user...
stackexchange/codereview
I was reading about the elementary sorting algorithms like insertion Sort, selection sort and bubble Sort in Introduction to Algorithms by Cormen and I decided to try and implement it in C. #include<stdio.h> #define MAXSIZE 100 // Maximum number of elements permissible in array void swap(int*,int*); void print(int*,...
stackexchange/codereview
I am creating my models manually. I have five tables in my database as follows: Members MemberTypeMasters Payments Relationships StatusMasters My database looks like this: So far I have 6 files containing auto-implemented properties as below: Models |-- DBCS.cs |-- Member.cs |-- MemberTypeMaster.cs |-- Payment....
stackexchange/codereview
I have a user model, a task model, and a junction model user_task that saves the data joining the two: class Task < ActiveRecord::Base attr_accessor :completed_on has_many :user_tasks class UserTask < ActiveRecord::Base attr_accessible :task_id, :user_id, :completed_on belongs_to :user belongs_to :task clas...
stackexchange/codereview
After using JavaScript for a while, I think callbacks are pretty good for asynchronous programming, but I haven't seen anything similar in C++. What I want to achieve is to start a worker thread from a function/lambda, and then use a callback to receive the result, which will be run in the main thread. The callback is ...
stackexchange/codereview
This function of my program is searching a file that is formatted as first_name last_name rate hours: John Smith 25 80 Mary Johnson 15.5 60.0 ... With one space between each item. The user enters the first name and last name of the employee and while the line is not equal to null it searchs for the employee. If its f...
stackexchange/codereview
I am new to Python and am looking for any feedback/criticism on scripts I have written for work. This script works as I intended, creating multiple .xls files from a workbook with multiple worksheets. I'm just looking to develop a better understanding of how to use Python. So, please, feel free to rip in to what I've...
stackexchange/codereview
I wanted a convenient class to easy access the parameters inside. I am using a lot of math in my game; that's why a wanted to access them through x, y and z (for readability). And this is my outcome. It is a class which lies on top of numpy array. It basically means that I can control a numpy array trough my class. And...
stackexchange/codereview
I am writing some tests that all follow the same pattern, I feel like repeating myself over and over again, how can I reduce the repetition? The (almost) repeating part is in constructor and the class level variables: VariablesPage public class VariablesPage extends LoadableComponent<VariablesPage> { private final...
stackexchange/codereview
I have created a basic login system that asks the user for a password. Here's a list of what it does: When you run the code it will open an Inputbox asking you for a password. There is one criteria: You have to enter a password of 8 characters. If you enter a password with less or more, it will give you an error messa...
stackexchange/codereview
I wanted to learn some regex, but learning regex is super boring so I decided to write a password validator that will validate a password with regular expressions. How it works: You enter a password that has no echo thanks to the getpass library The password is run against five different validations such as, upper cas...
stackexchange/codereview
Possible improvements I see are take lastdigit_num and implement arr_{lastdigit_num} since the math behind this is common for most (integers with cyclicity 4 or 2 common to them) integers and reduces repetitive if statements. For example if num = 23423, then lastdigit_num = 3 and arr_{lastdigit_num} is directly linked ...
stackexchange/codereview
In this code I tried to swap links in a linked list instead of swapping data.Please Review my code. #include <iostream> template<class T> class LinkedList { struct Node{ T data; Node * next; Node(T val): data(val), next(nullptr){} }; Node* head; public: LinkedList() : head(nullptr) {} void in...
stackexchange/codereview
I have been working on this particular sub for a while and it was very very slow from the beginning. Compared to my other subs that go through a lot more data the task of this one is almost minuscule. All it has to do is to go through about ~15 sheets and parse through a couple hundred cells. Since this is a fairly com...
stackexchange/codereview
I started implementing the folowing Matrix class in order to get a better understanding of templates classes in general. For now, it lacks a lot of features, it does very basic things: addition multiplication (only matrix X matrix multiplication is available here) transpose conversion to a string Here are some points...
stackexchange/codereview
I would like to improve code readability and reduce the complexity of my code to improve the maintainability of the source code. If you have any tips, please say so. I was also wondering if it would be a good feature to add a 2-player option to this game. Currently, the game runs off of a word list in which it randomly...
stackexchange/codereview
I am fairly satisfied with my solution here but I would definitely appreciate any constructive criticism of my style and design. The basic idea is to use the strategy pattern to simplify assembling a custom procedural generator. I'm using modules rather than classes for improved simplicity of 'mixing' everything togeth...
stackexchange/codereview
My implementation of BST. Critique will be appreciated! #include <iostream> template <class T> class Node { template <class X> friend class BST; template <class X> friend void clear(Node<X> *root); template <class X> friend bool search(const Node<X> *root, const X x); template <class X> ...
stackexchange/codereview
Here is my approach. Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. import java.io.InputStreamReader; import java.util.Scanner; public class Query { public static void main(String[] args) { Scanner scanner = new...
stackexchange/codereview
Task I tried to code a treemap function in matplotlib, and one of the challenges is auto-fitting text into boxes of different sizes in the treemap, similar to R's package ggfittext. My Code My implementation is as follows: import matplotlib.patches as mpatches def text_with_autofit(ax, txt, xy, width, height, *, ...
stackexchange/codereview
I am working on Project Euler problem 37 and I have the following program: #!/usr/bin/ruby -w require 'prime' h=11 y=0 x=0 while x < 11 if h.prime? == true boo = true f=0 n=h c=0 while n > 0 f += (n%10) * 10**(10-c) n/=10 b...
stackexchange/codereview