instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
All help welcomed!
I posted a big chunk of code here - but feel free to review only a small section. I will use answers to improve this deployed open source software.
About the code
This code works. But can be improved in code quality. Feedback is highly welcomed!
codespell, ktlint, Android Studio validator were alread... | stackexchange/codereview |
Let's say I have an abstract class Character that have fields health and maxHealth. maxHealth differs between subclasses. However, the first way I implemented it the health is always initialized as equals to maxHealth.
public abstract class Character {
protected Vector position;
protected int health;
protected i... | stackexchange/codereview |
I have ended up with the following code in order to filter out some bad elements from a std::vector:
#include <iostream>
#include <vector>
#include <algorithm>
typedef struct mystruct {
int id;
std::string name;
};
int main()
{
std::vector<mystruct> all_items = {{151, "test1"}, {154, "test4"}, {15... | stackexchange/codereview |
Hi I am pretty new to programming and I would like you to give me some feedback about my code, how does it look, what could be better. Thank you.
A = []
B = []
C = []
PegDict = {'A': A,'B': B,'C': C} #Would it be better to use a two dimensional array?
discs = int(input("Podaj ilość dysków: "))
for i in range(discs, 0... | stackexchange/codereview |
I have these relevant tables in an MVC website:
Server
ServerPlayer
ServerPlayerChat
Servers have serverPlayers and ServerPlayers have ServerPlayerChats. Simple enough and expectable.
I have a feeling my code could be drastically condensed (particularly the GetServerPlayer method) and that the GetServerPlayer method ... | stackexchange/codereview |
On my job I had the task to process multiple excel sheets, so I tried to make a generic component to make the conversion between the cell values and a java object type.
The first thing that came to mind was a generic interface that will handle the processing of a particular column:
public interface ExcelColumnProcessor... | stackexchange/codereview |
I have been trying to figure out how to meet space and time complexity requirements for the following leet code question. I have come up with two versions, one that meets the time requirements and another that meets the space requirements. Both versions fail on the same test case (the last test case shown below). Can a... | stackexchange/codereview |
I am participating in a funny crypto contest with my friends. This time, we raised the bar quite a bit.
The code below is my take for the constraints we set.
Note that on my machine, the code works perfectly.
Constraints:
The message M is made of random numbers
M1 is 200 bytes at most.
Packet P is 1024 bytes long.
At ... | stackexchange/codereview |
There is a site with posts that have tags. The site has a search for these tags, that is, you enter words / letters separated by a space and tags are displayed for you by matches. These tags can be selected and double-clicked to disable. When you enter words in the search bar, a query is sent to the database and a resp... | stackexchange/codereview |
I am writing some code to search my database and show results. Is the below code ok and safe enough? new to PHP and Mysqli so really appreciate any help that I can get on this subject. Thanks
<?php
$conn = mysqli_connect("localhost", "root", "", "tutorial");
if(mysqli_connect_errno()){
echo "Failed to... | stackexchange/codereview |
I am reading a text file that has some name inconsistencies. For example I have names like:
MILLERS, WALTER M IV
DUPONTE, THOMAS B. II
HARDIWAY, GRANT U. SR.
GUIDRY, PAUL JOHN
As you can see I can split the name by first name and last name however the suffixes are placed incorrectly. Ideally the names should be:
WALTE... | stackexchange/codereview |
I'm currently trying to display a list of movies with this pill-like elements. The code below works but I guess there is a better way or a way to use elements from the twitter Bootstrap. It also bothers me that the date in the brackets isn't centered with the heading.
Please give me feedback how you like my code. I'm a... | stackexchange/codereview |
I currently this code working, but its performance is very poor — 1.45 seconds seems a bit too much for a simple recursive if statement that only checks attribute values.
def _check_delete_status(self, obj) -> bool:
obj_name = obj._sa_class_manager.class_.__name__
self.visited.append(obj_name)
if geta... | stackexchange/codereview |
I have the following code to load an enumeration into a bound combo box, but am not quite happy with it.
I would prefer to store the actual enum value in the combo box and bind directly to it.
However, I can't quite figure out how to do so.
public enum HemEnum
{
HemNone = -1,
Hemsew = 0,
H... | stackexchange/codereview |
In the standard library, there are no algorithms for element updates. This makes it unsuitable as a queue for a Dijkstra's algorithm, for example. Thus I implemented generic heap update functions with the interface in line with the standard library.
Warning: the standard does not specify implementation detail of a heap... | stackexchange/codereview |
This code is from my blog project. This project is almost done. This is working well.
I can create new posts and update and display all saved posts.
const express = require("express");
const router = express.Router();
const Article = require("../models/BlogPost.model");
router.get("/", (req, res) => {
res.redirect... | stackexchange/codereview |
Given a set of ranges with lower bound and upper bound, I need to combine these ranges to produce minimum number of ranges which will cover all the values in the original set and nothing else.
Example 1:
Input:
[100, 200], [120-170],[210 - 230]
Output:
[100-200], [210-230]
Example 2:
Input:
[100, 200], [120-210],[21... | stackexchange/codereview |
I've been teaching myself python and I decided to make a Simon copy. Please let me know if there's anything notable that I should improve on. I understand my use of globals in some functions is considered poor, but I couldn't think of any other way to write them. Thank you for reading
import pygame
from random import r... | stackexchange/codereview |
Working my way through the second edition of the Rust Programming Language and did the exercise at the end of ch 8:
Using a hash map and vectors, create a text interface to allow a user
to add employee names to a department in the company. For example,
“Add Sally to Engineering” or “Add Amir to Sales”. Then let th... | stackexchange/codereview |
Already many days I'm documenting about the SQL Injection. I was wondering if the code I wrote is vulnerable in some of its parts.
<?php
if($_POST['nameone'] AND $_POST['nametwo'])
{
$conn = new PDO("mysql:host=localhost;dbname=dbname;charset=utf8", 'dbuser', 'dbpass');
mysql_query('SET NAMES utf8');
$conn->se... | stackexchange/codereview |
Sorry if it's a bit long... I tried to make it modular with methods, not sure if I overcomplicated it
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Learning
{
class Program
{
public static decimal principal;
public ... | stackexchange/codereview |
There is a function which is getting maximum values of each period-length interval in array.
I am trying to optimize this function by performance.
void maximumsT(const std::vector<double> &src, size_t period, std::vector<double> &dst)
{
dst.resize(src.size());
for (size_t i = 1; i <= period; ++i) {
d... | stackexchange/codereview |
I have written the following class used to get the metadata out of an internet radio station. It takes a Node Stream and transforms it to grab the metadata out of the mp3 stream and then removes the metadata bytes from the stream so it isn't audibly heard. If you need to know the Shoutcast metadata protocol, see here: ... | stackexchange/codereview |
I am creating a program to show NRRDs which are a format of medical images. In addition it loads a gallery of thumbnails, where each thumbnail has a link to change the selected NRRD. Plus there is a list on the bottom left with a list of the different bones inside the current NRRD.
Here is an explanation using the UI i... | stackexchange/codereview |
I want to build the markup below by iterating on an array of objects. The structure of the object is also listed below. I need some tips on how to make it clean.
Markup I want to build:
<!--the markup I want to build-->
<div class="pull-left col-xs-4">
<div class="thumbnail">
<div class="caption">
... | stackexchange/codereview |
This is an ordinary data processing task: read a list of dates and amounts (for example, deposits and withdrawals from a bank account) and report the date on which the lowest balance was recorded and what that balance was. While I do get the correct answer--always a virtue--with the code below, I can't help thinking th... | stackexchange/codereview |
I have a RadioStation class file and a view controller where I create two station objects based on this class, one for FM and one for AM.
I created both of these station objects from within the same required init method. I'm not sure this was this the best way to do this, for example can you imagine if you wanted 8 su... | stackexchange/codereview |
See Serializing (nested) data structures in a human-readable format for more details.
This is the latest version, I have fixed all bugs and now this piece of code works completely as intended.
And I have added many more test cases. So far all tests are successful. I think I can't find an edge case that will cause the c... | stackexchange/codereview |
I'm trying to come up with an "elegant" way of calculating Fibonacci for number in Rust, using recursion and memoization (self-imposed requirements).
This is what I have so far:
fn fib(n: usize, memo: &mut [Option<usize>]) -> usize {
memo[n].map(|v| v).unwrap_or_else(|| {
let result = {
if n > 1... | stackexchange/codereview |
I made a C# console math project where the user answers addition, subtraction, multiplication, division, power or square-root questions based on the difficulty they choose!
However, I am struggling to refactor one part of my code.
Here is my code:
using System;
using System.Collections.Generic;
namespace mathstester
{... | stackexchange/codereview |
Out of boredom one day I decided to make a game in pygame. I think it turned out fine, but am absolutely sure that it can be improved. How so?
import pygame, random, time, pyquark, pygame.freetype
from configparser import ConfigParser
pygame.freetype.init()
config_object = ConfigParser()
config_object.read("config.in... | stackexchange/codereview |
I would like to obtain some feedback on a simple code I wrote to
implement an easy and hopefully fast way to generate a large number of floats
with CURAND and use them one at a time.
This is achieved by switching between two large buffers that get generated and copied onto host memory asyncronously while the other buff... | stackexchange/codereview |
I had this S3Helper class before such that, every time I called a function to any of its methods (which I haven't shown here, but which do things like upload files to s3 or get temporary s3 links), it called the getClient() method and it would make a new client every time.
Now I don't know about the performance hit on ... | stackexchange/codereview |
This is self-explaining example with usage in doctests (it's not that fast as implementation with dict key-lookups, but it's a lot more readable, and don't require callables and lambdas):
class Switch(object):
"""
Switch, simple implementation of switch statement for Python, eg:
>>> def test_switch(val):
... | stackexchange/codereview |
I need to get values from a Map by Adapter position i get from a RecyclerView.
As you can see each time i click on an Album Art i create a new array of album objects.
final Album[] albums = new Album[albumMap.size()];
for (Map.Entry<Integer,Album> e : albumMap.entrySet()){
albums[i++] = e.getValue();
}
Th... | stackexchange/codereview |
I'm reading "Modern C++ Design"(A. Alexandrescu, 2002) and practicing basic TMP in chapter 3. Typelists. Since the book is quite dated, I revised example codes in C++17-esque manner.
Feel free to comment anything!
#include <cstddef>
#include <iostream>
#include <utility>
#include <type_traits>
// defining a typelist
... | stackexchange/codereview |
As part of my ongoing development of a 3D game engine based on PyOpenGL, I am trying to do some refactoring to make working with textures and framebuffers as painless as possible. I feel this refactoring is needed so that my texture class can handle all of these (and more!) use-cases seamlessly:
Loading in image data ... | stackexchange/codereview |
Project Euler Problem 35 asks:
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
How many circular primes are there below one million?
import itertools
import math
import time
prime_list = []
#num = 14
count = 0
limit = 100000
time.clock()
def ... | stackexchange/codereview |
I have previously attempted to write a object-cache that I use in co-junction with Redis keeping a persistent data-model. Old post can be read here Cached-object Store c# with Redis client for persistent storage
Not focusing on Redis it's the Object-cache that is the important portion, one of the questions i previousl... | stackexchange/codereview |
I have a class Address, a class AddressTest and I am trying to write unit tests for its constructors and getter setters.
Address:
/**
* The bean Address.
*
* @author Sandeep Chatterjee
* @since 24/8/2015
*/
class Address {
private BigInteger addressId;
private String name;
private String address;
... | stackexchange/codereview |
I have a form, I need to send untraslated values, but as well, I need to get translated ones from Vue to write them down in page.
For now, I ended up creating a 'shadow' property and changing it via the watch function. Note that I'm referencing the SELECT via the custom ref prop and Vue.$refs. So:
<select name="screw[t... | stackexchange/codereview |
I have written the following control which allows loading a GIF from embedded resource, file, or raw Image. It allows for more granular control over the direction and frames per second of animated image types.
The problem I face, is it is quite laggy during the frame switching (unlike the PictureBox control which does... | stackexchange/codereview |
I've written a program that counts the number of inversions using a Divide and Conquer algorithm, written in C++11.
#include <iostream>
#include <tuple>
#include <vector>
using IntVec = std::vector<int>;
std::tuple<IntVec, long long> count_inv(IntVec xs);
std::tuple<IntVec, long long> count_split_inv(IntVec xs, IntVe... | stackexchange/codereview |
In the C# Player's Guide book, one of the challenges was to make the game Game of Life in the console.
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
namespace GameOfLife
{
class Program
{
... | stackexchange/codereview |
I recently finished a simple Blackjack game that I made to get better at C#. I am wondering how I can better organize or simplify my code. There are 4 files:
Program.cs
/* Blackjack Game Copyright (C) 2018
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Publi... | stackexchange/codereview |
I'm using BFS to see if a given path exists in a graph:
static class Node{
int data;
Node next;
public Node(int data){
this.data = data;
}
}
//Adjency List to store the reference to head of each Node/Vertice
static class AdjList implements Iterable<Integer>{
Node head;
public void add(... | stackexchange/codereview |
I am working on a project where the hotspot is some code that is supposed to find an offset, such that the squared differences between a reference vector and a given vector becomes minimal. The core function is this:
#include <vector>
#include <map>
typedef std::vector<double> vect_d
double sqDiffSum(const vect_d& ref... | stackexchange/codereview |
I have made a lot of changes to the code over the course of the evening, but after making most of the suggested changes, the variable that the answer is returning is showing up as "undefined". Could someone please help me find my errors in this code? I have tried and have not been able to find the errors due to my limi... | stackexchange/codereview |
The following Awk code was created in order to verify if free memory from the top command is less than 20% of the total.
I've noticed that I actually do not need the top -n1 | grep Mem |, because the FREEM and TOTALM parameters are inside the third awk line.
But on the other hand, I could not run the Awk as:
awk -v FR... | stackexchange/codereview |
Could someone please review my code for performance(any other suggestions are welcome) which converts flat data list coming from database to a tree?
Interface for db entity class
public interface IDbEntityNode
{
int Id { get; set; }
int ParentId { get; set; }
string Data { get; set; }
}
Example of db E... | stackexchange/codereview |
I've started learning C++ using Microsoft Visual Studio. I'm decided to create a simple GUI program that creates a "snowflake" wherever the user clicks on the screen. Seeing as how this is my first C++ program, I would greatly appreciate feedback on any aspect of my code.
snowflakes.cpp
// Includes //
#include <SFML/Gr... | stackexchange/codereview |
I have two functions now with very similar functionality, and would like to merge them into one more generic function. The only difference between those two functions is that one handles json input file and the other xml input file.
I could use if statements to achieve this, but I find it cumbersome, other suggestions ... | stackexchange/codereview |
I created a test-server for RESTful integration-tests that I call TeapotServer because I like the status-code 418 that the server returns when the client makes a mistake and sends it an invalid request.
Example
Its API is similar to JustMock. I first tell it to what API I want to test, how the request should look like,... | stackexchange/codereview |
In the same vein as the (+++) function on JoinList and indexJ on JoinList, I implemented dropJ to drop elements from a JoinList.
Here's my attempt:
dropJ ::(Sized b, Monoid b) => Int -> JoinList b a -> JoinList b a
dropJ _ Empty = Empty
dropJ i jl | i <= 0 = jl
dropJ _ (Single _ _) = Empty
dropJ i (A... | stackexchange/codereview |
Context: I've been learning Python for a few months and I'm able to write codes which do work, but they normally look very ugly and contain a lot of unnecessary code. But I normally struggle to find better ways to do things because of my limited knowledge.
I would like some advice on what I can improve on the code belo... | stackexchange/codereview |
I want to assign the row of a matrix the return value of a function, but the only way I can figure out how to do this is with a for-loop. I'm assuming this is bad and vectorization would be better.
I'm trying to implement the first principle of the Neural Engineering Framework for a class. The function of the code is t... | stackexchange/codereview |
I'm unsure of how to Name and clearly distinguish between methods that deals with comparisons.
I know of the following two established concepts:
.Equals: A method to see if two objects refer to the same instance
.Compare: A method often used when determining sort order among objects
But what to name a method when you... | stackexchange/codereview |
I'm working with Codeigniter most of the time (about one and a half year now) and I came across many form validation code flows. Here are my best two selected shots which I created for a client recently.
I only care about model and controller, views do not need to be reviewed.
Features of both code:
Validation for for... | stackexchange/codereview |
I wanted to have a factory-method, but without the if statements that are often seen in examples of this pattern. So I came up with this, and would like to know:
is this a right approach, should there be any impovements?
some things I considered:
It is using Enum because that makes it possible to iterate or list the p... | stackexchange/codereview |
I am working on setting up automated build and deploy jobs in jenkins for a php based project. I would like some feedback on my Jenkinsfile. Specifically regarding the parallelization, the (in my opinion) huge usage of sh and the best practices regarding the site configuration (would a bunch of included files be better... | stackexchange/codereview |
I made this generic class which helps me reading values from user defaults. Besides it abusing several UserDefaults... what do you see? Can I make some instances share a reference?
class DefaultValue<V> {
var userDefaults = UserDefaults()
let name : String
let defValue : V
init(name: String, defValue: ... | stackexchange/codereview |
I have extension methods to encapsulate query conditions, however I have to separate IQueryable and IEnumerable. Is there any way I can reduce the redundancy and still not lose the performance benefit of IQueryable?
public static class PAYTRACK_PARTNER_Extension
{
public static IQueryable<PAYTRACK_PARTNER> WhereIn... | stackexchange/codereview |
I'm writing a command-line utility and I need to find commands (and parameters) by name. The name can either be a full name like save or a shortcut s.
I thought I use a dictionary with an ISet key and a custom comparer. At first I had a list and searched for the name with LINQ but I'd like to have something more conven... | stackexchange/codereview |
I came across this problem in a career cup. Below I have the questions and the Java solution. I was wondering if anyone could scrutinize my code and tell me if there are any improvements, or better coding practices that I should know, as I am working on being able to produce proficient code.
Problem statement:
Write a... | stackexchange/codereview |
I am developing an Android app. Due to my low experience and the requirement for network operation, my class uses a lot of AsyncTask instances and it grew quite large. I'd like to know how I can split this in to different classes, and generally make it better (not required).
I am really confused in cases where I have t... | stackexchange/codereview |
This is my implementation of itoa() (Integer to Alpha), which converts an integer to a string. Memory management and optimization is important. The caller is not responsible for allocation of the string.
The caller is responsible for freeing the string, as my implementation does not allow to call free(). The function h... | stackexchange/codereview |
Here is the new & improved Rubberduck 2.x entry point class, based on MZ-Tools 8.0's Connect.VBA implementation of the IDTExtensibility2 COM interface, graciously shared to the Rubberduck team by Mr. MZ-Tools himself, Carlos Quintero.
The modifications made are not yet merged into the project's main repository at the t... | stackexchange/codereview |
This is similar to the program in the book Hacking: The Art of Exploitation. It is rewritten to fit my needs.
There are two files, takenote and readnote. To write a note simply use takenote with your note as a command line argument: ./takenote "Buy eggs". The note gets added to the file /tmp/notes with User ID (non rea... | stackexchange/codereview |
I would like to re-render my WPF chart control when data source is changed. My minimum requirement for a data source is IEnumerable<Point> but it could be also ObservableCollection<Point> or BindingList<Point>, so collection change notifications are sometimes becoming available.
Chart Serie class (simplified):
class Se... | stackexchange/codereview |
I changed my mind. I don't want to implement 200-some Node classes. Instead, I'll be working directly with the ANTLR generated classes, to implement the Rubberduck code inspections, unit test method discovery, the "Code Explorer" tree view, and everything else Rubberduck might need a parse tree for.
The Node derived cl... | stackexchange/codereview |
I want to implement a book repository using a map where books can be added, removed and updated. Books in this repository should be accessed by their ISBN which is an object property. The books should not be edited from the outside of the repository, because if a book’s ISBN is changed from the outside, the ISBN used a... | stackexchange/codereview |
I wrote my own implementation of generic hash table. I’m using linked list to resolve collision problem.
I want to share my code with you and get your opinion about it, and if there are any advice or optimisations that you can point to.
HashTable.h file
/**
* @author Abdelhakim RAFIK
* @version v1.0.1
* @li... | stackexchange/codereview |
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?
public class SmallestMultiple {
public static void main(String[] args) {
int smallest = 0;
fo... | stackexchange/codereview |
I am going through the CodingBat exercises for Java. I have just completed this one:
Given two strings, base and remove, return a version of the base string where all instances of the remove string have been removed (not case sensitive). You may assume that the remove string is length 1 or more. Remove only non-overla... | stackexchange/codereview |
I am trying to solve below problem to improve my skill. I would appreciate it if someone improve my code in a better way.
Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded. For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka',... | stackexchange/codereview |
I've written this password-keeper application to keep my passwords safe in one place. From something over few lines it grew to almost 200 lines of code. I would greatly appreciate it if someone could review it and provide me with feedback on whether there are any potential improvements, optimizations, or simplification... | stackexchange/codereview |
What I'm trying to accomplish here is to pull a table of open employment positions with AJAX, filter out the garbage code that comes with it, put each <tr> from the response into its correct category <div> according to the type of position.
The trick is that there are no ids or class names on the <tr> being pulled mak... | stackexchange/codereview |
I inherited this code and have to fix it. It does work and I know I can refactor the code using If Not Intersect(Target, Me.Range()) Is Nothing Then syntax. I am wondering if using a function to pass the cell references in this case would be best, but im not really familiar on working with functions yet and would lik... | stackexchange/codereview |
I created a function that rewrites file names according to the available space on screen:
@{
var index = 0;
foreach (var item in Model)
{
<div class="gallery-item">
<a href="@item.Uri" title="Click to open file" target="_blank" style="display:block; width: 100%;">
var id = "filename_" + ++... | stackexchange/codereview |
Suppose I want to find the index of the maximal value of a given sequence. In Matlab, this is:
[value, index] = max(x)
In Python, I would abstract the following pattern:
def find_best_element_index(elements, is_better):
best_so_far = elements[0]
best_so_far_index = 0
for (index, element) in enumerate(eleme... | stackexchange/codereview |
I wrote a function that finds the sum of all numeric palindromes lesser than N.
const sumOfPalindromes = (n) => {
let x = 0;
for (let i = 0; i <= n; i++) {
x += i == (''+i).split('').reverse().join('') ? i : 0;
}
return x;
}
console.log(sumOfPalindromes(10000));
console.log(sumOfPalindromes(24)... | stackexchange/codereview |
I wrote this to scrape album review data from AOTY into a spreadsheet. Check it out and let me know what I could've done better.
Option Explicit
Const classAlbum As String = "listLargeTitle"
Const classScore As String = "listScoreContainer"
Const classRating As String = "listScoreValueContainer"
Const classReview As S... | stackexchange/codereview |
public struct DateRange : IEquatable<DateRange>, IComparable<DateRange>
{
private readonly DateTime _min;
private readonly DateTime _max;
public DateRange(DateTime min, DateTime max)
{
if (min.CompareTo(max) > 0)
throw new ArgumentOutOfRangeException("max", "Cannot be less than min.... | stackexchange/codereview |
I have a page with multiple menus. Once I hit a certain window width, I use CSS and jQuery to turn them into accordions. I also check the screen size when resizing so the accordions don't stay hidden if the user resizes the window. Since I have two window widths I need to adjust for, I am using two click events to open... | stackexchange/codereview |
Overview
I've just written a package in Python (which I've named sibstructures) whose purpose is to assist staff in managing a coldstore, which is a warehouse-sized refrigerator holding (in this case) boxes of potatoes.
The code below is one file taken from that package, the file which defines the centrepiece Coldstore... | stackexchange/codereview |
I wrote a Java FX application that translates binary to and from String and numbers in Java. Whenever the program is translating large amounts of text to binary it takes a very long time, and leaves the application unresponsive. Could a more efficient algorithm be used to speed up the process?
// Turns binary into... | stackexchange/codereview |
After hours of working, I've finally finished my first C log parsing program! (previously was a bash script, now it is C).
Although I think I've gotten most everything, I was just wondering if you saw any possible buffer/memory overflow dangers in the coding?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#... | stackexchange/codereview |
I need some constructive feedback for the working OOPs project which I created to introduce to Object Oriented Programming in a class. Hence is for beginners, I did not include interfaces or abstract functions nor singleton or factories. Can you give me some feedback on the code style, some possible anti patterns? Than... | stackexchange/codereview |
I'm creating a MUD and am running into some design issues regarding Items.
Items are stored in an ItemDatabase after being read from a JSON file.
template <typename ItemType>
static void load(std::string const& filename)
{
PropertyTree propertyTree;
boost::property_tree::read_json(filename, propertyTree);
... | stackexchange/codereview |
In this code, I generate the coordinates of a tube made of multiple rings. Finally, I write those x,y,z coordinates in a .csv file. I want to simplify this code (maybe using a for loop?).
import numpy as np
import matplotlib.pyplot as plt
bLength=1.6
numPoints=10
radius = bLength*numPoints / (2 * np.pi)
theta = np.lin... | stackexchange/codereview |
I'm currently learning haskell, and I wanted a simple project to get started. This project uses the JuicyPixels package to handle image reading. The logic of the image to ascii art algorithm is quite simple:
quantize the image in a number of bins equal to the number of ASCII character we want to use
map each pixel to ... | stackexchange/codereview |
As stated in the javadoc below, this is intended for monitoring and debugging. I've found it especially useful for figuring out which tasks got stuck and prevented clean terminations of my Executors.
I've run some simple benchmarks for TaskTrackingThreadPoolExecutor (see below) and performance penalty is up to 1.15x fo... | stackexchange/codereview |
I've been struggling with python OOP. I've gone through the basics but I'm struggling with implementing them. So I've decided to create something small everyday while in quarantine to get more comfortable with OOP.
My code simulates a simple coffee machine that makes 4 types of coffee.
This is the first one. What do y... | stackexchange/codereview |
Reaserching BouncyCastle for C# is not for the faint of heart. After navigating an ocean of Java dead ends, I have arrived at the following code.
I believe it's very useful for someone who wants to create these files in C# to use it anywhere.
It basically generates the 3 files every webdev who uses NGINX http server wo... | stackexchange/codereview |
I have created a simple Employee program and I am looking for a code review.
I want to make sure my use of concepts such as double-underscore methods and @property annotations are correct. I am also looking for feedback on my methodology.
Please feel free to be critical of each aspect of the program:
import time;
#H... | stackexchange/codereview |
This is my Breadth First Search implementation in Python 3 that assumes cycles and finds and prints path from start to goal.
Some background - Recently I've been preparing for interviews and am really focussing on writing clear and efficient code, rather than just hacking something up like I used to do.
This is another... | stackexchange/codereview |
The code below is a attempt to create a persistent login cookie. I am an amateur and not professional so this is the first attempt to have secure remember me cookie. Now I want you guys to review two things:
I am trying to create a system like best way to implement remember me but I am not sure if I have done the same... | stackexchange/codereview |
I do a lot of copying excel vba code related to classic ADO from workbook to workbook, so I've decided to add the code to a Class Module in a single utility workbook and then in all other books just reference the utility book and use instances of the ADO wrapper class.
The class module is called clDataAccess
I would li... | stackexchange/codereview |
I would like to be specific in parameter types or write something like this:
Test test = (Json<Test>)"{\"age\": 46}";
Where:
public class Test
{
public int Age { get; set; }
}
My helper is:
public struct Json<T>
{
public static implicit operator string(Json<T> json) => json.JObject.ToString();
public st... | stackexchange/codereview |
I had to implement a parser according to a given grammar as part of a school project. However, only the program execution was graded and I want to know if my code adheres to best practices. I would really appreciate it if you could give me pointers on how to improve my code.
Search conditions are of the form: a + b < 1... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.