instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
As a C++ newbie, I am practicing my C++ skill by implement games in BASIC Computer Games and here is my C++ version for Battle. Suggestions I want Any suggestion are welcome! Current Project code from my work place full of C styles in C++ (which is not a good thing), I want my code to be C++ style, and to be more C++11...
stackexchange/codereview
I am writing a program that can implement algorithms to solve the TSP. My goals: The solver can record every algorithm step, so that the whole solving process can be later visualised by charts or animations It's easy to add new algorithm implementation End user has full control over the simulation parameters I tried ...
stackexchange/codereview
This is a LeetCode.com problem. https://leetcode.com/problems/count-of-smaller-numbers-after-self/description/ You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i]. Example: Given ...
stackexchange/codereview
I'm interested in optimizing my code. Can someone help me understand the best way to trim this code down with DRY methodology? So I've got these two classes here preforming WMI queries on two separate Win32 classes. My questions are: Should I keep them separated in different classes based on the Win32 class for organi...
stackexchange/codereview
I have workbook having multiple sheets and having same data on it. Currently I am using macro that .autofilterand copy paste on respective sheets. I am using looping process like:- Sub SCRIPT() Application.ScreenUpdating = False Sheets("SCRIPT").Range("A3:P100").ClearContents Dim ws As Worksheet, lrc As ...
stackexchange/codereview
I've recently given a coding interview on a Java concurrency task and unfortunately didn't get the job. The worst part is I've given my best but now I'm not even sure where went wrong. Can anyone help give me some ideas about things I can improve on below code? The question is pretty vague. Given 4 generic interface...
stackexchange/codereview
I wrote an update() function to make an entry the first element in an array. var arr = [ {v: 1}, {v: 2}, {v: 3}, {v: 4}, ]; function update(e) { var i = arr.findIndex(o => o.v === e.v); if (i === 0) return; if (i > 0) arr = [e].concat(arr.slice(0, i), arr.slice(i+1)); if (i < 0) arr = [...
stackexchange/codereview
My primary concern is that this has been written as a global function. I think it would be better if this was a function of the SignalProducer class but I am not sure that is even possible. Is this thinking justified or is the use of global functions acceptable? (The following code uses ReactiveCocoa 4 and is written...
stackexchange/codereview
I'm trying to find patterns of different length in a given string. How can I improve it? Are there problems? function find(pattern,str) { var arr = []; for (i= 0;i<str.length;i++) { if(pattern== str.slice(i,pattern.length+i)) { arr.push([i,pattern.length-1+i]); }; }; if(!arr.length) { retu...
stackexchange/codereview
I was messing around with the csv package and I tried to implement a class that returns csv objects whenever I need to open a csv file directly from a url(and occasionally prints out something).I am still very green and I would like to know if there is something I can do to optimize this code.You are going to find the ...
stackexchange/codereview
This is a solution to the problem: "The Broken Pedometer" on the UVA online judge. (Note: I can not use anything beyond what is in g++ 4.6 which is what is used for the competition I'm training for.) Algorithmic approach (pretty simple, but fast enough, not needed to understand to comment on the code): possible_led_re...
stackexchange/codereview
I have created a function which randomly sets styles using CSS selectors. Right now it returns a random item from an array. The program also works with shorthand properties (such as font). Could my code be improved and run more efficiently? const setRandomStyles = (obj) => { console.time("Executed in "); Object.e...
stackexchange/codereview
I have an if else statement like this deciding the pattern to be followed based on type or department of employee. The if else block goes like this. I am planning to simplify the if else block to a better format. public static Pattern decidePattern(Employee employee) { try { if ("individual".equals...
stackexchange/codereview
Replace all c / C / v / V in stdin with lower case, upper case consonants / vowels respectively. All other input is passed through. Anything that can be improved? Looking at maintainability first, performance second. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> static const char lower_c...
stackexchange/codereview
This is a number guesser that guesses a random number between the values that you set. The user has to use the up or down arrow keys to say if the number that they thought of between the number generated. This continues until the number that the user is thinking is generated and then the user pressed enter to say that ...
stackexchange/codereview
Edit: Licensed source can be found here. The intent behind this class is to allow different game systems to run at their own clock rate. The physics integration rate should not be connected to the screen refresh rate, for instance. Instancing this class should allow for accurate, independent timing of separate systems....
stackexchange/codereview
Most quicksort examples online use C-style arrays and indexes. I have written below quicksort implementation with STL style iterators. It looks fine to me, but I feel like I may be making more than necessary copies of iterators. I am open for any suggestions/improvements: #include <iostream> #include <vector> #include ...
stackexchange/codereview
I create this class method to Enter Selected Items Form CheckboxList to associated resource I use ADO.net & store Proc to insert data can someone help me to improve it and make to so clean instead of my Hacks BTW I use Microsoft Enterprise Lib public static void Insert(List<int> listSkills, int rID) { ...
stackexchange/codereview
I really want to have a nice design pattern for my Node.js project. This is my state diagram. As I'm coding this, I'm wondering if it's better to separate state logic from the class? So instead I would only have my class be responsible for initial construction and then emitting state changes which get handled elsewhere...
stackexchange/codereview
Given a Binary Search Tree and a number N, the task is to find the smallest number in the binary search tree that is greater than or equal to N. Print the value of the element if it exists otherwise print -1. Please review the code, the unit tests are just for the demo. please comment about performance thanks. ...
stackexchange/codereview
I made this two player TicTacToe game as a challenge i was given in class. The game starts where the first player chooses where their X will be placed. Each area in the array has been given a number starting from 1 and ending at 9. After X chooses their area, the game will let the user know who's turn it is, and they w...
stackexchange/codereview
I've implemented the Conway's Game of Life in Java, including a GUI. Here's the code of the two classes I wrote: GameOfLife.java public class GameOfLife { public static void main(String[] args) throws InterruptedException { Gui gui = new Gui(); int [][] array = new int [71][71]; //Field...
stackexchange/codereview
I have this little exercise writing a binary trie in F#. In C# it can be done in few lines, but here it became more complicated than I had expected (especially the add function): open System type BitTrie = | BitTrie of Zero:BitTrie * One:BitTrie | NullTrie module BitTrie = let ubound = 31 // 32 bits i...
stackexchange/codereview
I have the following code on my server that takes a string and inserts newlines in such a way that the string is separated into lines, all of which are shorter than maxLineLength in characters. This ensures that the text, when printed, will fit within a certain width. const formatTextWrap = (text, maxLineLength) => { ...
stackexchange/codereview
C++ shared_ptr implemented as a coding practice and learning purposes. It uses std::shared_ptr interface. Basic tests are included (using single header Catch 2) Some methods are omitted to keep the code shorter and readable. For simplicity it expects C++ 20. See comments for more details. Is this implementation correc...
stackexchange/codereview
After the amazing feedback from these questions; I have prepared a third version of the original posted code. The Idea is the same: An std::size_t variable threads_ready is increased to threads.size() until all threads are finished with the payload, and then back to 0 when all threads are ready to execute again. I eli...
stackexchange/codereview
I'm a relatively new (~6 mos) developer, and I'm hoping for some feedback on my code style/structure. While I'm particularly interested in efficiency and maintainability, I'm open to feedback regarding anything that comes to mind from more experienced developers. /** * Attempts to create new SavedSearch (eventual POST...
stackexchange/codereview
I'm learning Racket and have implemented a mutable stack, which is just a bunch of wrappers around an underlying struct containing a size and buffer list (so it's not optimal, in terms of computational complexity). After consulting #racket and reading the first half of Greg Hendershott's Fear of Macros, I was able to w...
stackexchange/codereview
I recently posted a question about improving thread and socket safety in my NetworkEndpoint class. previous post I have implemented the changes suggested in the answer I got there. When I asked for a second look to confirm my changes I was told to post another question. Included below is the code I changed as well as a...
stackexchange/codereview
I do parsing of the string in order to find wrapped sub-string inside brackets of the first level. a+(b+(d-g))+g+d, in this case I will need to separate (b+(d-g)). Below is the function which i use for such situations. This function is invoked when i find any opening bracket (. I did profiling of the program and unfort...
stackexchange/codereview
I offer same day shipping if the user places an order before 9AM ET. If they place the order after 9AM, same day shipping is unavailable. My server is using UTC time so I need to check if the time is greater than or less than 9AM ET regardless of the time where the user is located. Not being an expert with JS, I cobble...
stackexchange/codereview
I am practising my coding skills on interviewbit. I got one question about preorder (for a tree). This is what I did first: public class Solution { private ArrayList<Integer> result = new ArrayList<Integer>(); public ArrayList<Integer> preorderTraversal(TreeNode a) { if(a == null){ return result;...
stackexchange/codereview
The CSyncObject object in CSingleLock constructor can't be NULL but I want it to work with NULL because I need to use this nest. BOOL CADODatabase::Open(LPCTSTR lpstrConnection, LPCTSTR lpstrUserID, LPCTSTR lpstrPassword) { CString database = GetSourceDatabase( lpstrConnection, NULL ); // get the appropriate ...
stackexchange/codereview
My Android app must request my Cloud Functions server to create in-app products at runtime ; then, the server responds with the created one-time product. I've written the server Cloud Function that creates the product. Here is how it works (full minimal, executable code is embedded at the end of the question): My func...
stackexchange/codereview
I wrote a program that concurrently reads multiple files and makes a request to an API for each line of each file. The JSON response is then parsed and the "available_filters" field is extracted. The program then evaluates if each "filters" field inside "available_filters" contains numbers in its name. Each numeric fil...
stackexchange/codereview
I am working on an HTML document to which I need to add certain classes to some elements. In the following code, I am adding class img-responsive. def add_img_class1(img_tag): try: img_tag['class'] = img_tag['class']+' img-responsive' except KeyError: img_tag['class'] = 'img-responsive' r...
stackexchange/codereview
I wrote a code and the code counts the number of identical elements between the arrays s and d at the same index. I need to optimize the code for speed and readability. I tried HashSet but it didn't work at all. Do you have any Suggestions? public static void main (String[] args) throws java.lang.Exception { Scanne...
stackexchange/codereview
I have created a vector math header library where the size and data type stored are template values, and I'd like it peer-reviewed please. I have a few main questions: Will using my SizedVectorBase struct prevent template instantiation code bloat like I intend it to? Are the functions I defined constexpr correct to do ...
stackexchange/codereview
I've just started using Lazy.js, which is my first exposure to a "functional style" javascript library. I'm still utterly lost as to which of the hundred different functional javascript libraries to use, but so far I like Lazy.js, so I've used it to write a tag harvesting module for a blog engine project I'm working on...
stackexchange/codereview
Introduction I am developing a dynamical system simulation/animation framework, which provides three abstract base classes, DynamicalSystem, Visualisation and Animation, from which clients can derive concrete classes for the purposes of animating dynamical (physical) systems in 3D (and 2D). The DynamicalSystem abstr...
stackexchange/codereview
I don't like the idea of sprinkling process.env all over the place and wanted to abstract it out a bit. I'm new to Node and know there must be a better way to do a few things. Not repeat the name 4 times (twice as a string and twice as a field) Any cleaner way to create properties and centralize existence checks than ...
stackexchange/codereview
I am a beginner in javascript and I have made this project as a part of The odin project. Feautres: Draw by hovering the mouse on grid Erase Clear the entire sketch at once Reset the grid size I have created the grid using only flexbox. Here is my code: function createGrid(grid, rowSize, colSize) { for (let i = 0...
stackexchange/codereview
Last version of library (performance has been improved drastically since posting). I tried to implement the Quick Hull Algorithm for computing the convex hull of a finite set of D-dimensional points. Algorithm itself: #pragma once #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/lu.hpp> #include...
stackexchange/codereview
I have a function that synchronizes according to some specifications columns of a dataframe. The functions works, nevertheless I was wondering how to: Improve performances Make it more pythonic Please feel free to leave any suggestions. Function specifications Inputs: df : a dataframe with columns: [a0,...aN]...
stackexchange/codereview
I'm developing an algorithm that takes structured light patterns to determine 3D properties of objects. This class builds the structured light objects. It creates a buffered image, and based upon initialization parameters and the needed iteration step, manipulates the image to form a structured light pattern that wil...
stackexchange/codereview
If I have an array: var names = ['John', 'Jim', 'Joe']; and I want to create a new array from names which afterwards will look like: newNames = ['John John', 'Jim Jim', 'Joe Joe'] What I came up with is the following: var newNames = []; var arr = null; var loop = 0; $.each(names, function (i, item) { arr = []; l...
stackexchange/codereview
There are my shapes (for example): public abstract class Shape { protected int _id; protected string _description; public abstract string ToXml(); } public sealed class Triangle : Shape { public int TriangleId { get { return _id; } set { _id = value; } } public string TriangleDescription { get { return _des...
stackexchange/codereview
I've created this database structure to store tabular information (it's a simplification of my real structure but enough to show the point). In it I have Sheets and each Sheet can define different Columns. The important part is that with this structure I can define different datatypes for each Column. Those could be di...
stackexchange/codereview
Note: I have a working solution, my question is about optimization and other approaches. Problem Description Hello, I'm re-writing an old program I made that solves nonograms. As part of solving it, I generate (for some of the lines) an array of all possible ways to fit the numbers in. I want to create a piece of code,...
stackexchange/codereview
Here the short story. I have a listener on a queue which sends me several jobs. Each job is launched in a thread and takes different times to finish. I have two main constraints : I want to retrieve the result of the job when it finishes (hence the use of std::async rather than std::thread) I want to have a collection...
stackexchange/codereview
EDIT: Version 2 is now available here I am just getting to grips with ReactJs using es2015 classes, i have just converted a simple portion of an app i maintain into react code and tried a few things out, this displays a list of customers with a sub-list of the animals that they own. Am i utilising es2015 features corre...
stackexchange/codereview
I'm trying to solve ECOO 2018 round 2(regionals) question 2 to prepare for the upcoming contest. Basically, in the question George has to achieve the maximum possible grade by completing the right assignments. Each assignment has a deadline and a weight value. I've came up with two solutions yet both only work for 7 of...
stackexchange/codereview
I know the vectors that describe two perpendicular lines, $$\mathbf{a} + \lambda\mathbf{d}$$ and $$\mathbf{b} + \mu\mathbf{d'}$$ I've written a JavaScript function to get the coordinates of the point of intersection of two such lines. It is guaranteed that they will intersect, since in my case the lines are perpendicul...
stackexchange/codereview
I am writing a task scheduler (that will one day grow up to be a windows service when I look into them) that should pretty much loop infinitely until I tell the program to stop. But having while(true) seems incorrect. What is the correct way to implement the loop? Use a dummy boolean variable that the code doesn't actu...
stackexchange/codereview
I am learning TSQL (SQL in general for that matter), and I wrote this trigger that inserts logs about updated employees into the tblEmployeeAudit table. When I was looking at the end result my eyes hurt. The trigger was super simple, yet super long (for something which is so simple), it seemed as if a 10-year-old rasca...
stackexchange/codereview
I wrote up a small script to calculate the answer to Project Euler Problem 5: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? I'm wondering if this algorithm...
stackexchange/codereview
Problem Statement Write a HTML page holding a form and a text field. Using JavaScript make the text field to accept numbers only. When a non-number character is entered through the keyboard (or by any other way), make the field red for a while and do not accept the change (preserve the previous value of the field). Ex...
stackexchange/codereview
The basic idea is for users of these classes to create derived polymorphic protocol specific messages. There is no protocol type in the interface, it is all hidden behind the scenes. But the serialised messages can be retrieved with the getMessage functions. Does this look a logical approach? Any suggestions? //base ...
stackexchange/codereview
Just wondering if anyone had any suggestions for improvements. I created these extension methods so it's easier to get the start and end dates of Daylight Savings Time from the TimeZoneInfo class. public static class ExtensionMethods { /// <summary> /// Gets the TimeZoneInfo.AdjustmentRule in effect for the giv...
stackexchange/codereview
I’m writing a small HTTP server (just for fun and education). One important part is the response dispatcher. Responses for each socket should be sent in the order the requests were received. The idea is: There’s an asynchronous connection manager that registers the request (and get id) and sends it to some request han...
stackexchange/codereview
I have an interview coming up in the next few weeks, and I'm choosing to be interviewed in Python. I began programming in Python (it was about four years ago), so the syntax is natural to me, but I only learned about some useful tools of Python just this past year, when I took a class that recommended using it. The Pro...
stackexchange/codereview
I have the following javascript code that I'm trying to modularize using ES6: import $ from 'jquery'; $('.select-element').change(function() { const $this = $(this); const $nextElements = $this.nextall(); const $nextElement = $this.next(); $this.val() === 0 ? $nextElements.addClass("hidden") : $nextE...
stackexchange/codereview
I have implemented a program to extract a log file which contains a header line, followed by zero or more data lines, in comma-separated value format. The file consists of 3 columns. The first column is the Unix time stamp, the second column is the country code, and the third column is the time in milliseconds. The dat...
stackexchange/codereview
The Dir() function in VB and VBA can accept wildcard characters (* and ?) but only in the basename of the path. Dir("path\*.txt") is a valid request but. Dir("path\*\*.txt") will return Error 52 "Bad File Name or Number", because * is an invalid folder or file name. I created the ability to use wildcards in the f...
stackexchange/codereview
I am trying to refactor a service by providing some options on what to bring back. I can't decide what is best way to go between the below A. Use a class for the options Create a new class for the options like public class Options { public bool Addresses { get; set; } public bool Documents { get...
stackexchange/codereview
I want to get two distinct sets of schema from a database without having to create multiple Connection/PreparedStatement/ResultSet objects. Currently, I have a helper method that queries the database, gets each individual schema, and then returns them together in one ArrayList - please refer to the code below. private ...
stackexchange/codereview
I'm writing a server for an MMO game using boost::asio. I would like to know, are there any design or other issues in my code? And what should I improve in it? Thanks in advance. BaseServer.h: #ifndef BASE_SERVER_H #define BASE_SERVER_H #include <asio.hpp> #include "MessageProcessor.h" class BaseServer { public: ...
stackexchange/codereview
I am looking to speed up the search for black and white images. I have about 150,000 images that I need to check but this is taking so long. How can I speed up the code? Private Sub BlackOrWhite() Dim iPath As String = txtFile1.Text Dim allFiles() As String = IO.Directory.GetFiles(iPath, "*.*", IO.SearchOpt...
stackexchange/codereview
A valid Sudoku board has the following properties The board must be square (n-by-n). Let m = sqrt(n) All rows must contain the numbers 1-n All columns must contain the numbers 1-n All nine m-by-m blocks must contain all numbers 1-n The following MATLAB code verifies a Sudoku board of arbitrary sizes (where n is a ...
stackexchange/codereview
Do you have any suggestions about how to make this code faster/better? Maybe suggest new features or better comments/docstrings? from time import time, ctime, sleep from random import choice, uniform from glob import glob import os # Gets current working directory DIRECTORY_NAME = os.getcwd() def load(): ""...
stackexchange/codereview
I have recently done some functional java programming at https://github.com/zmacomber/zm0823 and I would like feedback for what could be improved in my coding approach. Here is one of of the classes from that repo: package org.example; import java.time.LocalDate; import java.util.Arrays; import java.util.Collections; ...
stackexchange/codereview
Okay I've just finished writing a nice tiny C program to have an ASCII spinner (works on Windows and POSIX). I'm quite new to C, so any suggestions would be great. This is designed to be a small function in my other programs, so please point out anything that could cause problems when been integrated into a larger prog...
stackexchange/codereview
This MIPS Assembly program will make you access the elements in the 4x4 matrix in either row or column-major order i.e. accessing all elements row by row or column by column. Output is posted below as well. Data section has variables declared, Text section has the main function. This took me several days to put togethe...
stackexchange/codereview
I am trying to convert a SQL Server stored procedure to Pyspark code. This is my SQL Server query: WITH A (ID, CHILDMSF, PARENTMSF, TOPPARENT, TYPE, QUANTITY) AS ( -- Base case: Select distinct rows from #BO satisfying the condition SELECT DISTINCT ID, CAST(CHILDMSF AS ...
stackexchange/codereview
For fun I decided to make an algorithm in Python that would create a 2D list of a specified size that it can populate with a list of words and fill the gaps with random characters. It's basically a wordsearch. You supply it with the words, optionally a size and then a count of how many times to retry when invalid board...
stackexchange/codereview
I want to write read savefile function with smart pointers and SDL2. I have little expirience with smart pointers and just want to ask is my code good, correct and no memory leaks. this is my code: std::shared_ptr<SDL_RWops> saveFile; -- int GameEngine::ReadSave() { int Highlevel; //Open file for rea...
stackexchange/codereview
I haven't done much Python programming, but I really like the language so I've been using it for side projects that I work on. The problem with this is that I don't have the opportunity to have my peers review my code and give suggestions. I've been working on a project that will be scraping GitHub looking for secur...
stackexchange/codereview
I have two python scripts (or one bash script + one python script) which are working independently from another, one script puts data into a folder, the other one reads from it. Since I don't want to accidentally read from the folder at the same time it's updated, I created this simple folder lock using a dummy file. I...
stackexchange/codereview
I need to insert multiple checkbox text into a column in a mssql database, I could use a single checkbox list and make this thing easier, however, the requirements are to display separate table columns with several checkboxes , kinda like Check all the conditions that apply , but for several criterias, so I am guessin...
stackexchange/codereview
I'm new to Java and I've written a flashcard program in Java 8 that allows the user to create a collection of flashcards and then test themselves using those flashcards. Please provide any recommendations on the readability and the design of the program (including my use of OOP). Here's some specific areas that might b...
stackexchange/codereview
Let's say that I have a bool[,] with random values FFFFFFFF FFFFFTTT TTTTTTTT FFFFFFFF What would be the smartest way to create a new bool[,] that build on top of the previous one. That means, that it can have random values where the previous one was true, but that it preserves the falses from the original? So this co...
stackexchange/codereview
I have written ExtendedConfigParser class that adds ability to dot access config values like ExtendedConfigParser().section_name.option_name: from ConfigParser import SafeConfigParser class ExtendedConfigParser(SafeConfigParser): def __init__(self, config_file=None, type_conversion={}, *args, **kwargs): ...
stackexchange/codereview
I have an issue opened on GitHub since mid-November, to refactor & DRY up the Rubberduck Parser module (the idea is to model the code in a VBA project or code module, so it can be browsed and inspected programmatically). Yes, I've written this ........crap. I'm guilty of Ctrl+C/Ctrl+V coding here, of which I'm very unp...
stackexchange/codereview
I want to improve my code or structure. How does it look? Any comments or suggestions? $(function() { function searchGit() { //grab value of search field var search = $('#search').val(); // Validates entered value if (search.length > 0) { //pull json data from url ...
stackexchange/codereview
In my job, we often write functions that do some calculation and write the result to a database. Sometimes mistakes are made and wrong stuff ends up being saved, therefore we also want to supply an interface to clean up after the function. This is an attempt of solving that problem. from functools import wraps def rev...
stackexchange/codereview
I've been a fan of coroutines and asynchronous programming for a while, and I recently took a trip down memory lane to when I was using Python's tkinter module for a GUI. I wanted to combine the two worlds, one of smooth coroutines and one of callbacks. My hope is to find a better solution for the basic event loop, imp...
stackexchange/codereview
Any advice on how to make this code; cleaner, more effective, just overall better! Program setup object that is coming from the database. it loop the object adding to the viewmodel object. Then the object has a certain properties base on type. The config type will only have the setting and value objects. class Program ...
stackexchange/codereview
I'm currently in the process of refactoring some code and I was wondering if I should use switch or if-else for the is code: Switch for (int i = 0; i < length; i++) { CameraStream stream = null; var id = (Guid)CameraGridView.Rows[i].Cells[0].Value; ...
stackexchange/codereview
A function to create a radial gradient from one rgb colour to another and using rayon to improve performance. Are there better way to convert between some of the types / any obvious performance improvements I could implement? use image::RgbImage; use rayon::prelude::*; fn radial_gradient( geometry: (i32, i32), ...
stackexchange/codereview
I'm using this API to get information on sports-betting odds. I am then processing it in Python to discard the irrelevant information. Here's what the response looks like: [ { "id": "9eec062ad8ed334517ab3a4be8362739", "sport_key": "americanfootball_nfl", "sport_title": "NFL", "commen...
stackexchange/codereview
Introduction I'm fairly new to programming (and Java) and I've actually never implemented Insertion Sort. I know that there's pseudo-code defined in the wikipedia article (linked above), but the goal was to implement the algorithm without looking at the pseudo-code and only using the wiki article's graphic for referen...
stackexchange/codereview
I want to arrange async server-client communication with websockets and vanilla flux architecture. There is an excellent article about "Async Server-Side Communication with the Flux Architecture". I gonna implement it analogue with SockJS and ES6 promises: TodoActionCreator.js import { dispatchAsync } from '../AppDispa...
stackexchange/codereview
I wrote the following function which coverts a JSON format into a CSV. I'll be glad to have a code review because I know that it could be done in a simpler way and with less lines and iterations. Before I will show you the code, I will explain what it does. The format of JSON: [ { "subs": [ { "stat...
stackexchange/codereview
I have a table (Oracle): customer_quote ------ int id int part_key (fk) int condition_code (fk) number unit_price int qty_quoted date entry_date With a query that selects data from the past year: SELECT cq.part_key , cq.condition_code , COUNT(*) AS cq_count , SUM(cq.unit_price * cq.qty_quoted) AS cq_tot...
stackexchange/codereview
I'm trying to solve this Play With Numbers. I have passed the test cases but, I kept getting time limit exceeded. Can someone help me improve its performance in order to pass the time limit, please? Problem You are given an array of n numbers and q queries. For each query you have to print the floor of the expected v...
stackexchange/codereview
I'm learning C++ and whilst trying to write in modern C++, I've made an attempt to rewrite a trie implementation written in C found here: http://www.geeksforgeeks.org/trie-insert-and-search/ It uses arrays to hold the branches in each node and because it's C it was done using malloc() and no freeing of memory was done ...
stackexchange/codereview
I have come up with a code that takes the total number of an array and creates ? for each, then separates them by a comma; leaving me a list like the one below: ?, ?, ?, ?, ?... I am using this for my sql queries with prepared statements, instead of having to create the prepared statement each time, I want to just hav...
stackexchange/codereview
I have a database that contains many files, and each one of those files contains many tags that relate to the file in some form. Some of those files need to have a digital signature applied to them and due to reasons unrelated to the question I need to store the original files that don't have the signature applied. I s...
stackexchange/codereview
the below code does what it needs to do. However I would like to know if there are better (shorter) ways to express the below while maintaining the explicitness of showing the decision like with the usage of if. first a few definitions type Numbers = Array Number type Sizes = Tuple Int Int foreign import _dot :: Numbe...
stackexchange/codereview
I'm a beginner in Python and I made a password checker. I'm following these rules: I have to use regex password must be at least 8 characters must have at least one lower case character must have at least one upper case character must have at least one special character must have at least one number I also wanted to ...
stackexchange/codereview