instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I am fairly new to JS and I am trying to implement a sort of schedule in my website. I have a schedule of speakers and they change every half hour. I would like to display the name of the speaker at the time that they are speaking. At the moment I have everything working; however, I know I probably did it the most inef...
stackexchange/codereview
First I'm not sure what this is called formally but whatever. Basically I need to form "wildcard buckets". I think the best way to explain what I need to do is to take an example. For instance, say I have the three words "aaa", "aab", and "baa". Let me use * as the wildcard. Then from aaa I can form -aa, a-a, aa-, --a,...
stackexchange/codereview
I'm stuck with the slow VBA routine below, which I think is the cause of lagging (taking to long). I was wondering if there is a faster way to do this: With Sheets("Groups") .Cells(1, 1).Value = "Groups" .Cells(1, 2).Value = "Aantal" .Cells(2, 1).Value = "9N4" .Cells(2, 2).Value = n9N4 .Cells(3, 1)....
stackexchange/codereview
I just finished writing the core for my WPF application and because I'm still a very beginner at software design I wanted to get some feedback about the design decisions I've made. I've uploaded the project to Github and I'll post the most important parts here (the project is to big to be posted as a whole). To see t...
stackexchange/codereview
This first stores a string as input, loops through it to extract all of the numbers into an ArrayList, then prints all of these numbers along with their sum and product. How would I decompose this Java program into multiple methods? public class Assignment1 { public static void main(String[] args){ // Cre...
stackexchange/codereview
Tracks the number of calories a person consumes in a given meal it has helper method to get the day's total. The check method Tries to find any duplicate meals within the given list. The assumption is that a day can only contain one of each type of meal. public class Meal { public enum Type { BREAKFAST, ...
stackexchange/codereview
I'm a zeromq newb and have implemented the REQ/RES Lazy Pirate pattern with C#. It's essentially a port from the C example given in the documentation. It's harnessed by tests, and seems to be work to my expectations. I'm interested to know if I'm understanding the pattern correctly, or if I can improve the API. If anyo...
stackexchange/codereview
Working on identifying duplicate vendor payments using SQL in MS Access. The business logic uses four column; Vendor #, Invoice #, Invoice Date and Invoice Amount. There are 5 core reviews, if all are the Exact matches (EEEE) or if at least one field is different (DEEE,EDEE,EEDE,EEED). I have it working for all 5, howe...
stackexchange/codereview
I'd like a code review on my very simple server application that validates whether the serial number retrieved from the client is a valid one or not. Is there a better way to handle the start/stop on the service? If you look at my Start and Service methods, I'm basically looking at isServerRunning boolean variable an...
stackexchange/codereview
This is a program which computes the circumference of two circles and gives some information such as the difference between circumferences. I want to know whether the method declarations and method calling in my code is correct. I didn't face any errors. import java.text.*; import javax.swing.*; class Q5Main{ pub...
stackexchange/codereview
Currently this is the store procedure I am working on, it is working according to some testing that was done. I feel that it could be improved though, could use some optimization, feedback or recommendations. What is it supposed to do? For given policy id passed in, grab all coverages associated with the policy. For ...
stackexchange/codereview
On a whim, I came up with this program to act as a helper class for base changing, if I require it in the future. It was made to support fixed-point and negative inputs, but they are basically a hack. I used conventional mathematics for the algorithm, and I welcome any appreciation or criticism that may come my way. No...
stackexchange/codereview
input 3,5 output should be 3,4,5 input 5,3 output should be 5,4,3 And the code public static void test(int a, int b) { if(a>b) { for (int i = a; i >= b; i--) { System.out.print(i + "\t"); } }else if(a<b) { for (int i = a; i <= b; i++) { ...
stackexchange/codereview
I have come up with this code to do level order traversal recursively for a binary search tree. private void printLevelOrder_Recursive(Node root2) { Queue<Node> queue = new LinkedList<Node>(); queue.add(root2); Stack<Node> stack = new Stack<Node>(); stack.add(root2); if(stack.isEmpty() == false) {...
stackexchange/codereview
Following the book "Structure and interpretation of computer programs" I have tried to implement a functional solution to the problem of N-queens (implemented by the function nQueens). However, I am not satisfied by the reliance on for loops and the general readability of the code. Could I get your opinion the code? im...
stackexchange/codereview
Since today is apparently a good day for...unlikely FizzBuzz implementations, I decided to contribute another, this one in C++: #include <iostream> #include <functional> #include <vector> #include "xrange.h" int main() { std::vector<std::function<void(int)> > funcs { [](int i) { std::cout << i << "\n"; }, ...
stackexchange/codereview
I'm try to create array of strings from a text file. I need a review from experienced programmers about my program. (MinGW gcc, Win7) #include <stdio.h> #include <string.h> #include <stdlib.h> main() { FILE *file; char *fname = "lines.txt"; file = fopen(fname, "r"); if(file == NULL) printf("Can't read %s", fname...
stackexchange/codereview
Is there a more graceful way to structure the code below? The fingerPosition values are increments of 1. The fingerMask values start at 1, then 2 and then increment in multiples of 2. private int getFingerMask(int fingerPosition) { int fingerMask = 0; if (fingerPosition == 0) { ...
stackexchange/codereview
Need to parse MongoDB collection and save parsed data into different postgres tables. MongoDB stores documents with different type field, for each type need to write handler to parse the document of this type. I wrote Service class but it is overcomplicated. I see this troubles: Bad decomposition A lot of DAO classes ...
stackexchange/codereview
I'm working on a Swift app for macOS, where I take input from MIDI devices and transform that input. The MIDI devices being supported come in for flavors. What my code does is scan for MIDI devices, filter all the MIDI devices to only leave the ones I want, initiates classes on them and puts them in a array. However, w...
stackexchange/codereview
Out of the majority of my c++ projects, the most used thing is std::vector because it allows me to not have to my own memory management. However previously I had never really thought much about how std::vector works internally. Until recently and that's when I decided that to better understand std::vector I should atte...
stackexchange/codereview
I would like to define some constant sequences (of bytes, specifically) in my C# library/API. Both length and content should not vary, preferably by any means (barring reflection). To this end, a byte[] array would not be sufficient, and a ReadOnlyCollection<T> can still be mutated. I have not done a full comparison ye...
stackexchange/codereview
I know my question sounds strange but I have a situation in which I have Parent Data which can have 'N' Childs and each child can further have N-Childs and so on. So its Like. Parent a. Child i. Child ii. Child b. Child i.Child I hope I've made myself Clear. So here is a snapshot of the Database Table:...
stackexchange/codereview
This is an experiment to investigate how to wire up binding and inheritance in a composable, custom control complex. Custom Control Structure There is a custom parent (TestParent) with multiple custom child controls plugged into a ObservableCollection, DP on the parent. The Parent derives from Label and the children f...
stackexchange/codereview
I have written an attendance calculator that compares a set of rules against an employee's attendance record and determines what level of progressive discipline that employee is at (how much trouble they are in). Information: The rules are provided as a JSON object whose information comes from inputs on the page The ...
stackexchange/codereview
I have a class that is testing to see which enzyme-filled blood a person in need of blood should get. My code works, but it is so big for the small thing that it's doing, and it looks very bad and in need of condensing. import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Random...
stackexchange/codereview
I'm very new to python (been coding for about two days) and have created a programme that simulates blackjack games so that I can work out optimal strategy over many iterations. The problem is that when I run it, my CPU goes to about 99.8% and it freezes (I run in terminal) - Does anybody have any suggestions on how I ...
stackexchange/codereview
I'm using Q to flatten out some callbacks in my unit tests and return a promise to mocha (which knows to wait until the promise is resolved before running the next test). Originally I had this code: it ('resetCount should cause the count to reset as if there were no documents yet.', function () { // Now save user a...
stackexchange/codereview
About / Background This is indirectly a follow up from: General Game Loop 3.0, if you prefer to test against it, feel free to. That code is very outdated now though. A test suite is given at the end. For the actual class to direct feedback against: MyText.java, a short description of it follows beneath, as well as a te...
stackexchange/codereview
TL;DR: The algorithm receives a string as input, allocate another string to be the final digest, and start working on them. For each char on the digest (a null character on a first moment), it XORs it with every character from the original string, also XORing it with a set of "random bytes" that are specified in the be...
stackexchange/codereview
Can you help me to review my "mailto:"-parsing function ? Since I'm trying to write less code, that is as simple as possible. I'm not sure there if there is some bug or better solution. var href = 'mailto:hello@world.com?subject=My+Subject&body=My+Body'; function getMailto(s) { var r = {}; var email = s.match(...
stackexchange/codereview
I have a library which is being used by customers and they are passing DataRequest object which has userid, various timeouts and some other fields in it. Now I use this DataRequest object to create a URL, then make an HTTP call using Apache HttpClient for which my service returns a JSON response which I use to create a...
stackexchange/codereview
I am working on below python copy utility that should work on windows & linux, But I am looking for a more efficient approach that could optimize my I/O correction, as my target location is network dependent as well... I have computed the utility execution time factor in the code. #!/usr/bin/python """ Pythonic implem...
stackexchange/codereview
Background: Recently, I've been working through Coroutining Folds with Hyperfunctions. Don't bail out now if the whole thing makes little sense - it's just the motivation for the existence of my code, not what I actually want reviewed. I followed a rather typical approach of starting with the data structures and types ...
stackexchange/codereview
What would be the most efficient way to write the following code in Perl: my $index = 0; foreach ( @spec ) { if ( $module =~ m/$_/ ) { splice(@spec, $index, 0, $module); last; } $index++; } This works fine but just seems a little wordy. ...
stackexchange/codereview
I created this class which supposed to take a method and try to execute it. If it fails lets say 10 times, it will throw the original exception thrown by the delegate. Do you have any ideas for improvement about that code? I am particularly interested, in where to put this code. Right now it is within a FileHandler ass...
stackexchange/codereview
I am solving the following Hackerrank problem: Climbing the Leaderboard. The problem statement: Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking. The game uses Dense Ranking, so its leaderboard works like this: The player with the highest score is ranked n...
stackexchange/codereview
I was asked to make a String encryption utility without using encryption API. I basically had to come up with my own encryption methodology! the program was to be able to encrypt a string and decrypt a string and to of course make it nearly impossible for anyone to figure out what the encrypted string says! I would rea...
stackexchange/codereview
I have a very basic "game" where a robot is placed on a small 5x5 board, and commands are given to it. To start, the robot must be placed on the board, then you may command it to move, or rotate left and right. I have tried to use object oriented concepts, but it was not a requirement for my task. I think I have done a...
stackexchange/codereview
The working hours are saved in Database like {"1" : "11:00 - 14:30", "2" : "17:30 - 23:00"} Now i wrote a function like, which test is the shop is opened or close at the moment. Can someone please suggest if there is a better way to do this? And how i can check if the timing are like {"1" : "11:00 - 14:30", "2" : "17:...
stackexchange/codereview
I am working on a personal project for managing one's Pinboard bookmarks. Since this is already quite a big project, I am not sure if my question fits the guidelines. My main concern is with the complexity of one of my controllers. I have the feeling I should cut it into smaller controllers or directives, but I am not ...
stackexchange/codereview
One of my professional software I use everyday provides analysis results in *.csv format from which I need to extract data. I have written a script that first converts from text to columns, and then takes out the data I need rearranging it the way I want. My problem is that it is not very fast while I will need to use ...
stackexchange/codereview
there is a video on life at google about what an interview would be like and so i watched it and decided to go along and come up with a solution to the problem myself and i found it really easy this is the solution i came up with the question is to make a program to find 2 numbers in an array that add up to a sum retur...
stackexchange/codereview
I like the fact that I can create a class and have the connection details in one file if I need to update them and then pass them to the method I create in the class that defines my specific use of mysqli. I was thinking also that I may give an option to pass the connection details if I need to use a different db in on...
stackexchange/codereview
I am getting Out of Memory errors when I try to parse through a large CSV file (2.5Gb). My computer has 32Gb of Memory but Perl uses all of it up. The CSV has 2 columns. The first is the time in epoch and the second is a 10000+ line XML file as a single-line. There are around 13k rows. I then use XML::XPath to retriev...
stackexchange/codereview
The code below is an implementation of the Best First Search algorithm for navigation of the shortest path across a 2D NxN matrix. As a heuristic for the search I use the standard distance formula. The matrix is generated from a text file passed in as a command line argument,where the first line is the size N of and ea...
stackexchange/codereview
I was redirected from StackOverflow to your community in hope to get some help and improve my script. The script receives letters as input and generates possible words, then extracts readable words from comparing my list items with file containing English words. For example when I enter as input : eys this will generat...
stackexchange/codereview
I was curious how vectorization works and how to write suck code. To start simple I choose 7-bit encoding as my test suspect. I'm not expecting improved throughput in any way. My implementation works just fine, until we go over 2^31 due to compare not doing unsigned comparison. I would like to know how this could be ta...
stackexchange/codereview
I'm a beginner Python (2.7) programmer, and I've just started solving basic problems on SPOJ. I correctly solved the ADDREV problem (http://www.spoj.com/problems/ADDREV/), however my code takes 0.06s time and 8.8M memory to run. The top Python 2.7 rankers for the problem take <0.005s and 4.00M. Since I am starting out ...
stackexchange/codereview
Here is qsort implementation using iterators as it is in std::sort // iterator check template <typename It, typename T> constexpr bool is = std::is_same<std::iterator_traits<It>::iterator_category, T>::value; // quick sort template <typename BidIt, typename Pred> void qsort(BidIt first, BidIt last, Pred compare) noex...
stackexchange/codereview
Task is to encrypt part of the file using aes encryption algorithm. I did public static byte[] AES_(int len, byte[] passwordBytes, byte[] saltBytes, FileStream fSin) { byte[] encryptedBytes = null; byte[] encryptedBytesAndIV = null; using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { ...
stackexchange/codereview
I'm looking for feedback on my atoi implementation here in C. Any feedback would great. I made my own atoi for fun and to learn about it. I'm not trying to replace the standard library version. Reinventing the wheel is fun to me. #include <limits.h> /* for LONG_MAX, INT_MAX */ #include <stdbool.h> #include <stdio.h> #...
stackexchange/codereview
Since I have just started Javascript, I am trying to solve a few problems and improve myself. I encountered such a question. I tried to do everything step by step from the question, but I do not think that my code is efficient. Can someone help me develop it? Please code for a JavaScript function that accepts two argu...
stackexchange/codereview
I wrote this class to make it reusable in any project. It uses PDO as the MySQL connection. Beside not using Setters and Getters, is this code secure and good practice for CRUD? class ContactsRow { const PDO_CHARSET = PDO_CHARSET; const PDO_DBNAME = PDO_DBNAME; const PDO_DRIVER = PDO_DRIVER; const PDO_HOSTNAME = PDO_HO...
stackexchange/codereview
I need to send and receive data. Here is solution for my original problem. I want to know how safe my finished code is and how I can improve it. int sslWrite(SSL *ssl, const std::string &data) { return sslWrite(ssl, &data[0], data.size()); } int sslWrite(SSL *ssl, const void *buf, unsigned num) { const int IN...
stackexchange/codereview
Please look at the Java Stream methods in the for each loop. This method totals the score for when the your desired team is playing during the football season - input param teamKey - it is either team1 or team2 I extract score1 or score2, which I total from the Json. The Season object contains, collections of collectio...
stackexchange/codereview
I wrote a program to find the longest common subsequence among several strings. I used a naive algorithm and implementation. The motivation was solving the Rosalind problem at http://rosalind.info/problems/lcs/ . You can find sample input there as well. The Rosalind problem concerns strings as DNA, but I think my code ...
stackexchange/codereview
The problem of finding the first all zero row in a NxN matrix was featured in a letter to the CACM in 1974 by Frank Rubin who claimed it was a problem for which using a GOTO was better than alternatives. But many languages have labeled break statements and other features that make the problem trivial. In fact, in JavaS...
stackexchange/codereview
I've got this method and I realize that an instance of HttpClass is going to be created for each call to it. While working seemingly OK, I'm considering moving it out and placing it as a private property accessible to each call to the method. There might be other methods making use of it in the future as well. I have n...
stackexchange/codereview
How to make insertJson faster (I should keep the script compatible with old versions of IE and other browsers)? Problem innerHTML of this section tag: <section id="two"></section> is created by loading json.txt to window[p]: // Gets a tree structure JSON: getJsonTxt({p:'dir/dir/json.txt'}); Then, it adds the generat...
stackexchange/codereview
We are given a vector of std::pair<int, int>s, start int and stop int, and I need to extract the path out of it. For instance: given start = 2, stop = 8 and list of std::pairs as [(0, 5) (6,8), (5,6), (2,0)]. I am ordering the vector into: [(2,0), (0,5), (5,6), (6,8)]. Now I need to isolate the nodes to get the path a...
stackexchange/codereview
I have a form that I have broken into several different components in Angular. By the end of the form, all the data needs to be submitted together. My thought process was to create a provider to handle/save the form data and at the end of the form, use the provider to package it up so it can be sent to an API. I have ...
stackexchange/codereview
Hi I was just asked by stackoverflow to move this question into this forum (https://stackoverflow.com/questions/67685433/how-to-design-the-react-component-properly). Hi I am pretty new to react and I want to achieve something that turns out to be real pain for me and I am not sure what the best solution might be. I got...
stackexchange/codereview
I decided that I wanted to add some spice to my bland looking city maps, so I created a couple of algorithms to add water to the map. I also added a "marshlands" setting that would just randomly sprinkle water throughout the map. Here is an example of the river generation: Here is the world generation method in its en...
stackexchange/codereview
This is my implementation of "merge sort" in C++. I'm still a newbie at C++ so: Have I understood how merge sort works and implemented it in the right way? Have I used any bad practices? How could the code be improved upon in terms of efficiency? Criticism is welcome and appreciated! #include <iostream> #include <vec...
stackexchange/codereview
After searching a lot, on how to do it and not finding any good solutions, I implemented my own UDP livestream from an Android device to a C#/WPF desktop application. It works, however, since I get complete JPEG images from the camera2 API each frame in android, I need to wait until I have data for the complete image b...
stackexchange/codereview
I need help to simplify this code about implicit date calculation. The context: I have sentences with implicit and explicit dates. For instance: "From the 5th to the 7th of September 2017, the 12th, 13th and 15th of June, from the 25th to the 31th December, the 1st and the 2nd of January 2019." A program (not shown h...
stackexchange/codereview
My needs outpace my abilities. This code (mostly) works, but it is really ugly, doesn't always add correctly, and is in desperate need of some help refactoring. I can't wrap my head around what needs done with it. I have a SQLite table WorkLog which contains rows of int, long, long, long, and long. They are _id, unu...
stackexchange/codereview
I have built a basic shopping cart simulator. All it does is add and remove items between two different basket (i.e. aisle vs basket). While working on the problem I started to think about the approach and would love to hear what people think. Avoid initializing the state empty state in the constructor. However, I had...
stackexchange/codereview
I wrote a country name generator in Python 3.5. My goal was to get randomized names that would look as much like real-world names as possible. Each name needed to have a noun and an adjective form (e.g., Italy and Italian). I started with a list of real countries, regions, and cities, which I stored in a text file. The...
stackexchange/codereview
This is a follow-up to this question, which resulted in major confusion on my side regarding forwarding of arguments. Advice regarding that should probably be given in my question on SO. Overview The classes below implement the observer pattern for use in an embedded system. My main need is to be able to connect source...
stackexchange/codereview
I'm writing a basic tutorial for a simple console menu for Python. I think it is secure, since the input() is controlled by a dispatch. Any suggestions would be appreciated. """ Nice Menu for Python """ import time # used only for testing purposes def m_help(): """ - - - - - - - - - Micro Menu Help - help line 1...
stackexchange/codereview
I really think there's a better way to do this, but I can't seem to find it. Can you please point me in the right direction? import colorama import os from enum import Enum def clearscreen(): # Clear the screen os.system('cls' if os.name=='nt' else 'clear') class Color(Enum): """ An Enum for represent...
stackexchange/codereview
Okay... here's the beast: SELECT SUBSTRING(DischDate, 7, 4) + SUBSTRING(DischDate, 1, 2) as YYYYMM ,Type ,SubType ,Diags ,Count(*) as Count ,SUM(Charges) as Charges ,SUM(Payments) as Payments FROM ( SELECT DISTINCT ID ,Diags FROM ...
stackexchange/codereview
I have a database column with dates corresponding to sales orders. I get the count of orders in each month. Currently in my code, I use a switch statement. I know it is not a neat way of coding. So I need to know if there is any way I can do it more precisely. I need the output in such a way as below to form a chart in...
stackexchange/codereview
I am able to save my GridView layout by storing a string representation of the items in the ItemsSource. I then load that string representation from the SettingsService and set the index of the items accordingly. The layout is changed by drag/dropping items in the GridView. Here is the code-behind: private void MainGri...
stackexchange/codereview
I know there are a few recursive ways to solve this problem but the code below is what came to mind for me. void create_bst(node *root, vector<int> arr) { int len = arr.size(); add_nodes(root,len-1); //Make the tree structure inorder_traversal(root,arr); } void add_nodes(node *n, int len) { queue<node *...
stackexchange/codereview
An assignment this past semester was to write functions such that the following C program would run: int main() { int board[BOARD_SIZE_HORIZ][BOARD_SIZE_VERT] = { {0} }; int player_num, computer_num; int last_move; /* Ask Alice if she wants to go first */ player_num = print_welcome(); if (player_nu...
stackexchange/codereview
Dynamic Type - [ int, char, bool, ... => dtype ] Dynamic Type in C, A project that I had been thinking of for a while and made it. How it works ? Dtype currently is same as char, when doing dtype var[size]; size bytes are reserved for var as normal char would do. The actual working of dtype is that it stores the type o...
stackexchange/codereview
The script uses a financial indicator called moving averages and their crossover points to recommend best actions for stock trading (buy vs sell). starting_cash: initial cash position prices: list of prices (ordered by time) crossovers: list of crossover points on the prices, crossovers[i] is a list [time_index, buy_i...
stackexchange/codereview
I've been refactoring code today, try to implement a clean code setup using repositories. Is this on track? Can any improvements be made? public class IndexModel : PageModel { private readonly MembershipFormRepository _membershipFormRepository; private readonly IMembershipFormViewModelService _membershipFormVie...
stackexchange/codereview
consecutive_find() is a function that returns the beginning of a range that contains strictly N consecutive elements. It was part of a SO question that I answered. Currently this function runs in \$O(n)\$ time. I wanted to know if there are any pitfalls with this function and if it can be improved at all. For example, ...
stackexchange/codereview
The nested JSON file contains names of US states and corresponding cities. City.json [ { "header": "Michigan ", "id": "MI", "PlaceList": [ { "title": "Detroit", "slug": "detroit" }, { "title": "Lansing ", "slug": "lansing" } ...
stackexchange/codereview
I'm new here. I'm trying to teach myself programming by learning Python. I have assigned myself the following task. There's a game I'm playing (Rocket Valley Tycoon) where the goal is to basically place an Extractor to gather resources, then use Factories to transform the resource into a good, which then usually gets p...
stackexchange/codereview
Given an array start from the first element and reach the last by jumping. The jump length can be at most the value at the current position in the array. Optimum result is when u reach the goal in minimum number of jumps. For example: Given array A = {2,3,1,1,4} possible ways to reach the end (index list) i) ...
stackexchange/codereview
I'm very new to haskell (I never used Monads, Functors and other things) and FP in general. I decided to write the simplest parser I possibly can with some expansion possibilities. (I have a general interest in programming languages, so this is why I chose to do this...). I have a simple parser type: type Parser a = St...
stackexchange/codereview
I'm still rather new to Go and I wanted to convert a part of a Python script I wrote a while ago to perform the VPN initialization dance (basically a set of API calls + parsing to fetch an auth cookie which will be then passed to open-connect application via a spawn) The script below works, but I feel it's overly redun...
stackexchange/codereview
ACM ICPC Team You are given a list of \$N\$ people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of topics a 2-person team can know. And also find out how many teams can know that maximum number of topics. Note: Suppose a, ...
stackexchange/codereview
I need to write recursive static method with given 3 parameters the method will return true if the sub matrix with the size of (int size) which the left corner is mat[x][x] is the identity matrix picture for example: It was part of my exam and I barely got any points,this is what i wrote: public static boolean isIdent...
stackexchange/codereview
I created simple quicksort algorithm using iterators. I'm happy with implementation but not with its speed. Profiler tells me that the slowest operation here is std::iter_swap. I don't really know how to improve this code. Note that I am not asking for different kind of quicksort algorithm but about improving this one....
stackexchange/codereview
I write decorators a lot in my work. Sometimes you need to write "decorator that takes arguments", it usually turns out to be something like this: def decorator(**kwargs): def _decorator(func): @wraps(func) def decorated(*func_args, **func_kwargs): # do something with kwargs here ...
stackexchange/codereview
I'm programming a checkers game in typescript. I'd like to explain some important details to understand how the following code works. In my game coordinates are a string, like "b4". I want to get the neighbors of a piece coordinates, but only the neighbors that make sense depending on the player and if the piece in the...
stackexchange/codereview
NOTE: I previously asked this question in Stack Overflow and got pointed here. I have a macro that I am trying to get running a little more quickly. The intent of the macro is to merge multiple files into one. These files contain a unique ID for each item, some descriptive information about the item, and some measureme...
stackexchange/codereview
I am trying to apply this simple macro to merge two big sized sheets (around 30000 rows each), but the process is too slow and never ends. The macro works perfectly with smaller sheets. Could you give me any advice for the optimization of my code please ? My Macro consists in an Userform : Public listChoice As String ...
stackexchange/codereview
I put together this simple query to calculate the percentage of downvotes each user is responsible for and displaying them in order of downvote percentage. It's generating the desired results, but I am uncertain about style and best practices. WITH DownVoteCount AS ( SELECT DownVoteCount = CAST(SUM(DownVotes) AS float)...
stackexchange/codereview
I'm beginner at multithreading programming and I wanna write a piece of my code using it. I'm trying to split different numbers into multiple parts and store them as a polynomial. I wanna do this using multithreading as each number being splitted in one thread, all simultaneously. For example, 5 separate threads split ...
stackexchange/codereview
Rubberduck's latest (and greatest?) feature is a regex search/replace: This is the defining interface: public interface IRegexSearchReplace { List<RegexSearchResult> Find(string pattern, RegexSearchReplaceScope scope = RegexSearchReplaceScope.CurrentFile); void Replace(string searchPattern, string replaceValue...
stackexchange/codereview
I need to observe a ConcurrentQueue, but to minimize the resources I want to pause the Thread if the Queue is empty and resume it from another Thread if there is a new Entry in the Queue. I implemented a pausing and an resuming of a thread like this: My Worker, where the DoWork() method is called in a new Thread, looks...
stackexchange/codereview
After my last review request, I decided to try and make a "tree" visualization, and thought that I could benefit from making find-prime-factors lazily produce prime factors so the visualization can be updated in real time as factors are found. This is what I ended up with. I was actually surprised how easy it was to ad...
stackexchange/codereview
I have this below code where i am sending some content over a POST and then consuming the response. I would like to know if there can be any optimizations that can be done and is there any possibility of connection leak. import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.S...
stackexchange/codereview