instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I'm trying to create a canvas project inspired by this gif where colors of an image are averaged and animated. Thus far I have all of the functionality working but it only performs well with a large cell size. My current thinking is that it's all of the .fillRects that are causing the issue because rendering is expens...
stackexchange/codereview
<div id="form-0"> <a class="remove-form-0">X</a> form 0 </div> <div id="form-1"> <a class="remove-form-1">X</a> form 1 </div> <div id="form-2"> <a class="remove-form-2">X</a> form 2 </div> <div id="form-3"> <a class="remove-form-3">X</a> form 3 </div> I would like to hide the parent div, when it clicks on the remov...
stackexchange/codereview
I need to parallelise a for loop that does quite a lot of processing over thousands of items. I came up with this basic loop that seems to work quite effectively on a small test. template<class T, class C> void parallel_for_each(std::vector<T>* ts, C callable, uint poolsize = (std::thread::hardware_concurrency()+1)*2) ...
stackexchange/codereview
Inspired by this question by t3chb0t and as an elaboration of my own answer, I have written the following solution. My goal was to reduce complexity both in implementation and use. Eventually - I have to admit - the implementation ended up being rather complex - but in my flavor; but in terms of ease of use, I think I ...
stackexchange/codereview
I began learning Haskell last week. I wrote the following to get the next lexicographic permutation of a list. It works perfectly but I feel like I'm just writing a c# method. My long list of where commands just feels like an imperative approach. I would appreciate any feedback if this solution is indeed the way mo...
stackexchange/codereview
I am designing a new application to track sports statistics with code-first migration. I have the bare minimum POCO setup. The problem is that I am not happy with the design specifically how the players, teams and tournaments are relating to each other. I appreciate any comments and suggestions. PlayerAccount class: /...
stackexchange/codereview
I've came across this question https://stackoverflow.com/questions/11760420/what-is-an-optimal-way-to-find-duplicate-files-in-c and there are two answers for it both the answers convey that it is bit difficult and other suggested C++ is not suited for this purpose so as a student I am interested to test my C++ skill on...
stackexchange/codereview
I've been working on development for an Android game, and this is the game loop I have so far: private static final int MAX_UPDATES_PER_DRAW = 10; private long timeAccumulator = 0; private long lastTime = System.nanoTime(); @Override public void onDrawFrame(GL10 unused) { // Use this structure to set constant ...
stackexchange/codereview
I'm going to be working on a much larger version of this program and I just wanted to see if there was anything I should change in my style of coding before I made anything larger. If it wasn't obvious, this code goes through each comic on A Softer World and downloads each comic. Oh and with larger projects, should I t...
stackexchange/codereview
I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The question was: In the past, Twitter had a 140 characters limitation per tweet. If you wanted to enter longer tweets, you had...
stackexchange/codereview
I am trying to count the number of ways an integer can be represented as sum of 2 or more consecutive positive integers. My Code is working in under 1 second for small inputs (\$\le 10^7\$) but after that it's taking too long. How can I lower the time complexity of the solution? import java.io.*; //sum needs to conta...
stackexchange/codereview
(Part 1 here) I've recently created my own 2-player chess game, no AI... at least for now. I do plan to do that in the future, so one of my concerns is if the code is flexible enough to just use the same classes in all the different modes so I can avoid rewriting the same code over and over again. Resuming with the o...
stackexchange/codereview
I have been tasked with converting some pseudocode to working Java code and I would like someone to review my code for correctness. The pseudocode is as follows: Algorithm MaxsubFaster(A): Input: An n-element array A of numbers, indexed from 1 to n. Output: The maximum subarray sum of array A. S0 ← 0 // the initial pre...
stackexchange/codereview
I have over 260k lines of data. This code is likely to take more than 30hrs to run. Would like help to speed this up. Or is there a way to use something else like PowerQuery to accomplish this? I am very new so please break it down clearly. There are 260k rows of student achievement data. Some students may have multip...
stackexchange/codereview
I just started to learn C++ and I decided to make a Rock Paper Scissors game. It works fine but I would like to know how can I improve it further. In particular I couldn't find an efficient way to implement a play again feature. Thanks in advance. #include <cstdlib> #include <ctime> #include <iostream> #include <strin...
stackexchange/codereview
I recently finished writing an HoloLens proof-of-concept program. It involves generating a user interface based on a connection with an OPC server. OPC involves industrial PLCs, one or more PLCs send their data to an OPC server, and the OPC-client connects and process all the information in the form of JSON. An example...
stackexchange/codereview
I'm not really sure if the following solution is the best fit, and I would like to know best practices when manipulating state and/or Ajax isomorphic fetch requests, in this case, in intervals. Users Module import { createAction, handleActions } from 'redux-actions' import { api } from '../utils/api' export const RE...
stackexchange/codereview
I've written a function that searches for the nth occurrence of a character in the given string. A positive value for n will search from left-to-right, while a negative value will search from right-to-left. Zero is not a valid value for n. Left-to-Right Search "AABAXYAMN".NthIndexOf('A', 1) -> 0 "AABAXYAMN".NthIndexOf(...
stackexchange/codereview
My goal is to create a memory-efficient (immutable) collection of strings. The imagined use-case is checking for valid words in a Scrabble-like game. Wikimedia Commons has a pretty good summary of the data structure (author: Chkno): (Image license: Creative Commons Attribution-Share Alike 3.0 Unported.) For an input o...
stackexchange/codereview
We need to select a model reference from a view. To do this we need to add a dropdownlistfor. This is based on a selectlist containing database models. passing selectlists by viewbag This solves our problem, but we do not like using ViewBag: public ActionResult Create() { ViewBag.SomeModels = new SelectList...
stackexchange/codereview
I am validating a collection of proxy servers and trying to achieve the maximum possible throughput. I've tested a few different methods, such as Task.WhenAll, TPL Dataflow, and HttpWebRequest.BeginGetResponse. From my testing I've found BeginGetResponse to be the best for my use case. However, I have 2 different imple...
stackexchange/codereview
I am very early in my journey of learning Scala, and I was doing challenges on hackerrank.com to get used to the syntax. As I finished one (very trivial) challenge, I noticed that the run times seem to be unusually slow. Thinking that it might be environment-dependent (as the code runs on the HackerRank servers), I dec...
stackexchange/codereview
To become better acquainted with the Intel Parallel Studio XE profilers I'm currently messing around with a simple concurrent freelist. I'm fairly certain that it's thread-safe. It uses Acq/Rel semantics, Tagged Pointers to avoid the ABA problem and users of the free list can't actually touch the freelist header data. ...
stackexchange/codereview
Is below code a valid Singleton design pattern for Mongodb in Java? Please suggest any improvements. public class Mongo extends MongoClient { private static Mongo mongoClient = null; private static MongoDatabase mogoDB = null; private Mongo(ServerAddress server, List<MongoCredential> mongoCredentialList) ...
stackexchange/codereview
After reading the book from which this example is from I started using APIs like this typedef struct stack { char **items; int len; } stack; stack *stack_new() { stack *out = malloc(sizeof(stack)); //initialize the struct *out = (stack) {}; return out; } void add(stack *in, char *val) { ...
stackexchange/codereview
I'm using passport to setup login in an express site. The site is just a playground for me to learn. The code inside login was exhibiting the arrow anti pattern so I decided it was time to learn to use promises. But I don't know if what I've arrived at is good, bad, idiomatic, or idiotic. Any and all feedback appreciat...
stackexchange/codereview
I have a link aimed to '/FridgeTemperatureRoute' and a checkbox. Purpose of the checkbox is to show the user whether the check has been done or not. <div class="row"> <div class="col"> <a id="FridgeTemperatureBtn" href="/FridgeTemperatureRoute">Fridge and Freezer Temperature</a> </div> <...
stackexchange/codereview
I have written this piece of JS and CSS loading code and I would like some advice on it. Anything some of the JavaScript gurus could possibly point out would be much appreciated. The code works, but I have not done extensive testing, because I am concerned about replacing functions in this manner. A single JavaScript f...
stackexchange/codereview
I am taking efforts to solve problem K-th Symbol in Grammar - LeetCode K-th Symbol in Grammar On the first row, we write a 0. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10. Given row N and index K, return the K-th indexed symbol in...
stackexchange/codereview
As a practice exercise, I implemented a cellular automaton (Conway's Game of Life) in python (with help from this tutorial). I am very curious, if this code follows common best practices and I am wondering how to improve the code in terms of performance and readability. import numpy as np import matplotlib.pyplot as p...
stackexchange/codereview
My XAML looksl ike this: <UserControl x:Class="Dexel.Editor.Views.UI_Sketches.UiSketchCanvas" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.ope...
stackexchange/codereview
I'm trying to follow this Vulkan API tutorial and have come up with an implementation that I don't completely loathe. The VkUtf8StringArray class is my least favorite thing and would like to know if there are better ways I structure things and/or make them safer... Note: Depends on a helper file to load the dll at run-...
stackexchange/codereview
I coded a linear (without threads) app, which looks ok and has normal solving speed. Also, I coded a multithreaded app, and it is ok when I use 2 processors and 2 threads. It is also fine when I use 4 processors and 4 threads. But when I try to solve with 6 processors and 6 threads, I am not satisfied with the solving ...
stackexchange/codereview
I am currently working on a Redis project and I would love to know where I am likely to run into Unhandled Exceptions in the following code. A General Review would be great, don't hold back. This is code for Intercepting using proxies, and uses a considerable amount of Reflection to resolve unknown types. I am posting ...
stackexchange/codereview
I have solved the classic "Merchants Guide to Galaxy" problem: A merchant buys and sells items in the galaxy. Buying and selling over the galaxy requires you to convert numbers and units. The numbers used for intergalactic transactions follows similar convention to the roman numerals. Roman numerals are base...
stackexchange/codereview
I am writing some C# that will be running on Linux and will extract values from a kernel generated system file that represents readings from a sensor. The file contains two lines of text, and I have a method which will extract two values from the file. The file looks like this: $ cat /sys/bus/w1/devices/28-00000*/w1_sl...
stackexchange/codereview
(See the 2nd/previous iteration.) I essentially removed all the type conversion trickery and have this: numberbag.hpp #ifndef CODERODDE_STAT_NUMBER_BAG #define CODERODDE_STAT_NUMBER_BAG #include <cmath> #include <cstddef> #include <iostream> #include <initializer_list> namespace coderodde { namespace stat { template...
stackexchange/codereview
guys. The code below is spring security web adapter. I do not like configure(HttpSecurity) method that generates security confirmation policy. Any ideas to do it more readable and clear? /** * Spring security configuration * * @author Eugene Ustimenko * @date Nov 5, 2014 */ @Configuration @EnableWebSecurity public clas...
stackexchange/codereview
I already asked a Code Review question about Working with a new form instance every time. As far as I have decided, that the most important part of the code is to work with the instance of the form and to learn how to handle them properly, I have remade the code (roughly using the code from @Mat's Mug) in a way that I ...
stackexchange/codereview
The code below is converting: data from one format to another # input sample { productText: [ { "language": "en", "version": "1", "sequence": 1, "text": "blah", "textType": "ROMANCE" } ] } # output sample { productText: [ { sequence: 1, textType: "ROMANCE" ...
stackexchange/codereview
I have implemented Dijkstra's algorithm using a slightly modified version of the structure and class posted here. Unfortunately, I have ruined the efficiency. I am intent on using this structure. I will NOT use BOOST. Any STL algorithms are acceptable. #include <iostream> #include <vector> #include <map> #include <stri...
stackexchange/codereview
I am new to Ruby and would like some help with re-factoring my code. class Beam def initialize puts "Please specify span of beam" @span = gets.chomp.to_f puts "How many number of point loads do you want?" @pointLoadNos = gets.chomp.to_i @pointLoad = Array.new(@pointLoadNos) @pointLoadDistFromLe...
stackexchange/codereview
I recently coded a game of hangman and wanted to know, A: Are there any places it could be more efficient? B: Are there any things that are distinctly wrong with it, since I know people seem to say to avoid using GOTO and SLEEP? C: Is there a way to have it generate words randomly or a database the code could access? I...
stackexchange/codereview
The following code will start a timer to continue drawing real-time data (that has been pre-buffered, to be swapped in the gui as fast as it can) to the window during repositioning or inside a menu loop. // State of the application static bool running = false; static uint32_t modalmode = 0, modalcount = 0; static const...
stackexchange/codereview
I've got a CSV that contains users and permissions in the below format, where users can have as little as one or as many as eight different permissions: USER,PERM1,PERM2,PERM3,PERM4,PERM5,PERM6,PERM7,PERM8 jdoe,perm1,perm2 tsmith,perm1,perm2,perm3,perm4,perm5,perm6,perm7,perm8 This is the desired format, with each uni...
stackexchange/codereview
I have implemented a very simple idea of HashMap, I tried to cover cases like "get, put, delete, containsKey, resize," etc in the following implementation. Please take a look and suggest improvements to my coding styles and thought processes. Interface public interface Map<K, V> { boolean isEmpty(); int size()...
stackexchange/codereview
Is there a better way to refactor my below code where I have many conditions in if and else statement The reason for refactoring is to make code cleaner and readable public static PaymentOptions GetPaymentOptions_Auto(TestConfigurationCDO testConfiguration, int siteId) { var paymentOptions = new PaymentOptions(...
stackexchange/codereview
I am porting a linear optimization model for power plants from GAMS to Pyomo. Models in both frameworks are a collection of sets (both elementary or tuple sets), parameters (fixed values, defined over sets), variables (unknowns, defined over sets, value to be determined by optimization) and equations (defining relation...
stackexchange/codereview
I created a function to get the hash value of a file. Normally the output is 3 lines. My function does 3 things: extracts the hash value removes the spaces in between the hash value prints hash value Here is the output when using CertUtil -hashfile FILENAME.EXE SHA1 SHA1 hash of file FILENAME.EXE: XX XX XX XX XX XX ...
stackexchange/codereview
I need to transform the coordinates from spherical to Cartesian space using the Eigen C++ Library. The following code serves the purpose: const int size = 1000; Eigen::Array<std::pair<float, float>, Eigen::Dynamic, 1> direction(size); for(int i=0; i<direction.size();i++) { direction(i).first = (...
stackexchange/codereview
I implemented a test that reads data from temp file on Windows. I originally had an issue that I solved with the help of this answer def test_read(self): """Test read from file""" import tempfile import os try: with tempfile.NamedTemporaryFile(delete=False) as temp: content = 'Some ...
stackexchange/codereview
In case the table has class 'trans' - run dataTable() and columnFilter(); otherwise just run dataTable(). Is it possible to not repeat the dataTable() part? $('#dt_a').each(function() { if ($(this).hasClass('trans')) { $(this).dataTable({ "sDom": "<'row'<'span6'<'dt_actions'>l><'spa...
stackexchange/codereview
I have written code to get all the MAC addresses in from systems having multiple MAC addresses and I think there's something which needs to be corrected albeit the code runs fine. Note: I have just tested it on Android. import re def getMacs(): macs = [] file = os.popen("getmac").read() file = file.split("...
stackexchange/codereview
for a thesis I am creating a program that constructs curling sequences. The curling number of a sequence is defined as 'the largest frequency of any period at the end of the sequence'. (For example, 11232323 has curling number 3, because 23 is repeated three times) Currently, I am mostly interested in the appearance of...
stackexchange/codereview
I have made a procedure to display the highest and the lowest popular Items for a particular time of a given date. The procedure works with no errors or exceptions and everything is functional. As you can see, the queries are repeated twice for the purpose of showing the first record on Items, but the only differences ...
stackexchange/codereview
I made this Renderer class recently, to simplify the user interface of my library's API. I would like to ask advice about the move semantics (copy constructor, std::unique_ptr, ...), or any other things you can point out to improve my code. As you can see, I take in parameters in RenderObject in the form of a pointer. ...
stackexchange/codereview
The question asks to rotate an image/matrix by 90 degrees. Ideally it asks to do it in place but before that I decided to do it using extra space because this is my first time working with matrices. question: while using extra space, could this have been any better? def rotate_m1(matrix, d): """ with extra spa...
stackexchange/codereview
I am beginning the cycle of creating my role based access control into my framework. I now want to log the user into my application and my _user table looks like this: CREATE TABLE `_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL, `hash` varchar(255) NOT NULL, `session` varchar(...
stackexchange/codereview
Occasionally I need to implement periodic checks in a loop in a background thread, a typical example being asynchronous processing using a message queue. While it’s not terribly complicated, I wonder what simpler, more elegant solutions exist. I post my solution, and I’m eager to hear any constructive criticism! The r...
stackexchange/codereview
After answering Monty hall python simulation I wondered what the outcome were to be if there were more than three doors, say four or seven. And so I decided to modify the problem slightly to adjust for this. There are \$x\$ amount of doors. Behind one door is a car, the others are goats. You pick a door, and the host r...
stackexchange/codereview
This code works great and does exactly as it should, but there has to be a better way of doing this and I just can't figure out how! I'm pretty new to jQuery and am trying to use it more myself instead of using plugins and I can get stuff to work fine. It just isn't the tidiest or neatest code, which I'm trying to move...
stackexchange/codereview
I'm currently writing a script and I decided to run cane over it to look for some issues, and the following method was highlighted. I've done my best to cut it back, and at this point I'm inclined to leave it as-is, however cane is still giving it a pretty high rating of 23 (15 is the point it starts complaining) so I ...
stackexchange/codereview
I am reading some HTML files and returning them upon request, but when they go through my codes I need to filter out some stuff from these HTMLs, everything is working fine and I'm using about 20 or more str_replace and preg_replace to do that which works pretty fine. Until I used this $responseBody = preg_replace('/<s...
stackexchange/codereview
The code below calls the parse_config() function which populates the global variables user, passwd and host which are later used in main() function: #!/usr/bin/env python3 import sys import configparser def parse_config(cfg): """ Read the configuration file. """ global user, passwd, host if cf...
stackexchange/codereview
The problem statement is as follows: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 1254069874715852...
stackexchange/codereview
I have an endpoint in my API which does a port test on 4455 and 4456 once a client GET's it. This is accomplished by requesting two web pages. The result will respond to the client with a JSON object: { "4455": 200, "4456": 200 } I have the following code app.get(networkPfix + "/portcheck", (req, res) => { ...
stackexchange/codereview
I am writing a custom form validation script compatible with IE8+. I just wanted to make sure I am not messing anything up. I have tested on IE8 its works. However, I want to make sure I am doing it the right way. var wrapper = document.querySelector('.wrapper'); var btn = document.querySelector('button'); var in...
stackexchange/codereview
I created a calculator for CTR with jQuery. The calculator is working just the way I want, but I'm quite new to jQuery and I wonder if I am using jQuery effectively. The goal of the code is that if 2 values are entered and the button is clicked then the correct function is called and the output's background colour wil...
stackexchange/codereview
I've updated some of the type hinting/documentation in a lib called pygrib. The source documentation can be found here. The goal is to extend the Cython api with the associated native type hints and maintain an open ended platform for future growth, IE more methods like to_dataframe() pygrib uses Cython to read gridded...
stackexchange/codereview
I hope this is the right board for this. I am a novice programmer and I am trying to learn how to write better code. I have a visualforce page with a very long Javascript script in the middle of it to display a Google Map. The code is entirely inside of a single function, but I cannot figure out a cleaner way to break ...
stackexchange/codereview
I created a script to automate the task of uploading a CSV file to Box. I have a couple of files a Box client and a MySQL client. I create an instance of both on the function.rb file which is the one below. I wonder if there is anything to improve? if there are principles I'm not following or if I'm breaking best pract...
stackexchange/codereview
I've been trying to teach myself Rust, and I decided that a simple console calculator would be a good project to learn from. use std::io; extern crate regex; #[macro_use] extern crate lazy_static; use regex::Regex; fn main() { loop { println!("Enter input:"); let mut input = String::new(); ...
stackexchange/codereview
I am attempting to create a fast & robust object management system that allows adding, removing and retrieving objects from a "scene". I am trying to wrap my head around the best way to do this regarding ownership and object lifecycle. Code: main.cpp: int main() { r3d::scene main_scene; game_object& obj = main...
stackexchange/codereview
I have a library of news articles. Each story is unique by id. public String getStory(String id) throws Exception { Connection conn = MysqlDb.getConn(dbName); try { for(Publisher p : Publishers) { PreparedStatement prpStmt = conn.prepareStatement("SELECT story FROM " + p + ...
stackexchange/codereview
I was just wondering if my code below is a good way of populating data from database. I have had no issues with this really but I am being taught this and just wondering if it is the best practice. Public Sub LoadProperty() '**Finds the Current Property Data 'Error Checking ' On Error GoTo Err_LoadPropert...
stackexchange/codereview
I'm teaching myself Rust, and to do this I've written a toy register based virtual machine. I hope the code is easy to follow - I just want to know if there are any mistakes I am making with the language philosophy or if there are syntax tricks I could be using. For example, the program counter pc and the register fiel...
stackexchange/codereview
I am writing a simple web application where I have a User entity and set of pre-defined questions to be answered by the User. The answers provided by the users for these questions would need to be stored against the userId and questionId. After a bit of googling and with the help of stackoverflow, I have designed the t...
stackexchange/codereview
This is a simple script to make ls output first folders, then files, then other stuff (symlink). I think this is really neat and would like to share the script in exchange for comments. It should be noted that I'm working with GNU findutils and coreutils. Some basic criteria that I'm aiming for include: lssort must a...
stackexchange/codereview
I'm a few months into learning C++ programming and I want to know if I'm moving generally in the right direction or not with the following code. This is the most advanced thing I've created so far, but it doesn't contain any pointers or references so I'm worried I'm not doing things properly on the memory level. I espe...
stackexchange/codereview
I use zypper to download and install for openSUSE Tumbleweed (much like everyone else of course). Unfortunately it downloads packages serially, and having about a thousand packages to update a week, it gets quite boring. Also, while zypper can download packages one-by-one in advance, it can't be called concurrently. I ...
stackexchange/codereview
Description The code uses strtol() to convert text that represents a value in a given base into an integer. It takes three arguments from the command line, including the string and the base. The string may begin with an arbitrary amount of white space followed by a optional - or +. If the base is 0 or 16, the string ma...
stackexchange/codereview
I'm making a file downloader using Java. The project is on GitHub; I have included the most relevant excerpts here. I separate the file into parts and download them using HTTP Range request, with each part being handled by a thread. All of the threads share an object, which is used to keep track of the progress and pr...
stackexchange/codereview
I was tasked to write process that initially seemed like a straight forward thing. "Fetch data from database, create a cache object, and assign this data to it. Use existing class to model this after." That's it in a nutshell. The 'existing' class did not do any caching, just an async call across layers to the database...
stackexchange/codereview
The goal is to upload the columns from the csv into the SQL Pro database. I am able to select the column names that have been uploaded from the csv file, the columns from the csv file are then uploaded into the option dropdown. In return I need to submit the selections that have been selected from the options dropdown...
stackexchange/codereview
A unix convention is to use - as a placeholder for stdin/stdout in command lines, e.g. gcc -x c - to compile stdin as C. I often find myself writing logic to get this behavior in my Python scripts, so I abstracted it out into a context manager: from typing import IO class argfile: def __init__(self, default: IO, f...
stackexchange/codereview
Motivation const_cast is a beast that I seldomly encounter. But when I do so it is mostly a bad experience. Nobody knows what most of the C++ programmers do but so far I only ever had one use for const_cast: to cast away a const from a type. For this task const_cast is too verbose: const std::vector<int> constVectorOfI...
stackexchange/codereview
Problem Statement: Extract the filename and read if filename has jQuery on it, put them aside. Second step will be to check one more and see if any jQuery files has ui in the filename. Input: script_ref1 = """<script type="text/javascript" src="js/jquery-1.9.1.min.js"/> <script type="text/javascript" src="js/jqu...
stackexchange/codereview
Conflicts arise in Excel VBA while running multiple Subroutines that modify the Application State. What happens is that the first Subroutine will turn off setting to speed up the code and then call a second Subroutine that does the same. The second Subroutine will then switch the setting back on before exiting. The ...
stackexchange/codereview
I created a script for path search across network topology based on uploaded routing tables in text format. The final purpose is to be able to get all available paths to given subnet/host from each uploaded device with corresponding routing info. Routing tables are stored in subdirectory (./routing_tables by default) i...
stackexchange/codereview
I'm new to Perl and have successfully written a merge sort program. I'll paste the entire program below, but would like mostly a review of the subroutines mergeSort() and merge(). I tried to use pass-by-reference as much as possible to make as it as fast as possible. Is there ways I can make this better/more optimi...
stackexchange/codereview
I'm trying to write a module to dynamically load all the files from my "controllers" folder, and then add them to the main express instance as routers. The files inside the controllers export an Express router. So the code basically does the next things: Read the "controllers" dir. Store what each router exported by t...
stackexchange/codereview
I have implemented my code using Cython. It is the current bottleneck in my computations. There are two non-numpy functions involved: calculate_2D_dist_squared which calculates the distance squared between two points calculate_2D_dist_squared_matrix which generates the distances squared between every two distinct vert...
stackexchange/codereview
To expand from the changes supplied by the answer of my previous question: #include <condition_variable> #include <iostream> #include <random> #include <mutex> #include <thread> #include <vector> // global variables std::condition_variable cv; std::mutex mtx; std::vector<char> data; int count = 0, buff_size = 0; cha...
stackexchange/codereview
I have the following code, which works as I need it to, however, it repeats itself over and over. I'm relatively new to PHP and haven't grasped recursive functions yet. Which I've been told I'll need to understand as this function could potentially have many levels. if ($_POST['parent'] == "None") { $parent = "...
stackexchange/codereview
Context In an imageprocessing project of mine, I needed to do some edge detection and implemented the Theo Pavlidis algorithm which works quite well. A problem had been to get the next "good" position. Assuming an image like this (where the 1 represent the needed pixel value) 011110 111111 111111 011110 thi...
stackexchange/codereview
I'm writing a typical client-server architecture for a chat program. My goal is to make the protocol flexible so that I could add more functionality in the future. (Any good software should allow that) Both applications should be able to wait for a response from a particular request that has been sent. I'm currently us...
stackexchange/codereview
This is the first time I'm parsing an XML file. So I will be grateful for any suggestions on how my code may be improved. Or if you could suggest another approach to solving this problem. One other question that I have is why attributes 'title' and 'score' have switched in the resulting XML file (xml2.xml)? I've go...
stackexchange/codereview
Background Linked lists are a well-known data structure, so I won't waste too much detail on them. Suffice to say that a linked list consists of "cells". Each cell contains some kind of value and a reference to the next cell (except the last one, which contains an empty reference). I implemented a linked list in Clojur...
stackexchange/codereview
I wrote a multithreaded p2p chat application with Qt, and I'm hoping for some feedback. I know there's some deficiencies with error handling, but I'd like to know what else I'm missing. Thanks! import sys from PyQt4 import QtGui, QtCore import threading import socket import time import Queue class initWindow(QtGui.Q...
stackexchange/codereview
I've been coding for a while, but this is the first actual project I've made. I generally do contest programming, and as you might imagine, good code practices are not exactly the top priority. I'd appreciate any pointers, whether overall design of the program, or variable naming, or things that I should have split up ...
stackexchange/codereview