instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I've been learning Scala and I'd love to get your feedback in order to improve. As an exercise I made a simple framework for creating command-line user interfaces. Gist package com.ronyhe import java.util.Scanner import scala.collection.Set /** A framework for creating command-line user interfaces */ package object ...
stackexchange/codereview
I was interested to see if it was possible to implement an unsafe stack in C#, so I wrote this: public unsafe struct Node { public int Value { get; set; } public Node* Next { get; set; } } public unsafe class Stack { Node* first; public int Count { get; private set; } public void Push(int value) ...
stackexchange/codereview
I've been using Python for around 3 months and decided to make a simple text adventure game for fun and to exercise a lot of ideas I've been learning about. I've just recently learned about classes and OOP, as well as modules so those are the two features I'm the least sure of. It's mostly a base and has two rooms set ...
stackexchange/codereview
I was wondering if I could reverse a string without using collections and in-built functions of string, Please do add your thoughts on the approach and if possible do share your way of the solution. # Reversing a string with a simple approach # Ex: John Doe -> Doe John str1= "Happy new year! 2022" temp = "" final_str ...
stackexchange/codereview
I'm building a generic flat file reader which looks something like this. public class GenericReader<TComposite, THeader, TData, TTrailer> where TComposite : GenericComposite<THeader, TData, TTrailer>, new() where THeader : new() where TData : new() where TTrailer : new() { public TComposite Read()...
stackexchange/codereview
The problem is adding two lists as numbers L1 = [1,9,9] and L2 = [0,9,9]: ?- sum([1,9,9],[0,9,9], Lo). Lo = [2,9,8] But I also wanted to add this: ?- sum([8,1,9],[1,8,2],Lo). Lo = [1, 0, 0, 1]. I used the backtracking method I've learned: link([],L,L). link([Head|Tale],L2,L3):- link(Tale,L2,L), L3=[Head|L]. inve(...
stackexchange/codereview
I frequently have patterns as below, usually not this simple, which require me to first code a working solution for a single test case, and then to refactor the code to make it more concise. See the first incarnation below, then the final code. I'm looking to see what other techniques some use to skip the initial step,...
stackexchange/codereview
I was practicing implementing a hash function. I tried to use linear probing to insert in hash table. The insertion is working alright but I am not satisfied with the recursion. It doesn't feel like "good recursion". The Linear_Probing function instead of being recursive itself uses two other functions (excluding hash ...
stackexchange/codereview
Created FilePickerComponent recently. I'm new to React/Web development. Could you please help reviewing this code - export const FilePickerButton: React.FunctionComponent<FilePickerButtonFCProps> = ({ position, ariaLabel, ariaDescription, disabled, iconName, toolbarButtonId, acceptParams, ...
stackexchange/codereview
I made this function to test if the content has 301 redirections.. Please can you help me optimize it better because it's too slow function contains_http_301_link($content, $current_site){ $pattern = '~<a(.*?)href="([^"]+)"(.*?)>~'; $links = array(); // Check if there is a url in the content if(preg_match_all($pattern,...
stackexchange/codereview
I am learning Typescript and created a straightforward to-do list project to practice some basic concepts. I am able to Edit the todo Delete the todo Mark the todo as completed I want to how can I better structure my code and what typescript best practices I am not using. index.ts import { v4 as uuidv4 } from 'uui...
stackexchange/codereview
I know that my let configFilePath = Prelude.head args is unsafe and was wondering how I could handle it better. My deployment almost always has a file at ~/config.cfg so I suppose I could have used mayHead then later maybe to safely default the filepath to ~/config.cfg. This was all done a little rushed, so I'd like t...
stackexchange/codereview
I am using a script to open a bunch of Excel files, copying two or more sheets into a new file and saving this new file. It sure beats doing it manually, but I think it could be faster. Here's my script: Sub Flujo() Const FilePath = "A path..." Const Destination = "Another path..." Dim app As New Excel.Application ap...
stackexchange/codereview
Snake on a plane 2.0 This is the first iteration of an iterative review. The next iteration is found here: 3D 1st Person Snake Game #2 When I figure out how to add wings, this snake is going to have hyper-wings. (Note: I am not asking for help with these being implemented) My code creates a 3d version of the snake game...
stackexchange/codereview
Would anyone be so kind as to review my code for Memory? import java.util.*; public class Cards { public boolean gameInProgress = true; public void shuffleCards() { Scanner userInput = new Scanner(System.in); List cardList = new LinkedList(); List matchedCards = new LinkedList(); ...
stackexchange/codereview
I wanted to implement abstract factory method in typescript with react for sharepoint framework webpart. So I tried to translate ideas from this Java tutorial. I don't have method implementations yet, but so far it compiles, and I want to know if I am doing it right: component .tsx file import * as React from 'react';...
stackexchange/codereview
The project is an API that will itself make HTTP requests to external webservices. Since this is PHP, we actually chose to use guzzlehttp. Now the library itself doesn't matter much, but I'm scared we'll be stuck with it if it ever has a major change (it already happened in the past). So I thought I'd create an inte...
stackexchange/codereview
As mentioned in Project Euler #2 in Swift, I intend to work my way through Project Euler using Swift to make sure there aren't any tricks I'm missing. This is the problem statement for #3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? This solution if few...
stackexchange/codereview
What follows is an implementation of the java.util.Map interface with weak values. This means that entries should be removed from the map when their values become weakly reachable, in the same way that WeakHashMap removes entries whose keys have become weakly reachable. It is intended to fully implement the contract of...
stackexchange/codereview
This is a simple class that runs a timer every 10 seconds to update the title with some information like how long the application has been up, depending on the datetime that is set in another class when the application has finished booting up and is responsive. This application is part of a game server and it just disp...
stackexchange/codereview
My goal was to create an zip-like iterator to selectively iterator over a subset of arrays in a larger manager object, compare itself to any other zip-like iterator, but can be copy constructed from any zip-like iterator with the same template parameters. It's to be used like this: #include "Iterator.h" struct Positi...
stackexchange/codereview
want to write this code in simplified way using SOLID principles. Any help would be highly appreciated.Can i implement inheritance to do this. void CalculateTaxAndRewardPoints() { if (state == TEXAS) { rate = TX_RATE; amt = baseRate * TX_RATE; ...
stackexchange/codereview
Problem is - If in an MxN matrix, a zero is encountered, the entire row and entire column should be set to zero. Example - 8 4 2 2 3 7 1 0 1 9 8 4 Should become: 8 0 2 2 0 7 0 0 0 9 0 4 I encountered this problem today and came up with a solution. I'm hoping for some feedback regarding...
stackexchange/codereview
As you know, converting an int to an enum is straightforward. Doing it generically with type/range checking isn't. I looked for a reusable example since this seems like a common situation but did not find a suitable one. If it exists, please let me know. Below is a C# extension method that encapsulates this behavior. A...
stackexchange/codereview
I've made some modifications to the async client example found on MSDN for the purpose of testing a server application. It works entirely as I expect and/or want, even running multiple clients, but as I intend to use this as the foundation of the actual client and not just for testing I figured I'd see if I'm doing any...
stackexchange/codereview
I am writing an ASP.Net MVC app which has a page that will display a standard table which will contain a person's hours for the week. The basic structure of the table would be a 7 column, muti-row table. The Header of each column would display the Day of the Week with the total hours worked that week. There would then ...
stackexchange/codereview
This is a simple program converting user input decimal numbers into octal ones. #include <iostream> using namespace std; main() { int de,oc,y,i=1,octal; float decimal,deci,x; cout<<"Enter decimal no :: "; cin>>decimal; de=decimal; deci=decimal-de; cout<<"("<<decimal<<")10 = ("; while(de...
stackexchange/codereview
I've created a report in Excel which connects to SQL Server via ODBC and I wrote some VBA to allow parameters to be passed in optionally. At this point everything works as expected but I'm curious to see if there is anything I can do to further improve it. I've brought the execution time for the full queryset (~60k rec...
stackexchange/codereview
There is a matrix of \$m\$ rows and \$n\$ columns where each row is filled gradually. Given the first row of the matrix we can generate the elements in the subsequent rows using the formula: $$\begin{align} a_{i,j} =&\ a_{i-1,j} \oplus a_{i-1,j+1}\quad\forall j:0\le j\le n-2 \\ a_{i,n-1} =&\ a_{i-1,n-1} \oplus a_{i-1,0...
stackexchange/codereview
I would like some feedback on my code. I am currently building a payments solution in a serverless lambda project. This what I came up with (very basic code at the moment): // "interface implementation" export default class Stripe { constructor() { this.stripe = new Stripe() } async charge(data) { try { ...
stackexchange/codereview
I have an object, KbArticle, that originally in it's constructor, would try to return null if the SQL query that retrieves the data for its required properties came up with 0 rows. A friend told me that constructors shouldn't return null, and that I should look into the Factory Pattern. I did and I see the benefits, so...
stackexchange/codereview
My code takes the input submitted by $ _POST, via a checkbox array. I process the array and check the sent data if there is a particular string in it, which is set as my default. If I have a string, which is my default, I just go through implode and add ",", if my default string is missing in the data. I add and sort t...
stackexchange/codereview
The codes below get the rows of data until it reaches the total running quantity limit. Notice that the SQL uses sub-query. select *, sum(Quantity) over (order by id) as RunningQty from #PurchaseOrderProducts. I'm worried that the sub-query would get all the data from the table. Is there a way to improve the performanc...
stackexchange/codereview
I wrote this quick script to convert a genotype file into a BED file. Running it seems to be taking a very long time. #BED file format #http://genome.ucsc.edu/FAQ/FAQformat.html#format1 #1.chrom - The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671). #2.chromStart - The starting ...
stackexchange/codereview
I'm unsure about how to simplify this method properly. The method is basically responsible to allocate data. The response object is a collection of objects. Each object contains an attribute called order and i have to distinguish between visible and invisible elements. Visible elements are represented by positive integ...
stackexchange/codereview
I have been teaching myself python in my spare time and so far I think I have figured out the basics. However, I am fairly certain that my code is extremely unprofessional and the way I write it is incorrect. So far, I have been going on a "If it works don't screw with it" philosophy but I would like to learn how to ac...
stackexchange/codereview
For our first project in my C++ course this semester we had to do a simple calculator program. My background is mostly in Functional languages. What's the best way to do generic programming/functional style in C++? We're doing C++14 standard in this course, but C++17 also welcome! main.cpp #include <iostream> #include...
stackexchange/codereview
I wrote a node editor library which can be found here. What can I do to make the code more readable and maintainable? I'd like to stay in plain javascript and keep a single reference to use the library. "use strict"; /************************** * Main object **************************/ var Ned = { create(svg) { ...
stackexchange/codereview
I'm writing driver code for the SPI peripheral (as part of a tutorial) on a Nucleo64 (STM32F446RE). The instructor recommends writing this code: // General macros #define EnableStatus uint8_t #define DISABLE 0 #define ENABLE !DISABLE void SPI_EnablePeripheralClock(SPI_RegDef_t *pSPIx, EnableStatus status) {...
stackexchange/codereview
A while back I wrote a socket programmed chat in Python. This question isn't really about the program specifically, moreso on conventions of Python and my style of coding. I've only been using Python for a couple of months and any pointers would be appreciated. Here's some code I'm curious about: # in case of inappropr...
stackexchange/codereview
Suppose I've got a JavaScript function that I'm treating like a class - that is, I want to make many instances of it: function Blerg() { this._a = 5; } Blerg.prototype.getA = function() { return this._a; } Blerg.prototype.setA = function(val) { this._a = val; } This class has one attribute, a, which the constr...
stackexchange/codereview
Aim is to provide total head movement in different disk scheduling algorithms namely FCFS, SSTF, LOOK, C-LOOK, SCAN, C-SCAN. #include <iostream> #include <cstdlib> #include <conio.h> #include <math.h> using namespace std; int compare (const void * a, const void * b) { if ( *(int*)a < *(int*)b ) return -1; if ( *...
stackexchange/codereview
See the next iteration. I have that method for computing Fibonacci numbers \$F_n\$ (\$n = 0, 1, 2, \dots)\$, that relies on computing $$ A = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}^n. $$ The solution is then read from \$A_{1,2}\$. Now I can easily compute, for instance, \$F_{100000}\$. However, in this code snipp...
stackexchange/codereview
I'm learning to code with Deitel's C: How to program book, 6th edition. Here's Exercise 5.9 (Parking Charges): A parking garage charges a $2.00 minimum fee to park for up to three hours and an additional $0.50 per hour for each hour or part thereof over three hours. The maximum charge for any given 24-hour period ...
stackexchange/codereview
I'm processing a list of files, and want to check the filenames against a list of regex, like: IGNORE_FILES = [ re.compile('^./Vendor.*'), re.compile('^./Pods.*'), … ] def in_blacklist(file): return len(list(filter(lambda r: r.match(file) != None, IGNORE_FILES))) > 0 def in_whitelist(file): retur...
stackexchange/codereview
The task is taken from leetcode TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/dec...
stackexchange/codereview
What do you guys think: OPTION #1 (same font-face name and change font-weight) @font-face { font-family: ProximaNova; src: url('/fonts/ProximaNova-Regular.ttf'); font-weight: normal; // THIS IS NORMAL font-style: normal; } @font-face { font-family: ProximaNova; src: url('/fonts/ProximaNova-Semibold.ttf'); ...
stackexchange/codereview
We are using the Aspose PDF library to work with PDF files. Aspose requires the license to be set once per process. Accordingly, I have created the following common static method that sets the license. Any code that needs Aspose will call into this method. public class ConfigurationService { private static bool isA...
stackexchange/codereview
I came across a CocoaControl ZFPlot and wanted to extend here. I ended up writing a base class (ZFPlot shown below) as well as several extensions (ZFLine, ZFScatter, ZFBar, none shown here for brevity). I'd really love feedback on everything in the code below but especially on readability, performance, and structure. I...
stackexchange/codereview
I'm currently learning c++ coming from a python background, so I'll include a solution in python and in c++ for the following problem statement: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly on...
stackexchange/codereview
welcome everybody I wrote a simple code to measure time easily Features Easy include and just call timeit() Fast It just calculates the average time in the loop Light No lots of code, just one function is written CrossPlatform It doesn't using any third party libraries, so it should work anywhere Syntax timeit(name...
stackexchange/codereview
I have created a reusable code for jQuery tab functionality for my client site. Every thing works fine but the only thing I am worried is that the lines code I have written for this small feature is very high. Can any one help me to shrink lines of code or any suggestions. Here is my JavaScript code: /** * @param lin...
stackexchange/codereview
I have this blog lurking around in the web. It's just static HTML, but I was interested to keep track of all the views on that blog. Finally, I end up with the following web application: (The Java backend resides entirely here.) com.github.coderodde.weblog.viewcounter.CountViewServlet.java package com.github.coderodde....
stackexchange/codereview
I am working on a project, neurodecode, which uses a logger based on the logging library. As I am not very familiar with logging, I don't know how to further improve this aspect of the project. The project is constructed as: neurodecode |_ __init__.py |_ logger.py |_ folder1 |_ script1.py |_ script2.py ... The...
stackexchange/codereview
Given The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Solution def max_factor(num): """Find the maximum prime factor.""" factor = 2 while factor * factor <= num: while num % factor == 0: num /= factor factor += 1 ...
stackexchange/codereview
After the amazing feedback from these questions; I have prepared a third version of the original posted code. The Idea is the same: An std::size_t variable threads_ready is increased to threads.size() until all threads are finished with the payload, and then back to 0 when all threads are ready to execute again. I eli...
stackexchange/codereview
I made a function which checks if a word is the opposite of each other (ex: word and drow) and then realized that with minor changes it could also be used to detect if a word is palindrome. They both return bools, false means they aren't opposite/it isn't palindrome, true means they are/it is. First function: bool oppo...
stackexchange/codereview
Most of my slow queries on my server are due to a single "find" query. I have a collection that represents website pages. I want to be able to look up a page in the collection by URL. The caveat is that a website might have URLs that redirect to it. I've modeled my schema (with Node.js/Mongoose) like this: { 'u...
stackexchange/codereview
Just want to know if I used CSS Grid properly along with flex. I always have that feeling that what I'm programming can look better and be shorter, etc. Thoughts? /* Main */ @import url('https://fonts.googleapis.com/css?family=Quicksand'); body { background-color: #ecf0f1; margin: 0px; padding: 0px; } .grid { ...
stackexchange/codereview
I have written this code for checking whether all leaves are in the same level or not, in a binary tree. Any suggestion or improvement is appreciated. import java.util.LinkedList; import java.util.Queue; public class Methods { //* ---- Method for check whether all leaves are in the same level or not --- * ...
stackexchange/codereview
Here is a short and simple Ajax method that returns "True" or "False" if an entity exists in a database via a stored procedure that returns just "Y" or "N" (the details of this entity and database are not relevant to my question though). This is the first time I've used the C# using() statement, and was wondering if ...
stackexchange/codereview
I want to pass a predicate into quick sort. The issue I'm running into is that the predicate must have two arguments, the pivot and the element of the list's tail. As far as I know though, predicates can only have 1 argument. Here's what I have so far (it runs, I just want to improve it): import Data.List quicksort ::...
stackexchange/codereview
I have implemented a collision check algorithm that I have created for my game, and the algorithm uses recursion. Now it all works fine, and I thought to myself, what if there was a way to solve this algorithm, without using recursion, and more something with promise callbacks, or something, but unfortunately after res...
stackexchange/codereview
I created a simple number-guessing game. Do I need to divide this program into functions? Please offer suggestions. #include<iostream> #include<string> #include<ctime> void drawLine(int n, char symbol); void rules(); int main() { int amount; int bettingAmount; int guess; int dice; std::string pl...
stackexchange/codereview
I use the code below to calculate the required information from other tables. I used joins to display names instead of IDs and to get required sums from other tables. I used COALESCE to convert null to zero. I had to used it again if I need to sum already COALESCED values. The code below is hard to understand and it's ...
stackexchange/codereview
Trying to improve my HTML and CSS. Creating a Basic Table using CSS grid, to match as closely to this image: Please ignore the color red and green in the rows and Some rows are missing since it was used with data inside a react application and since I only care about the HTML and CSS I copied only what was relevant. H...
stackexchange/codereview
I'm new to ruby, later I asked about ways to refactor code (Parsing GPS data), one man gave me direction, so I made class for Median filter and it will be great to read review for my work. What guys are you thinking about it? Is it still smells? class MedianFilter attr_accessor :step def initialize(step, keys) ...
stackexchange/codereview
I have this regular expression that extracts guid and couple of other attributes like name, type and version. Please review the regex for any optimizations and improvements. Strings are always in the pattern of /publication/guid/type/name;version=1234 regex (([a-f0-9]+\-)+[a-f0-9]+)\/(.*?)\/(.*?);version=(\d*) Tes...
stackexchange/codereview
My aim is to avoid using threadpool threads for CPU bound work, thus avoiding a situation where IIS stops responding to new requests. Can you see any problems with the code below? Is this a safe/clean approach? Can you offer any improvements? private static ConcurrentQueue<Job> Jobs = new ConcurrentQueue<Job>(); ...
stackexchange/codereview
The task is taken from leetcode Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three ...
stackexchange/codereview
I have two local maven projects A, and B. B is dependent on A. A |- resources/log4j2.xml B |- resources/META-INF/log4j.xml |- Maven Dependencies |- A |- And other dependencies... Both A, and B exports the log4j xmls to jar. However, as I only need the B/resources/META-INF/log4j.xml to my final B.jar, I tried...
stackexchange/codereview
Request input (Z) from user, \$-65535 \leq Z \leq 65535\$. Check if \$(X^2)-(Y^2)=Z\$ (while \$0 \leq X,Y \leq 1000\$). I wrote a code which will receive Z from user, if it's negative, store the negative value and continue as if Z is positive. Two loops, one which will check Y from \$0 \mapsto 1000\$, after that add ...
stackexchange/codereview
I have the following code that simulates the monty hall problem (see google for more details). I used sets to do it but is there a more intuitive or efficient way to do it? import random as r from sets import Set def montysim(N): K = 0 for i in range(N): s = Set([1,2,3]) doorstoswitch = Set([1,2,3]) ca...
stackexchange/codereview
I have a list of orders (each order is a dict) which looks like this (simplified version) : [{'name' : XXX, 'id' : { 'order_id_local' : 'xxx_001'}}, {'name' : XXX, 'id' : { 'order_id_local' : 'xxx_002'}}, {'name' : XXX, 'id' : {}}, {'name' : XXX, 'id' : { 'order_id_local' : 'xxx_002'}}, {'name' : XXX, 'id...
stackexchange/codereview
I will import given code for my main QMainWindow.(I only add import sys etc. to run it) Is there a more compact way to code this lines. Output is correct for my expectation. from PyQt5.QtWidgets import * import sys class ButtonWidget(QWidget): def __init__(self): super(ButtonWidget, self).__init__() ...
stackexchange/codereview
Sometimes I need an NSDictionary-like object that maps a few integers (non-negative) to objects. At first glance, NSMutableArray is great for this, provided that the indexes aren't too high so I came up with a quick category to allow holes in an array: @implementation NSArray (FoundationAdditions) -(id) objectAtChecke...
stackexchange/codereview
Warning Wall of text, little bit of code. This question is about as much as introducing the language as it is about whether or not I still know how to write the language. Introduction Programmable Logic Controllers (PLCs) are industrial, heavy-duty computers used to control (semi-)automated processes in factories. The...
stackexchange/codereview
I'm working on a program that will (hopefully) eventually allow me to perform frame rate analysis like Digital Foundry does. The code below works (as far as I know), but before I iterate on it, I'd like some feedback as I'm new to both C++ and OpenCV. I say "as far as I know" because I'm not sure how "lossless" my lo...
stackexchange/codereview
I recently posted an answer to this SO question as I did not think any of the current answers were satisfactory (most don't even answer the question!). I was wondering if anyone could offer any improvements on my solution to this problem? I'm most interested in performance here. Also note this algorithm does not requir...
stackexchange/codereview
I have this small C++ program for computing the \$n\$th Tribonacci number at compile-time. My main concern is: is it possible to get rid of the statickeyword (I had to use it in order to silence my compiler (VS 2019))? Code #include <cstdint> #include <iostream> template<uint64_t N> struct tribonacci { constexpr s...
stackexchange/codereview
This code gets detailed information about a particular game from an online database using an API Get request. The question I have doesn't pertain to the request but is more about the code itself. The code works. I just think it is long for what needs to be done though. I was wondering if this code is able to be refacto...
stackexchange/codereview
I wrote a Hangman game to try out some of the new features in C++11. I'm pretty new to C++, and I would like some good advice on how I can improve this code (in terms of conventions, bad/good practices, ...): #include <iostream> #include <fstream> #include <vector> #include <string> #include <stdexcept> #include <rando...
stackexchange/codereview
Yesterday, I introduced a bug into our codebase by calling #titleize on a string that could possibly come in as nil: def route medication.route_name.titleize end This threw an error on production and a coworker fixed this by adding try: def route medication.route_name.try(:titleize) end I'm not totally happy with...
stackexchange/codereview
I initially posted a question on SO. I have come up with an answer for the same. Basically, given two dicts of models and parameters, user can create an object, and get the report in 5 steps. Following is the code. import numpy as np import pandas as pd from sklearn.model_selection import train_test_split, GridSearchCV...
stackexchange/codereview
I have a very basic method at the moment that fills text boxes with data relevant to the selected company. I load the data into a DataGrid using this method; CompanyDataService namespace SdcDatabase.Controller { class CompanyDataService { public DataTable GetCompanyList() { string co...
stackexchange/codereview
This is a question from the book "Cracking the Coding Interview". Write a method to decide if two strings are anagrams or not I think interviewer will not be convinced with this solution because here it is no test of logic. Please help me to optimise this solution. #include <iostream> #include <string> #include <algo...
stackexchange/codereview
I have a requirement to validate file names related to architecture after they are uploaded. Once they have been uploaded I must warn the user if the file name is not standards compliant. What's in a name To be standards compliant a file name must consist of 7 parts after the extension is removed from the name, and: p...
stackexchange/codereview
I frequently use MathJax, and often I need to write matrices. Since writing matrices using MathJax is very tiresome task, I decided to automate it. Code: import numpy as np import pyperclip class Conversion(): def __init__(self, matrix, n = None, m = None): if matrix == None: self.matrix = n...
stackexchange/codereview
The purpose of this code is to generate the CSR and the Private Key. The scenario is that we have some clients for whom we run websites and for the SSL component we want to have a page on our site where they can input the fields like domain name, company name etc and then the system will generate the CSR (and return it...
stackexchange/codereview
Greetings. I'm a newbie python developer who just started using PyQt5 as his major GUI development tool. Because of this, I have started a side project known as NyvoAI, just for gaining more knowledge in the branch of GUI development with PyQt5. The main project goal was to gather multifarious Artificial Intelligence t...
stackexchange/codereview
Currently I am working on some kind of mechanism which will be able to monitor directory and when file with extension .pdf appears I need to mock some kind of processing on this file. Let's say, renaming and creating log file with the information of this processing. And as I wrote it is some kind of mock. So informatio...
stackexchange/codereview
I have this piece of code which given a list returns another list which combines every element with every other element (without repetitions) using a given function as a combiner. I came up with three different version (2 of them listed below, fastest to slowest), and now I'm asking for help to optimize it/them even fu...
stackexchange/codereview
I am learning to write a multi-threaded linked list class implementation with basic functionality such as push to front or back, pop_back and read. I came up with this implementation: #include <iostream> #include <thread> #include <mutex> std::mutex m; template<class T> class Node{ public: T data; Node* nex...
stackexchange/codereview
I would like to modify my shortest path finding code to use multithreading and improve its performance. The algorithm must be able to work with negative weights, and as a result, we cannot use Dijkstra's algorithm. Instead, our approach combines three algorithms: Bellman-Ford, SPFA_Queue (shortest path fast algorithm, ...
stackexchange/codereview
I'm currently learning python with an udemy course. I wrote this code, which is meant to be a higher lower game, where the second answer always stays. As far as i tested it my code is working fine, but i feel like many solutions are bad. Its just felt weird coding some of the solutions, but i cant come up with better s...
stackexchange/codereview
Background I am currently participating in a tic-tac-toe coding challenge. During their move, each participant is given the board state and their team, X or O. The blank board is: [[' ',' ',' '],[' ',' ',' '],[' ',' ',' ']] With 'X' and 'O' being added to the board, for example: [[' ',' ',' '],[' ','X',' '],[' ','O'...
stackexchange/codereview
I've posted an excerpt from my Nginx configuration with the hope that someone can give me advice on anything I've done wrong or could do better. Please note that the below config works, but has been edited for brevity. The area I'd like you to focus on is TEST1 and TEST2. TEST1 is redirecting any requests to /folder/...
stackexchange/codereview
I want to map functions from my functions library (Map called as chain) to input string str. Also that functions (Twitter.removeRT, ...) are regex which replace substrings in input str. I think it is better to save that regex-functions in Map like in my example. So, the code: Tail recursion variant def filterTwitter2...
stackexchange/codereview
I've written a fairly simple script in F# which reads structured data from binary. I've avoided using the built-in .NET BinaryReader class because it's stateful in that it maintains its index in the stream. Instead I wanted to write a purely functional implementation. I'm doing this for my own personal learning so YAGN...
stackexchange/codereview
I am working on the largest Java program I have undertaken to date and feel uncertain in my current code practices. I think that I state and repeat things that don't need to be which can become a headache as development goes on. Specifically, in my GridBag Constraints. I have worked with GridBagLayout before and had go...
stackexchange/codereview