instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
We are given a map of sides of length n and m (both n and m are less than 1000), divided into n*m fields (squares of side 1). The map looks (for example) like this: . z x . x . x x . . . . x . x x . . n . Here n=4 and m=5. We start from the field with "z" and we have to get to the field with "n". Suppose we are at po...
stackexchange/codereview
Task: This function searches given null terminated string pStr by given subset of regular expression pMatch. Return value is matched string appeared in pStr. If nothing has matched, return value is empty string. The subset of regular expression grammar is defined as follows: A string is set of 8-bit characters. Beware...
stackexchange/codereview
I have a form in which I am collecting data from two applicants. In order to minimize HTML duplication I built an applicant Vue component that generates each applicant from a template. Each applicant has an applicant data object. My question is regarding the best practice for data binding these applicant objects inside...
stackexchange/codereview
I am getting into multithreading and I was wondering if the code below is good practice or not. This is one of my first tries at multithreading. Is there a better way of getting the values from the Future<Integer> rather than saving them in a list and summing them up afterwards? // Counting the number of prime-numbers...
stackexchange/codereview
I'm getting a lot of timeouts with the following code and I'm running this method around 10,000 times so I need to figure out how I can optimize this so the timeouts will stop. I am getting timeout errors when I try to call the fill method and I believe it is because the queries aren't done processing yet. It is a loca...
stackexchange/codereview
I am beginning to learn Scala and functional programming, and I came across this puzzle. This looked like good practice and I have a solution but just want some hints in terms of functional approach to this. I did rip off the evaluate function from Stack Overflow. I particularly am interested in if the approach of crea...
stackexchange/codereview
I'm working with a Rails app that requires a few layers of infrastructure to run: MySQL, Redis, Sidekiq, and (of course) the Rails server. I wrote some functions to help me manage the various servers (start/stop/check and one to kill the rails server when it gets hung up and decides to eat all my memory rather than shu...
stackexchange/codereview
I played around with some optimizations when answering this SO question. Sought is a function which given matrices x of size (m, l) and y of size (n, l) returns a matrix of size (n, k) where each row consist of the k row numbers in x closest to the corresponding row of y. The important requirement was that this shoul...
stackexchange/codereview
As I understand creating lots of resource managers in C# may be a bad idea so I thought that the best thing to do would be to create a singleton for this. However, I'm not 100% if this is a good idea, or if this is a good way to implement it. The main thing about the implementation I am unsure about is making the "Ins...
stackexchange/codereview
In my game there are space ships and each of these space ships tracks which other ships are in range of it. I need to perform certain logic when a target ship comes in range of another ship, and certain logic when the target ship leaves the range of the ship. I am looking for advice on the most performant way to manage...
stackexchange/codereview
I have a Back function, and it is growing. I also think this is terrible, but I don't seem to get how it can be improved: public void GoBack() { NavButtonUsed = true; Forward.Insert(0, Back[0]); Back.RemoveAt(0); if (Back[0].Title.StartsWith(" ") && CurrentItem.Menu != Back[0].Menu) { swi...
stackexchange/codereview
I am attempting the matched brackets problem. I have written a Python program which seems to do the job but is very slow and thus exceeds the time limit. Please help me making this code more efficient. I have explained my code in the comments. length = int(input()) inp = input().split(' ') inp = [ int(x) for x in inp ]...
stackexchange/codereview
I have a system that can put and get messages from a messaging middleware (JMS), which is asynchronous. I need to provide an API that allows synchronous call, as in, when the API/method is called, it returns only when a response message is received or until a specified time out. In short, the calling thread needs to wa...
stackexchange/codereview
I have created a small crypto extension and I want a deep review of it, such as possible fixes (for hidden problems) and tweaks... 1- Crypto.cs public static class Crypto { public static Salt Salt = new Salt(); public static string GetMd5Hash(this string input) { using (var md5Hash = new HMACMD5(S...
stackexchange/codereview
I have a simple function that takes a string and reverses it: def reverse(string): begin = 0 end = len(string) - 1 strlist = [i for i in string] while(begin < end): temp = strlist[begin] strlist[begin] = strlist[end] strlist[end] = temp begin += 1 end -= ...
stackexchange/codereview
I am using the following Depth-first search algorithm to compute value of a property called rotation_absolute based on previous values of rotation of parent elements recursively. The result of the script is correct (open console to see the result) but I would like your code review regarding performance, considering tha...
stackexchange/codereview
I have a legacy code (might be 20 years old) as shown below. Where they are using the non ASCII '§' char in the code. First they are preparing a SELECT query and the SELECT query looks like this... SELECT 'ERROR_ID=§' || ERROR_ID || '§' || ' AND ' || 'DAT=:' || ... They are using below code while preparing the SELE...
stackexchange/codereview
Validate IP Address I got this problem during an interview. And would like to get some code review. I also wrote several tests with the expected output, and they all passed as expected. Validate an IP address (IPv4). An address is valid if and only if it is in the form "X.X.X.X", where each X is a number from 0 to 255...
stackexchange/codereview
I don't really have a problem, but my code bothers me, because I know it could be done in a much better way. I have an enum of 4 directions: north west, north east, south east and south west. And I have a method that converts a vector to one of those directions. The method prefers North and East, so values of 0 would r...
stackexchange/codereview
i'm trying to create a url router system, for educational purposes, that has a similar usage like Laravel has, but i'm curious about how i can register the routes like laravel does (with single calls to static methods), here's my "conceptual" code that i made using a TDD approach: $Route = new Route; $R...
stackexchange/codereview
If you'd like to pivot this: ┌────────────────────┐ │One Two Three Four│ ╞════════════════════╡ │One 2 3 4│ │Five 6 7 8│ │Nine [10] 11 12 │ └────────────────────┘ to this: ┌───────────────────┐ │One One Five Nine│ ╞═══════════════════╡ │Two 2 6 [10]│ │Three 3 7 11│ │Four 4...
stackexchange/codereview
I wrote this code to De- and serialise structures afap using IL generation (comments describes C# analogue). What can be improved here? using System; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; namespace StructInterop { public static class StructInterOp { ...
stackexchange/codereview
Write an efficient function in the Python language called SmartSearch. This function will receive a sorted arr array of integers of size \$n\$ containing at the beginning \$m\$ "significant numbers" and the rest of the numbers are "fictitious numbers" whose value is 9999. The function also receives a number \$x\$ to b...
stackexchange/codereview
Just used DI containers in MVC projects, via constructor injection, and I'd need to now inject a service into a console app. I'm using Autofac so I followed what I found here. The code would be something like this: The service the console app depends on: public interface IBatchService { void WriteInformation(string...
stackexchange/codereview
I have a time-critical calculation running on an ARM Cortex-M0. This is the fastest 32x32 bit -> 64 bit multiplication that I can come up with. The following C compiles almost 1-1 to assembly instructions: //consider each arg as two 16-bit parts. //r0 is Aa is A<<16+a. r1 is Bb is B<<16+b //then Aa * Bb = (A*B)<<32 + (...
stackexchange/codereview
I have written a LaTeX package to visualize B+ trees. The main purpose is to provide a simple but powerful package which provides a convenient interface. However, this is my first LaTeX package and I would also like to know where I can do better. So I'd like to get reviews from these two points of view: Simplicity of ...
stackexchange/codereview
I am working on an SMS marketing project based on Yii2 Framework (PHP 7.3 & MariaDb (innodb engine)) where we have to move the logs from different tables to the archive db, which is total a different DB server from the live one. The log tables keep growing and we had to setup an automated job which runs 3 times a week ...
stackexchange/codereview
My goal here is to make a program that makes a list of passwords that has no doubles, making an end result of every combination of passwords in a specific area. print "Make sure you have a botnet army for this..." print "You will need one or this will take about 20+ days to compile.\n(Depending on your cpu speed an...
stackexchange/codereview
I want to load credentials into my program from different sources. If one source does not have 'valid' credentials (in my case valid credentials are all tuples of two non empty strings), try the next source until you get a valid credential (or the sources run out). I wrote a method (validate) that checks if credentials...
stackexchange/codereview
I have this little function to validate e-mail. It's a little piece of code to search major mistakes in e-mail input and it's part of a bigger program I have to complete as a school assignment. Is there a better way to do it in C? I'd like to do it in regex but if I have understood correctly, C under Windows doesn't ...
stackexchange/codereview
I'm building a small MPL module in one of my utility libraries for fun and learning experience. One of the problems I'm trying to solve is getting a list of all indices where a sequence of types appears inside another sequence of types. Example: static_assert(is_same < List<int, char, int, int, char, int, double, ...
stackexchange/codereview
I have a lot of files. I care about those files. I also care about good programming practices and learning proper python. Given the described context, it seemed appropriate to implement my own automated backup utility (as an exercise) What I bring here is my attempt at the task and any advice is welcome. Description: T...
stackexchange/codereview
My program works, but I'm really new at programming and am just curious if anything I wrote could be written better or more efficiently. It's suppose to display rainfall totals for the previous 12 months and say if they are + or - the average of those months. My teacher this semester gives no feedback or criticism on p...
stackexchange/codereview
I would like to generate Millions of Random String and Hashes in Java fast as possible. For the moment, @Turing85 gave me a pretty good code who was pretty fast only 5 sec for 50M of random String but the next problem to which I am confronted is the slowness when I hash my passwords in my String. The only problem is th...
stackexchange/codereview
package com.unisa.pf.sp52016.assign01; import com.unisa.pf.sp52016.assign01.Predator.STATUS; /** * <strong>Overview</strong><p> * This code comprises a component of a larger game. You have been asked to implement the structure * that maintains a group of Predators that could be a Pack of friendlies or enemies. ...
stackexchange/codereview
This is Conway's Game of Life written in Python and using Tkinter for GUI. Problems are: The "Play" button works so slowly. I can see how the canvas is redrawing from top to bottom. But when I quickly click on the "step" button - I see that I want to get from "play" button: I don't see redrawing process. How can I mak...
stackexchange/codereview
I have to read from a file and store the data inside an std::vector container. The procedure of opening the file, reading and writing onto the container are enclosed in a routine: readData. Reading and writing include the use of several std functions that may fail. Instead of putting a try catch for each of those std f...
stackexchange/codereview
I have built a quiz app. It is my first project so the purpose is to learn app development at this stage. There are two key things which I am wondering how to do better (the app is fully functional). 1: Livedata / flow / room I have the following data class @Entity data class SavedScores( @PrimaryKey(autoGenerate =...
stackexchange/codereview
I have a model such as this below that acts as a base model. Several other models inherit from this one since they will all share common properties. Would an approach like this fit best practices or would it be better to go another route. I'm aware that composition is always considered a best practice. public class Bas...
stackexchange/codereview
I read this question about the "100 Doors" puzzle, and thought that it would make for a good quick exercise. I ended up with two implementations. The first is more straightforward and uses a vector to store the boolean state of each door. This is quite slow though, and having a vector of true and falses seems off, so I...
stackexchange/codereview
I am trying to create an outline of what a character is in a game. Then I want to create 10 different characters and compare their stats at different levels. I am creating an interface called Hero that looks like this, public interface Hero { // define methods that must be defined across all character types ...
stackexchange/codereview
In my application I need some resources to be loaded and I have services to load each of them and then I need some point to know that all requests finished. First thought was to use $q.all with array of promises from that services. But it would be resolved only if all promises resolved which is now always the right cas...
stackexchange/codereview
The Program I wrote this program as an answer to a question I thought of for Programming Puzzles and Code Golf. To avoid cross-posting, I will only summarize the requirements: Solve a game in a 3x4 grid that is similar to the fifteen puzzle, except there are colors instead of numbers, and some colors are duplicated; 4...
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
This is my first program I can call 'something'. I would be glad to hear what you think of it, so I wouldn't pick up bad habits further on. It catches errors, but requires numbers to be separated from operators. It ignores a lot of characters, therefore (+ 2 2) is as valid as (+ 2 blargh 2) 100 lines of code + comments...
stackexchange/codereview
I am working on an algorithm question in which I need to find out pair of number out of 2 sorted arrays which sum up to the given number. I need to print out the indexes of those pairs rather than number itself. I have written an algorithm which does work but I am wondering is it the best solution or is there any bett...
stackexchange/codereview
I have implemented this compile time map as a way of learning templates and constexpr classes: template<class K, class V> class Element { public: const K key; const V value; constexpr Element(const K& key, const V& value) : key(key), value(value) {}; }; template<class K, class V> constexpr Element<K, V> El(...
stackexchange/codereview
Back in my calculator post, janos suggested I either find a better way to read a double from a StreamReader or else go the whole way and build a double from scratch. I looked through a few streams, but the only one I found that supported reading a double was the BinaryReader. This, unfortunately, reads exactly 8 byte...
stackexchange/codereview
Using .net 3.5, implementation of the repository pattern along with enterprise library 5 and stored procedures. Did not use EF, stored procedures already available and VS2008 is limited to EF 3/4. Looking at the following code, what are your recommendations for each section: Domain/Repositories/IRepository.cs public in...
stackexchange/codereview
I used to use the MemoryCache in .Net but recently read about a DB using using a linked-list, which only had to check the prefix of the list in \$O(1)\$ complexity, to time values out, as opposed to ln N; the heap-based approach that's default for variable timeout, min-heaps. I'd appreciate a review of this code; in t...
stackexchange/codereview
A dataframe and a right-sided formula are given: dat <- data.frame( A = c("a", "b", "c"), B = c("x", "y", "z"), NotUsed = c(1, 2, 3) ) frml <- ~ A + B + A:B From them, I want to get this list: # [[1]] # [1] a b c # Levels: a b c # # [[2]] # [1] x y z # Levels: x y z # # [[3]] # [1] a:x b:y c:z # Levels: a:x b...
stackexchange/codereview
I have a javascript function written which I think is horrible for multiple reasons (which I have tried to mention in the comments in code below). I want to give it a rewrite following some best practises in general. I am trying to solve following two problems. Do I need to include multiple try-catch statements in th...
stackexchange/codereview
This function generates a unique id for my files, which will be stored in the database to reference them. It returns the id if unique, if not, it generates a new one. My separate file server can then use these ids to locate and retrieve a file. I'm planning on storing thousands upon maybe millions of files uploaded by ...
stackexchange/codereview
I am extremely new to programming, and I am a really fast learner if I am interested, I have only started using PowerShell in less than a month, to improve my programming skill, this is a script I have written a few days ago, to do what I said in title, I developped it all by myself, completely without help(because whe...
stackexchange/codereview
After my first exercise here is another. Again, this is exactly that: Exercise, which means that the output doesn't necessarily need to be beautifully formatted, etc. I probably have some variable naming issues around and also more general issues. # coding=utf-8 """Basic usage: $ python xggt.py 3343 77 (1, -12, 521) 6...
stackexchange/codereview
The code should be relatively self-explanatory. I was wondering how much rep the Top Voters on sites did "generate" on a site, in comparison to how much rep they "own". Therefore I created a little SEDE-Query and I am now wondering, if I follow good SQL-Practices and how the performance of the query could possibly be i...
stackexchange/codereview
I'm completely new to Javascript and NodeJs and functional programming in general. The code below scrapes a torrent-website containing movies, gets info about the movie from the OMDb API and lets a user choose a movie to watch by streaming the torrent. Any feedback appreciated. var scraperhelper = require('./scraperhel...
stackexchange/codereview
I've made a mock version of Silverlight in D2. It is meant to output HTML, but since I don't know HTML yet, its current output is in. HTML is not the reason I'm here, though. The goal of my project was to create a framework that uses XAML and MVVM to create a site bound to a viewmodel. It doesn't do too much and isn't ...
stackexchange/codereview
I have written the following implementation of the Caesar cipher for an old Linux computer with a Pentium MMX chip. The code has been written with the following design goals in mind: the code should perform well to avoid timing side-channel attacks, the runtime should be independent of the data used the code should r...
stackexchange/codereview
Is there any easier/shorter/better way to do the marked part? plnkr <body ng-app=""> Apple <input type="checkbox" ng-model="apple" aria-label="Toggle ngHide"><br/> Banana <input type="checkbox" ng-model="banana" aria-label="Toggle ngHide"><br/> <div> <!-- This part--> <div ng-show="apple || banana"> You wa...
stackexchange/codereview
This code simply returns a small section of HTML code and then gets rid of all tags except for break tags. It seems inefficient because you cannot search and replace with a beautiful soup object as you can with a Python string, so I was forced to switch it back and forth from a beautiful soup object to a string several...
stackexchange/codereview
This font manager is part of a game engine. It's supposed to mostly load fonts at the start, so I'm more worried about reading performance than loading performance. If there's any way of improving loading performance as well I'm happy to hear it. How would I optimize this font manager or managers in general, and what ...
stackexchange/codereview
class Names: def __init__(self,name): self.name = name self.numname = name for letter in name: self.numname = re.sub(letter, rosetta[letter] + ",", self.numname) self.numname = self.numname.split(',')[:-1] Essentially what this does is creates an attribute for the object...
stackexchange/codereview
I have working code here which takes two lists and turns them into a dictionary with the first list being the keys and the second being the values. If the keys exceed the values the value "None" will be assigned to that key. def createDict(keys, values): i = 0 dictionary = {} # go through all the values in...
stackexchange/codereview
I have a C++ project which needs a few periodic timers. I have created a timer class for this project using Grand Central Dispatch. I tried using boost::asio, but for some company policy reasons, I cannot link with said library. Here's the header file with the interface: // // PeriodicTimer.hpp // #pragma once #in...
stackexchange/codereview
Calculator class: class Calculator { /** * @return array */ function doPowTable ($n) { $table = array(); for ($i = 1; $i <= $n; $i++) { $table[] = array( 'i' => $i, 'factor' => pow($i, 2) ); } return $t...
stackexchange/codereview
I am using play framework with scala and here is a scenario on which I would like to have your opinion. Let's say I have 2 custom exceptions that I can throw, which are EmailTaken and AuthFail. What I need to do here is, whenever any of these 2 exceptions happen, I need to return a json with 3 keys success, errorCode a...
stackexchange/codereview
In my program, I have a tree of Group nodes, each identified by their ImportId. Each group has zero or more members, that I want to collect. Each group has zero or more child groups, referenced by their importId, whose members should be added to the collection. Each group has zero or more RuleParts. Each rulePart is a ...
stackexchange/codereview
Im looking to improve my search algorithm in my battleship game. Code is not perfect but would appreciate any suggestions or recommendations. Running the simulation using a 100x100 grid (10,000 possible locations) Im averaging ~30% accuracy. Games played 500 Average = 0.31108 Im using a forward and backwards diagon...
stackexchange/codereview
The project I've working on is designed with the intent of being able to quickly and efficiently identify discrepancies in live sports betting data that comes from web API's in json format. The first step is to retrieve the json's and I have incorporated async for that. Each json is structured differently so it gets pa...
stackexchange/codereview
I have made an attempt to write the Mastermind game, to improve my basics in C++. I would like my code reviewed, emphasising on design, readability and structure of the program. The secret code is stored as a string of 4 character/PEGS and input is taken as: RRGY for red red green yellow. #define RED "\x1b[31;1m" #def...
stackexchange/codereview
I am self-teaching Python. I wrote a simple and extendable version of Tic-Tac-Toe. As far as I know, I did some immature handling with too many function parameters and multiple creation of list. Please let me know your thoughts on this implementation and how to make it better? def create_board(board_size,to_index=Fals...
stackexchange/codereview
I have finally finished creating my first real project. It's just a simple music player that can provides the user with the latest music from any site (as long as it contains MP3 files) he provides in the settings file. It can play it, download it and has an simple settings file from which the user can: add/change si...
stackexchange/codereview
I begun to work for a company which do not have enough time to practice code review. As a beginner programmer I would like to improve my skills on real working cases. I have been asked to facilitate translations on "tableau workbook" files (those are just XML files) by replacing french text with English one. I work in...
stackexchange/codereview
This is a part of my Minesweeper analyzer code that didn't fit into the last question. This code uses FieldGroup which extends ArrayList because I am using some more data than just the elements themselves. I am mostly wondering: Can any simplifications be made in the split method? Even though the current code is fast e...
stackexchange/codereview
I have a group of four inputs, the first three are required, the fourth is optional. $fieldA $fieldB $fieldC $fieldD #Optional So to validate the inputs, I just use this: if($fieldA === '' || $fieldB === '' || $fieldC === '') { #error } That works pretty well, except there is a special case: If all four inputs ar...
stackexchange/codereview
I made myself a smallish template for practice writing some characters, see below. The objective for me was to have an easy way to enter a couple of characters, set the parameters (how many pre-drawn characters, how many columns, etc.) and then get a print-ready PDF. It's written against TikZ and LuaLaTeX (I'm not su...
stackexchange/codereview
Would the following be considered idiomatic Go code? My main concerns are: The use of maps for this purpose. I basically want the data structure to be completely dynamic in size and have easy access to elements by id. This is because I will want to retrieve specific items on demand lots of times, so I don't want to ...
stackexchange/codereview
I'm developing a screen recording application using java. I've modified code from https://dzone.com/articles/screen-record-play-using-java where all the external jars required for this application are available. If I lower captureInterval to 25 then the application runs out of memory - i.e. it throws a java.lang.OutOfM...
stackexchange/codereview
I have a legacy winForms application that now I'm in charge of maintaining and developing. This app has a lot of singleton instance.... Some are very similar to service that wrap other component or class other instead wrap some entities to making a cache-like pattern This is an example of this cached class public class...
stackexchange/codereview
Last night in The 2nd Monitor there was a discussion about postless users - I wanted to see how many there are, whether they're one-timers that showed up once, registered and never came back, and whether they vote at all. So I whipped up this query on SEDE, showing voters and their post count, as well as other informat...
stackexchange/codereview
This class seems to be able to represent the data stored in any possible database table: public class DbTable { private Set<Map<String, Object>> tblData = new HashSet<Map<String, Object>>(); public DbTable(Connection dbConn, String tblName) throws Exception { PreparedStatement prpStmt = dbConn.prepare...
stackexchange/codereview
I would like comments on my implementation of a stack: template <class T> class Stack { public: void pop(T& element); void push(const T& element); Stack(); private: int elementCount_; int stackTop_; static const int MAX_ELEMS = 10; T elementArray_[MAX_ELEMS]; }; template <c...
stackexchange/codereview
This code works well, but it's too long and looks too bad. I've tried to format it, but it all sets data, so I don't know how to make it better. Here is the class: private static BrandProfitAndLoss getAllRateComparisonRecords(BrandProfitAndLoss brandProfitAndLoss , BrandProfitAndLoss brandProfitAndLossComp){ BrandP...
stackexchange/codereview
Given an input string, reverse the string word by word. For example: Given s = "the sky is blue", return "blue is sky the". What constitutes a word? A sequence of non-space characters constitutes a word. Could the input string contain leading or trailing spaces? Yes. However, your reversed string should not contain...
stackexchange/codereview
I am working on a KNN implementation for sparse datasets (that I apply to text analysis). My points are represented by a Dictionary<string, double>, each key represents a word of the text and the value, its count or TFIDF. I am using index inversion to reduce the number of distances to evaluate. However, evaluating th...
stackexchange/codereview
I wrote a script in Ruby for a better family budget overview. The expenses are hold under a CSV file. Any feedback is welcomed! require "csv" FILE_DB = Dir.home << "/expenses2017.csv" CATHEGORIES = %w[ Baby Food Car Travel Books Poker Programming Rent OtherBills Beauty ] MONTHS = %w[ Jan Feb Mar Apr May Jun Jul Aug Se...
stackexchange/codereview
I have a usecase where I want to prevent unexpected duplicate Http calls. I'm wondering if I can have a custom operator which can be used in pipe for any API as shown in below example 1. Even better if I can use this operator in Angular's HTTP_INTERCEPTOR as shown in example 2. Code for customer operator class RxJsUtil...
stackexchange/codereview
I built a method using reduce of JS to aggregate together data from a DB in a better shape. What I'm wondering is, if that method can be simplified with a more modern approach or better written. Like using a different method instead of a reduce. The method takes the dbData which includes data in the following form: con...
stackexchange/codereview
Isn't there a better way to create my constants that I can use elsewhere in my code ? export default class AppConstants { } Object.defineProperty(AppConstants, 'APP_NAME', { value: 'iVoc'}) /* *... *Other constants */
stackexchange/codereview
I've written a simple JavaScript function based off some existing code that takes a specific UNIX time string (in the snippet: 1491685200). It shows an alert if the specified time is still in the future. When that date has passed, it shows the elapsed days, hours and minutes whenever the function is called in-page. I...
stackexchange/codereview
I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on best practices used here, which would be much appreciated. The idea is to have a central Database class and separate classes...
stackexchange/codereview
I have <button>s that when pressed expand or collapse the contents of all the <details> within the document. The code works, but as a novice in JavaScript, I am not very confident in its performance and/or efficiency. Could you please review it. expandDetBtn = document.getElementById("showBtn"); collapseDetBtn = docu...
stackexchange/codereview
I want to perform statistical analysis and index subtitles that are stored in the WebVTT (Web Video Text Tracks) format. Before I can do that I need to remove duplicated text since each cue can contain text from previous cues. This duplication is a side effect of making the subtitled words appear closer to when they ar...
stackexchange/codereview
I'd like to know what's the most efficient and correct way to do the following: We're given a list of objects. Here's an exampler object: public class Search { public string ColumnName {get; set;} public string Value {get; set;} } One of the object's properties can hold only two "types" of string values: A do...
stackexchange/codereview
Tic-Tac-Toe from scratch. Code Ugliness check before I implement the win-condition and maybe get set in to bad habits. Questions: As implemented: Better to pass board between functions or set as a global variable? OK to use same variable name within different functions? OOP: Would you recommend using Object Orientated ...
stackexchange/codereview
I've written two classes that I use to create and manage a high score list. I plan to use this code for my own, larger project. I would like to ask if there is something to complain about my code. Were the language tools and the libraries of the language used meaningfully? Does my implementation meet the requirements o...
stackexchange/codereview
class Pool(type): pool = dict() def __new__(clas, *a, **k): def __del__(self): Pool.pool[self.__class__] = Pool.pool.get(self.__class__, []) + [self] a[-1]['__del__'] = __del__ return type.__new__(clas, *a, **k) def __call__(clas, *a, **k): if Pool.pool.get(clas)...
stackexchange/codereview
I have programmed a simple command line password-manager in Node.js during my learning process, and since I am done with it, I would highly appreciate a review. Comments could be based on any topic. I am looking for a review which covers: Security flaws. Performance and Efficiency. Better ways to achieve this. Violat...
stackexchange/codereview
This below program will be further enhanced for TicTacToe game with Human and Computer as players. Currently this program is written for choosing best move for a given grid position. package project2.tictactoe; enum TicTacToe{ X, O, NULL; @Override public String toString(){ switch(this){ ...
stackexchange/codereview