instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I been writing code for my company for years and there is never any constructive criticism for what I do. I am the only developer here and I would appreciate your opinion on this web page I made. It grabs data from a mssql database and places it in a data table adds some calculations then displays the data in a gridvi...
stackexchange/codereview
Question: You're in a hotel and you forgot what room number you were in but remember that the sum of it's divisors is greater than the number, yet there is no subset of those divisors that add up to the number itself. There are 100 rooms in the Hotel, what's your room number? My Answer in CoffeeScript: Looking for cons...
stackexchange/codereview
Original post: Tic Tac Toe game with emphasis on design and readability I got great help, but I feel like I have to ask how I can keep the GUI and logic loosely coupled. Is there any best practice that I should follow? I tried to pass MainFrame object to Games constructor instead, but then I had to redesign MainFrame ...
stackexchange/codereview
The array contains digits and it is unsorted. Its length could be as big as 120000. I need to count the smaller numbers to the right of each digit. This is a coding challenge on Codewars which requires a specific code efficency to be completed (Solve X amount in Y time). https://www.codewars.com/kata/56a1c63f3bc6827e13...
stackexchange/codereview
I am trying to use Selenium for website automation testing tasks and I am new to Selenium testing framework. The the situation I faced is to wait the website components loading and then do the related operations with the target components. The WaitFor method with xpath and waitingTimes input parameters are designed as ...
stackexchange/codereview
I'm looking for general review and improvements on this code that safely gets the next element of a list (and wraps to the first element if you exceed the list). It just seems a little excessive for how simple of a task it is. It should also be noted that this function will only work for lists that do not contain dupli...
stackexchange/codereview
It took some time to make Conway's Game of Life in HTML, CSS, JavaScript and jQuery. I'd like suggestions, criticisms, and discussions on how it can be done better. JSFiddle link /* * Conway's - Game of Life. * Any live cell with fewer than two live neighbours dies, as if caused by under-population. * Any live cell ...
stackexchange/codereview
I wrote a piece of code to benchmark the detection of perfect numbers up to 10000. The original code is here, in C: #include <stdio.h> int isPerfectNumber(int num) { if (num == 1) { return 0; } int i, c = num - 1; for (i = 2; i <= num / 2; ++i) { if (num % i == 0) { c -= i; } } return c...
stackexchange/codereview
I have N(>1000) .npy files, each has ~80MB, each contains a vector of high dimension (P). I have to deal with these data with the code below: G = np.zeros((N, N)) for i in range(N): vi = np.load(str(i)+'.npy') for j in range(i, N, 1): vj = np.load(str(i)+'.npy') G[i, j] = process(vi, vj) ...
stackexchange/codereview
I am working on architecture where I can have any client + server API. I need to call API as clean as possible and get, post, put any object I want to. For me, it is important to have clean secure code with good practice. This is how I implemented it and I would like you to help me to improve this code. Some of questio...
stackexchange/codereview
I have to update user email and password if they are present in the params, I have other user information also which can be updated. this is the method I have written, but it doesn't seem like a good method def update if user_params[:current_email].present? if @current_user.has_valid_email?(user_params[:curre...
stackexchange/codereview
I'm implementing a version of the mean shift image processing algorithm for color segmentation in Python/NumPy. I've written a pure NumPy version of the actual mean shifting per pixel (which I imagine is where the majority of time is taking). It slices an array of RGB values to work on out of the parent image, then cre...
stackexchange/codereview
I have this small utility for selecting from a collection via multiple indices at one method invocation: MultiIndexUtils.java package net.coderodde.util; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; public final class MultiIndexUtils { private MultiInde...
stackexchange/codereview
I created a dictionary web app for my language in PHP. At the beginning of the project I wanted to create not a dictionary but a simple web application that would correct the words that were entered in the wrong format by the user. But with time, the circumstances became shaky and I found good books on my topic and I d...
stackexchange/codereview
I'm nearing the end of my first MVC project which uses VB.Net and MVC5. I've started writing all my view models in a very similar fashion. This has been working well for me, but being the first person on my team to use MVC, and fairly new to being a professional developer I'm curious if this is an acceptable way to w...
stackexchange/codereview
For some time now, I've been working on a game which is superficially similar in appearance to this one. A world is filled with particles that move and change state frequently (per frame, often). Drawing is achieved by finding the locations of particles within the camera's viewport, calculating lighting for the grid lo...
stackexchange/codereview
I'm learning C++ as well as algorithms. Here's my implementation of finding the closest pair problem. I tried to minimize memory by using only iterators. And points are being read from points.txt file content: 2,1 3,5 8,3 5,8 9,1 5,2 3,3 4,5 6,5 1,9 Output is: Closest pair are: 3, 5 4, 5 Here's the code: #include <...
stackexchange/codereview
I am trying to parse this XML file. I have the extension and I need to get the description, icon, and class from the XML. My code works(ish) (I know how to continue from where I am), but it doesn't seem very elegant. Is there a better way of doing this? Here is the PHP code: <?php if($xml = simplexml_load_file('formats...
stackexchange/codereview
https://leetcode.com/problems/sum-of-two-integers/ Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = -2, b = 3 Output: 1 using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MathQuestions { ///...
stackexchange/codereview
Here is a code I want to simplify: public void Method1(Context context, EventLog log = null) { Class myClass = ConvertToMyClass(); ApiCall1 apiCall = new ApiCall1(context); if (log != null) { eventLog.WriteEntry("Starting"); } try { apiCall.Call1(myClass, null, false); ...
stackexchange/codereview
Continuing working on Natural merge sort, I have parallelized it. Requires \$\Theta(N)\$ space and runs in $$\Omega(N + \frac{N}{P}) \cap \mathcal{O}(N + \frac{N}{P}\log_2\frac{N}{P})$$ time, where \$P\$ is the amount of cores available. parallel_natural_merge_sort.h: #ifndef NATURAL_MERGE_SORT_H #define NATURAL_MERGE_...
stackexchange/codereview
Here is an input array that contains country name, year and value. I need to group values by country and years. I use this approach that works for me, but I wonder how to optimize it: export function collect( data: any[], years: string[] = ['2020', '2021', '2022', '2023', '2024'] ) { const countries = new Map<str...
stackexchange/codereview
I have this basic Java code to find average of eight immediate neighbors of a matrix. Is there any way to simplify or merge any part of it, or can I refactor it? I'm a beginner in Java programming and am trying to improve myself. // CODE STSRT import java.util.Scanner; import java.lang.*; class Matrixer { double...
stackexchange/codereview
I'm fairly new to C++ and to game programming itself. Today I decided to build a multiplayer Tic Tac Toe program using only elemental C++ syntax/data structures. I also implemented a text interface for the game instead of real graphics. Any suggestions or tips for the code? #include <iostream> #include <string> #defin...
stackexchange/codereview
A few days ago, I uploaded my first version of my calculator app I made in android studio. I got some great some feedback on it and tried to improve my app as much as I could. changes/new featres: Implemented a delete button optimized the way, everything is calculated Made a seperate class for the calculator Here u c...
stackexchange/codereview
I wrote this working code to create a linked list of a given length and print each node's values. #include <stdlib.h> //NULL #include <stdio.h> //printf typedef struct Node { int val; struct Node* next; } node; node* make_ll(int len){ node* head = malloc(sizeof(node)); node* cur = head; for (int ...
stackexchange/codereview
I am relatively new in making (invocable)callouts. My main concern is if I should be using smaller parts for example for the body and using a query only once in this case. Any suggestions would be appreciated. Class: public class or_service { @InvocableMethod public static void InvocePostProperty(List<ID> p...
stackexchange/codereview
I have several Dao classes, including a UserDao, below. The DAOs have many methods, but I'm focussing on deleteUser: @Override public boolean deleteUser(Connection connection,String login) throws MySQLEXContainer.MySQLDBExecutionException, SQLException { int rowNum = 0; Connection con; Prep...
stackexchange/codereview
I used the "long" form of all math statements, avoided the use of pointers, and used only while loops for aesthetic purposes (simply put, I think the code is prettier when it is written like that.) I am mainly concerned about the CPU efficiency of the code. Bubble Sort - The quintessential example of an "inefficient" s...
stackexchange/codereview
I've been taking a crack at Domain Driven Design, SOLID principles, and unit tests to write more maintainable code in the future. Though I tend to run into the same issue: While I have many classes/objects that are easy to test, and do one thing well, I'm completely stumped on how to get classes to interact with each o...
stackexchange/codereview
I just found a now deleted question on Stack Overflow and solved the problem. The OP was asking for a way to get all the values contained by all 'PLU' keys. I solved it this way but because I am a newbie in python I was wondering if it would be an optimal/better way of doing this, maybe using iterators, I don't know. R...
stackexchange/codereview
I use this code to check that all files in a directory are free from Unicode and non-printable characters. Can I improve the structure of the code? #!/usr/bin/env python3 import argparse import os import string import sys def main(input_folder): for directory, subdirs, files in os.walk(input_folder): for ...
stackexchange/codereview
public static class ThreadStatic<T> where T : new() { [ThreadStatic] private static T instance; public static T Instance { get { return instance ?? (instance = new T()); } } } Used like this: var probability = ThreadStatic<Random>.Instance.NextDouble(); Can this be broken? (Like, am I mi...
stackexchange/codereview
This is an algorithm I'm trying to optimize. I was trying to use openMP without any success. I know the code is long but most of it is params init. Please try to explain why I need to change any line of code. I want to learn. I also wish to understand if using openMP is the best way for matrix based algorithms. void ...
stackexchange/codereview
After my previous question I made several changes and came up with this. Remember: I wrote this for PHP 7.0.33. I'm aware I should upgrade, save the advice :) class Table { private $orientation = "hz"; // "vt" not implemented yet private $table_title = ""; private $headers = array(); private $data = ar...
stackexchange/codereview
My program is intended to allow (de-)serialization of arbitrary Python objects. It's basically a replacement for python's pickle module, which is similar but prone to arbitrary code execution. I think I've managed to make my implementation more versatile and more secure than pickle, but I'm not an expert in security. ...
stackexchange/codereview
A string contains many patterns of the form 1(0+)1 where (0+) represents any non-empty consecutive sequence of 0's. The patterns are allowed to overlap. For example, consider string "1101001", we can see there are two consecutive sequences "1(0)1" and "1(00)1" which are of the form 1(0+)1. public class Solution { ...
stackexchange/codereview
I have an agreement with a customer. When the agreement ends, the customer needs to pay. The amount which the customer needs to pay increases for each month that has passed since the agreement was initiated. The maximum duration is 3 years, so I have a final expiration date. From this final expiration date, I must be a...
stackexchange/codereview
Most of what I'm writing is pretty quick and dirty as I'm crashing through a lot of stuff to learn. My variable/function/class names are most likely not efficient and I still need to get a lot of the PEP8 formatting down. That said, I put a quick Tic Tac Toe game together in Python. I'm going to add some decision logic...
stackexchange/codereview
I'd love thoughts on how to make this more elegant. I'm planning to add some additional functionality, but basically this is just my first pass at creating a pythonic Slack bot from scratch. You need Slack API token to run it. I am deploying to Heroku, so I have it looking for an environment variable called API_TOKEN ...
stackexchange/codereview
I have code that uses the brute force technique to find the message to a Caesar cipher. The program decrypts the message using different keys and then checks whether the resulting words are contained in a file called 'wordlist.txt'. if they are, it returns only that result. from collections import namedtuple Keycode = ...
stackexchange/codereview
I have a form code behind and it has what are called "Common Utilities". Basically the original author made a super class that is embedded into the main form code behind. What is the best way to refactor this? And what methods can stay in the main form? I think my issue is in each of these methods there are referen...
stackexchange/codereview
I have to calculate the configuration of hardware that uses the least number of capture cards based on the number of channels desired. The cards are available in 4, 8, and 16 channel varieties. It's important to note that the least number of cards is the first priority, and the second priority is using the cheaper (low...
stackexchange/codereview
I have been working on this code, which is the part of an economy system that handles the work command. This lets the user pick a role and if they have enough level then they will get it by updating a db. I know it's inefficient and I am unsure how to reduce the if count and keeping a cyclomatic complexity below 15. I ...
stackexchange/codereview
This is my first question here and I'd like to get some feedback. The program works but I'm not sure the classes I've used are right. First, a class to calculate the Body Mass Index from a double (kgs) and an integer (height in cm): //Data taken from https://codereview.stackexchange.com/questions/216933/java-swing-exer...
stackexchange/codereview
I've created a basic site with thumbnail images which when clicked open a modal type window to show a larger image with info related specifically to the image. It works as I would like. However, I'm trying to develop my limited JS skills and looking at the code, I think there is most probably an easier and cleaner (and...
stackexchange/codereview
I've made the following and have a few questions: Do I have some (big) mistakes in this approach? (bad practices, 'this code is trash'...) 1.1 If I do, can you suggest what to fix? Are appended element created in good way? Code in success function seems to be a little long. Any way to refactor? CSS code .no-displa...
stackexchange/codereview
I wrote this jQuery code as I could for a dropdown menu. But I'm sure there is a way to make this code shorter. $(document).ready(function() { $('#show-menu-1').on('click touch', openSubMenu); $('#close-menu-1').on('click touch', closeSubMenu); $(document).on('click touch', function(event) { if (!$...
stackexchange/codereview
I want to check if a record already exists in a database, and return true or false. If it exists, I want to update the update_at datetime field. The method touch_with_version from the paper_trail gem will do it. Which is better? def repeated?(unprocessed) occurrence = Occurrence.find_by(unprocessed: unprocessed)...
stackexchange/codereview
Over the past week, I've been working on a project that works as an interpreter of sorts for bytecodes in a custom language that would run in a "live" environment. It works, in a sense (I don't have a compiler or anything for it yet, just bytecodes for now and a file format, sorry! They are explained in the serializeOb...
stackexchange/codereview
I have written a very basic bandwidth usage monitor in C++/winpcap. I would like to get some feedback, regarding design choices, implementation, style, correctness. (Or anything else you care to mention for that matter). Win TaskManager schows 0% CPU usage and 1,7MB RAM, and the program runs and updates the files as ex...
stackexchange/codereview
This is the "Increasing Number problem", where we are looking for all numbers with \$n\$ digits where each digit is bigger than the digit before it. Or in Mathematical therms where: $$\mathit{IncreasingNumber} = c_n \times 10^n + c_{n-1} \times 10^{n-1} + \cdots + c_1 * 10 + c_0$$ and \$c_i < c_{i-1}\$. Examples: 1234...
stackexchange/codereview
I have this function const rank = (totalPoints, pointsRank) => { if (totalPoints <= pointsRank[0]) { return ({ rank: 1, pointsLeftForNextRank: (pointsRank[1] - totalPoints) }) } else if (totalPoints >= pointsRank[1] && totalPoints < pointsRank[2]) { return ({...
stackexchange/codereview
New to Neural Networks and before I move on to gradient descent I would like to make sure I have got basic idea right. (Sorry that the class is called perceptron I know that this isnt technically right, I adapted this code from and AND gate NN). This NN is made to learn the XOR function. #include <iostream> #include <...
stackexchange/codereview
a Temperature calss is given (not allowed to modify it): public class Temperature { private final LocalDate date; private final double temperature; private final String city; private final String country; // getters are available } There is a pre-implemented method called stream() with gives me a...
stackexchange/codereview
We have three integers: A, B, C where the first (i.e. the most significant) digit of C is the first digit of A, the second digit of C is the first digit of B, the third digit of C is the second digit of A, the fourth digit of C is the second digit of B etc. If one of the integers A and B runs out of digits, the rema...
stackexchange/codereview
Challenge: Return the length of the longest word in the provided sentence. I've made a solution that works but it is kinda bad since the time complexity is \$O(n \log n)\$ and it involves mutation. function findLongestWordLength(str) { let strSplit = str.split(" "); let wordLengthArray = []; for(let i = 0; i < ...
stackexchange/codereview
I have been working on a function which I call report. What it does is that whenever I call the report function. I can give it a payload of my dict with some data and as well as reason where I can have custom message or the exception errors of whatever can happened. For now I have created something simple where I creat...
stackexchange/codereview
I've got 17 currency fields on a form and need to do some calculations with their values. I wrote this method some time ago and have come back to try and refactor it to make it more efficient and/or more readable. Could I have some pointers please? Note: The variables appended with d are the decimals used to hold the f...
stackexchange/codereview
The code below takes 5-6 hours for a years worth of data (850,000 records). It takes much less time when running a single month. To start with is there anything glaringly obvious within this script which may account for the slowness. Are there any tests I can do to determine where the flaws are. I kind of find it off i...
stackexchange/codereview
I have a small project that requires a third-party module that's rarely updated (once every other year or so) and not maintained by any package management system. The context, here, is cognitive science & research, the third party module is for linking proprietary hardware to custom scripting, in the house project, pot...
stackexchange/codereview
I am working on a Rails 3 application, and am having some trouble with my user/edit view. In this application, Users can subscribe to Categories. Users and Categories have a has_and_belongs_to_many relationship through a join table (categories_users). In my user/edit view, I need to display a list of checkboxes for the...
stackexchange/codereview
I decided to try and make a code that can calculate the n-th term of any sequence (any sequence that only contains n^a, sequences like a^n and n! won't work) and calculate the next numbers of the sequence to further my understanding of Python, here it is: from math import factorial from fractions import Fraction class...
stackexchange/codereview
My purpose is to calculate the energy spectrum of three-dimensional turbulent flow from three velocity components. The calculation is too expensive. Therefore, I hope the calculation time can be reduced. The above code is a sample of calculating the energy spectrum. I expect to receive some suggestions on parallel comp...
stackexchange/codereview
I have a few custom exception classes that I created simply for the sake of having my own exception message: public class DivideByZeroException extends Exception { @Override public String toString() { return "ERROR: Expression cannot divide by 0"; } } I realize that this can be done by throwing ...
stackexchange/codereview
I am trying to speed up a function to return the longest common substring. The requirements: The function takes two strings of arbitrary length (although on average they will be less than 50 chars each) If two subsequences of the same length exist it can return either Speed is the primary concern This is what I have ...
stackexchange/codereview
I knocked this together in a few hours as I was just simply bored. I was going to add a namespace to this but decided there was no point. This is also available on Github All feedback is appreciated! <?php /** * This class will allow you to generate goo.gl links * @package Google * @subpackage Googl * @author...
stackexchange/codereview
For a website I'm working on, I had to get all the unique entries in an array and count their occurrence. It is possible a certain entry is only found once, but it can also be found 20 times. So I designed the following bit of code: for ($i = 0; $i < count($nodes); $i++) { for ($j = 0; $j < count($nodes[$i]); $j++)...
stackexchange/codereview
I am learning F# and implemented Conway's Game of Life as an exercise (There are also other implementations on CodeReview). I have tried to forget all my object-oriented background and practice "functional thinking". Any feedback is welcome, especially related to alternative (more functional) solutions. open System [<...
stackexchange/codereview
I've written a little clock implementation in Java Swing. It now seems to work flawlessly after having terrible Swing specific timing problems. Please indicate if this is the way to draw the clock and if the passive / active combination (i.e. drawing from timer and drawing from e.g. paintComponent) has been programmed ...
stackexchange/codereview
I tried to make a function able to compute the binary sum. Binary numbers are passed as list composed of 1 and 0, like [1,1,0,1], [0,0,1], etc. It seems to work. I tried to improve the code, but I don't think this is the best way to make it work. How can I improve this? def check(value): if value%2 == 0: #check if...
stackexchange/codereview
The task is taken from leetcode Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Example 1: Input: ["abcd","dcba","lls","s","sssll"] Output: [[0,1],[1,0],[3,2],[2,4]] Explanation: The pa...
stackexchange/codereview
Write a bash script for an ABC organization fulfilling the following requirements: Takes an Employee's Name, designation, age, years of service and salary, extra working hours as an input. Calculates remaining years of service. An Employee retires at the age of 60. Check if the Employee is valid for salary appraisal....
stackexchange/codereview
This is my first real attempt and playing with GoLang In my project, I will be contacting multiple carriers to get their "estimate". I have carriera at the moment, but there will be carrierb etc too. As I will be wanting to use the same struct from the package "estimate", I decided that I should share the struct in one...
stackexchange/codereview
Description This javascript code uses tmi.js to listen for chat messages in a Twitch chat and perform certain actions depending on their content. In the sample code provided, if the message starts with !add, !taskadd, !addtask or !taska it will call the addTask command handler which tries to add the task to a list of t...
stackexchange/codereview
The following function takes the probability of a person aged 100+i dying in the next year (conditional on them being alive at the start of the year) and returns the probability that they will be alive after j years (for 0 < j < 21): import pandas as pd def prob_in_force(): # i-th entry of qx_curve gives the pro...
stackexchange/codereview
I hope this question is okay to ask on Code Review; this is a little function I wrote in Python 2.7.12 that checks if a number is a palindrome. It works fine but I'd like to know if there is a purely mathematical way to do it without using string conversion. Here is the function: def is_palindrome(n): forward = str...
stackexchange/codereview
I am doing a code wars problem and so far I have managed to loop through a collection to find the "winner" (defined by the String that appears more than collection.size()/2). However, my code times out and isn't efficient enough. How can I make this more efficient? import java.util.List; public class BallotsCounter1 {...
stackexchange/codereview
I set up an error handler class to handle all server errors, I know there are already quite a few out there, but I like creating my own for better learning and understanding of how things work. I am currently using this in a framework I am working on (again, for learning purposes), and its working as it should. With th...
stackexchange/codereview
Let's say the model for a razor view has the following name: Model.Receipt and there are a couple of places where you do @Model.Receipt.ID @Model.Receipt.BillToCustomer etc. but you decide to shorten it by declaring the following code block: @{ var receipt = Model.Receipt;} and now you use this receipt variable instead...
stackexchange/codereview
I'm going to write a Huffman Coding implementation, and decided to write from scratch a priority queue to help out. I've never written a priority queue before, in any language, so this was interesting. After mulling over the design for a bit, I finally settled on a linked list design. The queue is essentially just a li...
stackexchange/codereview
I wanted to implement a generic merge sort algorithm using the same interface as std::sort(). The interface takes first and last iterators to a range of elements in any container. The user has the option to provide a custom function that compares two elements; if none is provided, the operator < is used by default. I h...
stackexchange/codereview
How can I vectorize this code snippet and eliminate this double loop? Even with "only" 1001 elements in a this takes almost 30s. a = np.linspace(-.5, .5, 1001) S = np.zeros((a.size, a.size)) # east, north and tp are np.arrays of equal length for l, sy in enumerate(a): for k, sx in enumerate(a): S[l,k] ...
stackexchange/codereview
By default, mouse wheel scrolling in Java Swing behaves differently than in web browsers. In Swing, when you have an inner scrollable component and an outer scrollable component, the mouse wheel events are only ever dispatched to the inner component. This means that when you are in a text area inside a larger panel, yo...
stackexchange/codereview
the following tutorial uses an interceptor to show/hide a loading bar: https://www.freakyjolly.com/http-global-loader-progress-bar-using-angular-interceptors/ export class LoaderInterceptor implements HttpInterceptor { private requests: HttpRequest<any>[] = []; constructor(private loaderService: LoaderService) { }...
stackexchange/codereview
I've Implemented a Serialization Utility which Serializes/DeSerializes a class, along with writing JUnit Test Cases for the same. Please Review the code and Suggest me how to improve it. Particularly in generics as I've not written much code with Generics in java. SerializableEmployee.java - Class to be Serialized pu...
stackexchange/codereview
I have two tables (parent-child model): Loans & Transactions. Each Loan row has multiple Transaction rows. I want to select all rows from Loans together with most recent row from Transactions. Here is my select to achieve this. SELECT L.*, T.* FROM Loans L CROSS APPLY ( SELECT TOP 1 * FROM Transactions AS T ...
stackexchange/codereview
Here's my code - I've a lot to learn so any advice, tips etc would be welcome! A few notes: I'm using OpenCV and numpy for other features in this code, not just for this snippet. The main readon for making frameDelay a class was as a way of passing another variable into the on_press function The weird infinite while lo...
stackexchange/codereview
I was having a chat with a friend about data structures (as you do), and that, and his love of portmanteaus meant that he came up with a Quack - A queue and a stack, stuck together in the dumbest way, as it just gives you a tuple of the front and back items. I thought that it might be at least possibly useful if it was...
stackexchange/codereview
I'm currently trying to improve my C understanding. Would you mind telling me if there are good/bad things that I did here? (I implemented a function to reverse a string in place). For example things I feel uncomfortable with: I forwarded pointers to a buffer so that I could loosen the coupling of different parts of t...
stackexchange/codereview
I wanted an opinion about an idea I had regarding the use of config.properties, static classes and the use of reflection. I have to load some preferences at application startup, for that I will be using config.properties. Certain properties within config.properties will be changed during various points in the program. ...
stackexchange/codereview
I will be creating a web service as part of a group project for university, which will be developed using Java within the Eclipse IDE. Having no prior experience using web services, I managed to find some tutorials that were useful, but struggled to find enough database code examples which suited my needs (though, per...
stackexchange/codereview
I have a userform with around 20 controls in that can be inputted. Some are textboxes some are comboboxes etc. The user fills in these controls and then hits save. When save is pressed, the code finds the relevant row number (based on the task number generated in userform e.g. 1.04 will find 1.03 and add row below.) H...
stackexchange/codereview
I have the following VB macro, which works fine, but the problem is one section of the macro which is this for loop (in bold), which is reading the cell value in the selection, and then looking in all sheets in the WB to find the match, and then insert that row into that sheet and then exiting and going to next cell. T...
stackexchange/codereview
I have solved one problem on Codeforces and I guess the output is quite correct. However, it is slow for input in range of thousands. Since, I am learning Python now, it would be great help if one could help me optimise this code. Any notes, tips or suggestions on the sidelines are always welcome. The question is a pra...
stackexchange/codereview
I am new to the code review area of Stack and welcome all positive criticism. I would be grateful if someone could review my code below and let me know where I can improve or have gone wrong that I cannot see. The only thing that I have left is to write the delete and would appreciate help in doing this is possible t...
stackexchange/codereview
The game I am working with is a block game. It generates terrain and then allows you to freely mine and place blocks as you wish (sound familiar Cx) BUT! there is a problem. I have a code that snaps the mouse to a 32x32 grid: mse=pygame.mouse.get_pos() mse=(((mse[0])/32)*32,((mse[1])/32)*32) cursrect.x,cursrect.y=mse s...
stackexchange/codereview
Looking for any feedback to improve practices on the following logic, and I have removed large chunks of documentation to reduce noise. I feel the areas that could expect heavy criticism are the win/tie condition checking. Main.cpp #include "Board.h" int main() { //initialize board Board gameboard; for (i...
stackexchange/codereview
My AngularJs app is currently working fine. I'm working on modularity, refining my code design, and making it more readable. I have a app.js file that contains the module, the run block, and configuration definitions. By default Ionic uses the Ui-Router for route definition, so the routes are defined in my config block...
stackexchange/codereview
I have written two code pieces to check if a given string is a palindrome: public static bool FirstMethod(string str) { int i = 0; int j = str.Length - 1; while (i<j) { if (str[i] != str[j]) return false; i++; j--; } return true; } public static bool Sec...
stackexchange/codereview