instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I have been working with C# for quite some time but relatively new to the concepts of lambdas and Linq. I was working with a Linq To SQL example and trying to write a generic solution for executing a search against a collection of entities (eg. list of Customer objects) where the search parameter will be specified by p... | stackexchange/codereview |
I use this Timer function quite a bit lately for all sorts of stuff,
and would appreciate if someone could review/analyze/criticize/verify
and, of course, suggest things I can do to optimize it for high
frequency execution (mainly animation).
My goal was to replicate ActionScript's counterpart (Timer class) and its usa... | stackexchange/codereview |
I have a below method in Java 8 which checks for message pattern and finds the line number from the message.
private LawfirmInvoice getInvoiceForErrormessage(InvoiceParcel parcel, String message) {
if (parcel.getInvoices() != null) {
if (parcel.getInvoices().size() == 1)
return parcel.getInvoic... | stackexchange/codereview |
I was wondering if someone could take some time to look over my portfolio script and see let me know if it's secure enough to be uploaded live and connected to my database. My previous mySQL script was VERY insecure...
The Database Connection:
public function __construct($server, $databaseName, $username, $passwor... | stackexchange/codereview |
Here is my code. It works fine but I need to make the code more efficient.
def o(s):
l=len(s)
return len(set([a+b+c
for a in s for b in s for c in s])
)==l*(l+1)*(l+2)//6
M=int(input())
N=3**M
i=1
s=M*[i]
while i:
if s[i]-N:
s[i]=s[i]+1
if o(s[:i+1]):
... | stackexchange/codereview |
I am aware of it being frowned upon to do something like write C# in JavaScript. (see this if you don't know what I'm talking about)
But as a judgement call, I think we could stand to have a relatively simple check for values that are null or empty, so I'm looking for feedback on this implementation of String.isNullOrE... | stackexchange/codereview |
does someone has any opinions about this SafeBox StateMachine?
import java.util.Scanner;
public class SafeBoxStateMachine {
public enum SafeBox {
ACCEPT{
private Scanner scan;
private boolean askPassword(SafeBoxStateMachine safebox){
System.out.println("Pleas... | stackexchange/codereview |
I wrote a basic JavaScript plugin that allows you to specify what specific JavaScript files and CSS files to be loaded in, and in addition specify attributes for each file.
To specify where to load in scripts, you just have to add a data-script-loader attribute to an element, and all scripts will be inserted after that... | stackexchange/codereview |
I've previously posted a version of this code here:
MS Access VBA code to compare records in a table and combine data where necessary
To repeat what I'm looking for from my previous post:
Note I have written "Suspect there is a better way to do this" etc. in the comments of a line which I think is questionable, so if y... | stackexchange/codereview |
I need to implement a Ring Buffer/FIFO for data coming from a TCP socket.
It must support the following operations:
Append a the recv()'ed chunk of bytes.
Allow me to peek at the beginning of the buffer, since i get differently-sized packets, and I must decode a small fixed-size header to know how many bytes to proces... | stackexchange/codereview |
I've written this Card component which is composed of thumbnail image, name, symbol, total_volume, current_price, and price_change_percentage_24h.
I want to refactor my renderPriceChange function since it's using the same pattern.
const renderPriceChange = (price) => {
if (price > 0) {
return (
<Text style... | stackexchange/codereview |
I have a grid and a class Vehicle, which will have starting point(X, Y on the grid) and direction(one of N,E,S,W) taken from user and there will be commands, L & R turns the vehicle 90 degrees around left and right respectively and M moves the vehicle one unit to faced direction.
For instance, if the command is M and... | stackexchange/codereview |
I've finally got a solution for a "weekly streak" bucketing system I've been working on but unfortunately it's resulted in a very large switch statement.
I'm running through a handful of dates and determining by a range of seconds (the length of a week) which bucket that date belongs to.
It's obvious to me that this co... | stackexchange/codereview |
I am stuck on a piece of code that I have written that uses dcm4che. I have made a whole heap of nested ifs and I want to find a way to convert to a switch-case (problem being I have no way of declaring an int that can distinguish between cases). Is there an alternative to making this code snippet appear less ugly?
imp... | stackexchange/codereview |
This is a follow up from my previous post: Program that converts a number to a letter of the alphabet
This is meant to teach my little brother (who only knows how to make games in Geometry Dash) about C, and computers. This is an example I've written meant to be shown and explained to him.
#include <stdio.h>
#include <... | stackexchange/codereview |
I'm moving on to graphics, picking Pyglet and Cocos2D. This is my first program in Python with GUI.
Introducing:
Two distinct high definition button sprites
Satisfying high quality button pressing clicks
Conveniently positioned counter
Fully functional exit button
Detailed error logging techniques to support software ... | stackexchange/codereview |
Attempting to populate HTML string-templates from untrusted input.
function sanitizer(str, i, list){
return str + (this[i] ?? '').toString()
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/'/g, ''')
.replace(/"/g, '"')
... | stackexchange/codereview |
Looking for some advice on whether or not this can be improved in terms of efficiency and speed, it would need to work on large data sets.
public class Anagrams {
public static boolean isAnagram(String str1, String str2) {
String s1 = str1.replaceAll("\\s", "");
String s2 = str2.replaceAll("\\s", ""); ... | stackexchange/codereview |
I implemented the Dijkstra algorithm from scrath and wonder if I can save some code? The whole algorithm is here.
n is the number of nodes, and m the number of edges. 1 ≤ ≤ 10^4, 0 ≤ ≤ 10^5, ̸= , 1 ≤ , ≤ , edge weights are non-negative integers not exceeding 10^8.
def restore_heap(heap_arr, dist, updated, vertices2... | stackexchange/codereview |
Here is my two-player Tic Tac Toe game. How can I improve it?
#include <iostream>
#include <vector>
//Simple Display
void Display(std::vector<char> const &grid){
//Creating a onscreen grid
std::cout << " " << 1 << " " << 2 << " " << 3 << "\n";
for(int a = 0; a < 9; a++){
if(a == 0)
... | stackexchange/codereview |
I would appreciate a thorough review of my updated User entity class. It's still an anemic domain model, but behavior (like upgradeToPremium(), etc) will be added as I'm developing my application further.
This is the first time that I'm commenting my code properly according to the phpDocumenter docs. So some feedback o... | stackexchange/codereview |
Challenged by Sandy Metz's newsletter, I've tried to implement this kata from exercism. However, my solution, which passes the tests, is quite a lot simpler than Sandy's solution. Ok, so she's using refinements and also supports the inverse, but still... As she's probably smarter than me, do I miss something?
class Fix... | stackexchange/codereview |
In my solution I've implemented transaction-like methods of uploading posts media. For example I'm adding new post with photo. I want to have 700x700, 200x200, 70x70, 10x10 px sizes in my storage and original in device album. And when all images are uploaded, then save new post info to database. But this code is not be... | stackexchange/codereview |
I was wondering if someone could review my object oriented design for my Noughts & Crosses program. Yesterday I posted a procedural version and now I've done an OOP version.
Can someone tell me what I've done well, what I haven't done well, and provide any suggestions on how I can improve this program? I included inher... | stackexchange/codereview |
Here's an example script I wrote for Instagram (Facebook)'s Basic Display API. I did this for myself because I haven't used Instagram's API since their Legacy API was disabled, and I needed to familiarize myself for upcoming projects. It's super easy to understand and is meant for learning purposes. It covers every fun... | stackexchange/codereview |
I'm playing with a simple (for now) project in PHP with Google Calendar API. I have posted the code here in order to improve my programming style about whatever you think it's worth suggesting. Thank you.
As you can see, at the moment the script listEvents.php retrieves all the events in the last 7 days from primary ca... | stackexchange/codereview |
I was extremely annoyed by the lengthy, edge-case-galore explanation of integer version of C++ standard library mindpoint implementation here, so I made my own simple 2's complement version. I present it for your judgement.
The general idea is to carry out a + (b-a)/2 in a wider signed integer that won't ever overflow.... | stackexchange/codereview |
Racetrack
The August community challenge is to implement a program that plays the Racetrack game. Each player starts with an integer position on a square grid. On each turn, the current player can accelerate by -1, 0, or 1 unit in each direction. The first player to reach the finish line wins.
Most of my Java implement... | stackexchange/codereview |
I am new to COM programming in C++ and while this code works welcome suggestions to improve readability/reliability. This creates a blank word document and adds the text Hello, World.
// The Microsoft Office Object type library (mso.dll)
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" raw_interfaces_only, name... | stackexchange/codereview |
For my resources management, I wanted the objects allocated on the heap to be in a contiguous block of memory. Obviously, each data type then has to have their own chunk of memory. I could have used a vector for this, of course, but the resources need to be aligned properly with a given alignment which a vector can't d... | stackexchange/codereview |
(See the previous iteration.)
(See the next iteration.)
I have a simple "data structure" for storing numbers and querying the statistics on them (average, variance and standard deviation).
Now I have made the bag data structure more versatile:
numberbag.hpp
#ifndef CODERODDE_STAT_NUMBER_BAG
#define CODERODDE_STAT_NUMBE... | stackexchange/codereview |
A simple command that wraps another command, locking a file first. It is similar to flock, just simpler.
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/file.h>
#include <err.h>
#include <stdlib.h>
void attemptLock(const char *lockFileName)
{
int fd = open(lockFileName, O_CREAT | O_WRONLY,... | stackexchange/codereview |
This works as expected and I want to get this code reviewed so that I can improve my coding ability.
I am concerned about readability and the quality of the code
#include<stdio.h>
#include<stdlib.h>
struct node
{
int element;
struct node *next;
};
struct node* mergeList(struct node *list1, struct node *... | stackexchange/codereview |
I'm trying to parse a char* into an int without using atoi(). I walk through the string, check if it's a valid digit, then add that digit to my integer by multiplying by 10 and adding the digit. I am not accepting negative integers.
Here's the code I'm using:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
... | stackexchange/codereview |
Am using the datasource which is from the MVC controller method "GetRepairIssues" in the client side to bind the options to the dropdownlist. The result comes as expected. I have to do it even better and optimistic.
public JsonResult GetRepairIssues()
{
JsonResult result = null;
try
{
var repairIss... | stackexchange/codereview |
I was asked to create a method that would:
Return a Change object or null if there was no possible change
The "machine" has unlimited bills of: 2, 5 and 10
The Change object must return the most minimal amount of bills possible
This was a question asked in codingame.com and wanted to investigate further on it:
packag... | stackexchange/codereview |
I created a little Kotlin clone of the 2048 game that is playable in the console. My goals were readability and statelessness for no other reason than practice. Consider it a code kata wherein I didn't want to mutate the original grid, instead returning a new permutation for every operation.
To this end, I would greatl... | stackexchange/codereview |
I'd appreciate feedback on the code itself (style, performance optimization (both space and time)), and also on the algorithm (because I think this is typically implemented using a stack).
The assumption I'm making here is that there are only two constraints to having balanced parentheses; one is that there be the same... | stackexchange/codereview |
Using JavaScript ES5, I would like to know if you could suggest me a more "elegant" and succinct way to overriding defaults variable when User pass custom values.
In the following example, an animation is executed using _defaultOptions, a developer can change the default behavior passing only some properties to a funct... | stackexchange/codereview |
I'm pretty new to linked lists - I understand the concept and how they work - but coding them is a bit more...complicated. I have some code below that I'm using for homework - essentially we're to create a struct containing data for a football player, and then create a linked list and add the struct to it. I'm not 10... | stackexchange/codereview |
I have a jQuery function which adds a tag to the first row of a table. I previously tried using append, however that didn't work. I now have the following solution which is very slow and it gives this warning:
A script on this page is causing Internet Explorer to run slowly
Function:
jQuery.fn.fixGridView = function ... | stackexchange/codereview |
I would like to communicate a piece of code which I hope will soon be broadly useful for everyone who programs in C++: A set of quasi-random number generators proposed for addition to boost.random. To keep the scope somewhat bounded, I will only submit the Sobol sequence for review (though there are two other sequences... | stackexchange/codereview |
These two functions search for directories with a certain prefix that contain no files of a given type.
Does the code adhere to Ruby standards and conventions?
Am I doing something the hard way or the "non-Ruby" way?
Should I use more/fewer/different comments?
def find_empties(directory, dirprefix, fsuffix)
empty_... | stackexchange/codereview |
I created this testimonial on CodePen
I am a bit skeptical about a few things in my HTML structure. For example, I typically see testimonials enclosed in <div>s with custom classes. In my case I used a <blockquote> but had to overwrite a lot of rules.
Also wondering if enclosing the author in <strong> tags was wise.
... | stackexchange/codereview |
std::array < char, 27 > new_alphabet() {
std::array < int, 26 > a;
static std::random_device rd;
static std::mt19937 mte(rd());
std::uniform_int_distribution < int > dist(0, 25);
std::generate(a.begin(), a.end(), [ & ]() {
return dist(mte);
});
std::array < char, 27 > alpha = {
"ABCDEFGHIJKLMN... | stackexchange/codereview |
I need to sort a large array (5 columns x ~500,000 rows) of string variables by two columns. I have code that works, but it takes an unacceptably long time, particularly because I have to do this on five sheets with different data.
I have been doing research, but the code I found tend to be for either a single column, ... | stackexchange/codereview |
This is a project I came up just as an exercise with to familiarize myself with Python syntax and data types. I am just learning how to code and would like to avoid establishing bad habits. On the other hand, I wanted this program to function so when I found something that worked, I left it as is, even if I suspected t... | stackexchange/codereview |
This is my solution to CodingBat problem p150113. My Java knowledge is from 2011 and I'd like to know if this is still the optimal way to approach such a problem. and if my code is clean and understandable.
We'll say that 2 strings "match" if they are non-empty and their first chars are the same. Loop over and then r... | stackexchange/codereview |
Here is a little game modeled after adventure that I have been working on. The code initializes a set of lists. It sets a current location randomly generated. The user is tasked with either incrementing the index or de-incrementing the index (moving up and down the avenue). At each location there is a store which they ... | stackexchange/codereview |
Here I have a method for reading the contents of a file into a buffer and returning whether or not it is successful.
Here is what I would like reviewed:
Speed: Am I reading in the file as fast as possible?
Bugs: Are there cases where my code could fail or give unexpected behavior?
Syntax/Styling: How does my code lo... | stackexchange/codereview |
Is there any way to improve this kind of code? I have converted this from production code for privacy reasons, so there might be some mistakes.
public class AddNewUserDto
{
public bool IsAdmin { get; set; }
public bool IsRead { get; set; }
public bool IsWrite { get; set; }
public string[] GetRolesByD... | stackexchange/codereview |
Here is the code that I write for my work on Excel-vba. I use that code to know shifts' and operators' performances.
Main purpose is to divide machines' work to orders and shifts.
Sub Ucshift()
On Error Resume Next
'Cleaning before start
Sheets("Data").Range("A1:R568").AutoFilter
Sheets("Data").Range("A:A,F:... | stackexchange/codereview |
Problem statement: Write a function which checks if two triangles intersect or not. Complete containment or tangential contact is not considered intersection.
Approach: I have considered each triangle as collection of three line segments. And then checked if any of the line segment from first triangle intersects segmen... | stackexchange/codereview |
I solved a problem which you can read about here, but it gives me "time limit exceeded" even though it runs in 4 seconds. I really don't understand why.
I don't think my code can be any simpler, basically it has as many functions as there are solutions I think. At the start of my code I find the first letter matching t... | stackexchange/codereview |
I have created my own wrapping framework for the COM interfaces exposed via Microsoft.Office.Interop.
MIRRORING WRAPPERS
The first purpose is to be able to unit test the rest of my applications, and also to be able to intuitively log some of the calls.
The wrapping is achieved through 2 layers of interfaces: the first... | stackexchange/codereview |
I've been learning to program in Java and I decided to implement a doubly linked list as practice and as a bridge project before going on to learn C++. I know Java includes a LinkedList implementation, but I wrote this for practice. I have finished the code and it works correctly. However, I'd appreciate some feedback ... | stackexchange/codereview |
I have a performance problem when trying to create a csv file starting from another csv file.
This is how the original file looks:
country,state,co,olt,olu,splitter,ont,cpe,cpe.latitude,cpe.longitude,cpe.customer_class,cpe.phone,cpe.ip,cpe.subscriber_id
COUNTRY-0001,STATE-0001,CO-0001,OLT-0001,OLU0001,SPLITTER-0001,ON... | stackexchange/codereview |
I've written a script in VBA which is able to parse image links from a website, download and store them in a local folder and finally set those images beside each link in an Excel file.
As the script is a bit big, I tried to make it clean so that it can serve the purpose errorlessly. However, it can do successfully wha... | stackexchange/codereview |
I wrote a terminal-based TicTacToe game in Kotlin to practice both Kotlin and OOP. Any feedback on structure and code would be appreciated.
Board.kt
package main.com.github.me.tictactoe
class Board {
val originalBoardConfig = listOf(
listOf("1", "2", "3"),
listOf("4", "5", "6"),
listOf("7",... | stackexchange/codereview |
I need to have some thread-safe event handler (like C#'s EventHandler), so I made one. Here is my event handler class and sample code (compiled with VS2013). Is this code OK to be operated in multithreaded environment?
#include <functional>
#include <memory>
#include <atomic>
#include <list>
#include <conio.h>
///////... | stackexchange/codereview |
What I have to do is to sort the array list and then rank them in descending order.
I have to write a method to sort and display the names according to their final scores decreasingly.
The output should be in the form:
Rank_number1 Name1 new_final_grade1 new_final_score1
e.g.
1 Winnie A 94.4351629426243
(Rank_number... | stackexchange/codereview |
I am working with MongoDB through Docker, and I have a terrible bash command to pull the Docker Machine IP so I can sanely connect locally.
export dockerip="$(docker-machine ls | awk '{print $5}' | sed -n '2p' | sed 's/tcp:\/\///' | sed 's/\:2376//')"
mongo --host "$dockerip" --port 27017
How can I optimise the docker... | stackexchange/codereview |
If many threads Borrow() and Return() an instance of Packet from/to PacketPool could the Exception in Packet.Init() ever be thrown? Assuming only PacketPool ever called the Init() and UnInit() methods on a Packet.
class PacketPool
{
private Stack<Packet> pool;
public PacketPool(int initalNum)
{
poo... | stackexchange/codereview |
The challenge is to find the maximum product of a subset of a given array. Here's the problem:
Write a function solution(xs) that takes a list of integers
representing the power output levels of each panel in an array, and
returns the maximum product of some non-empty subset of those numbers.
So for example, if ... | stackexchange/codereview |
Overview
I have been writing my own graph API for Rust and one thorny problem I wished to tackle was a
parallel breadth first traversal of the graph. The API itself will have different graph
flavours, but the one I have built for these tests is an undirected variant without double
edges.
I have created a breadth first ... | stackexchange/codereview |
I'm currently learning Vue JS and I made a simple app that pulls information from API and displays facts about a country given a 2-letter country code. I'm looking for feedback on how to improve the code. I'd appreciate any feedback. Many thanks.
This is my app.vue
import axios from "axios";
export default {
name: "... | stackexchange/codereview |
I have a interface with the following implementation
public abstract class PersonInterface
{
public abstract void Update(PersonModel person);
public abstract void Delete(int id);
public virtual PersonModel Find(int id)
{
return new List<PersonModel>().Find(x => x.Id == id);
... | stackexchange/codereview |
I'm trying to implement a sparse vector (most elements are zero) dot product calculation. My major idea is to represent each sparse vector as a list (which holds only non-zero dimensions), and each element in the list is a 2-dimensional tuple -- where first dimension is index of vector, and 2nd dimension is its related... | stackexchange/codereview |
The query (on SEDE)
This query builds upon the previous and includes the suggestions by rofl as well as the now mentioned activity index.
DECLARE @tag_name nvarchar(35) = '##TagName##';
DECLARE @min_score int = ##MinScore:int?0##;
DECLARE @max_score int = ##MaxScore:int?0##;
-- CTE to find the maximum answer score on ... | stackexchange/codereview |
I've been experimenting with wiring up a vanilla web component in a reactive manner to a state box. The goal is that when something changes on the state object, the web component reacts. I realize that there are frameworks and libraries for this, but I want to understand fundamentally what goes on underneath. After two... | stackexchange/codereview |
Some time ago I started with a small Ruby project. I call it social_aggregator.
This software aggregates information from different networks to one xml-stream, which you can reuse. For instance on your personal website to show some of your activity to your audience or as your personal news feed.
I've written something... | stackexchange/codereview |
This seems like an awful lot of code and I'm guessing can be condensed and made more efficient somehow. Can anyone suggest this to me at all?
// Add the active class to the first element
$('.indexWorkDetailsInner:first').addClass('active');
// Next Button Click
$('.indexWorkRight').click(function() {
// Move all ... | stackexchange/codereview |
I am reading the book Advanced Programming in the UNIX Environment and I have tried to solve the following exercise: Write a function that performs the same actions as dup2, but without using fcntl
My question: What can I improve? What problems may arise?
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#incl... | stackexchange/codereview |
The goal is this "simple game".
The game is all about that you choose a "boom number" and then count
one by one from 1. Every time that the player hits a number that can
be divided by the "boom number" resulting in an integer.or that the
"boom number" is a part of the number, the current player must shout
"B... | stackexchange/codereview |
I need to calculate the height of an optional (not AVL, binary) tree. For input I receive an n integer positive number: parent(0), parent(1), ... parent(n-1). Here, parent(i) is a parent of node i. If parent(i) == -1, that i is the root of the tree. It is guaranteed that the sequence has only one root and presets a tre... | stackexchange/codereview |
I'm looking for advice on how to improve the performance and/or style of these two search functions. This is just for fun and for practice: they are already fast enough for any application I would be using them in, and they don't have to meet any specific performance criteria, but I'm interested to see how they could... | stackexchange/codereview |
I'm diving into the world of nodejs and mongo. I am playing around with a simple app that uses MongooseJS to talk to Mongo. I have been looking at examples and some GitHub projects for references, but the pattern seems very sloppy to me. Is this approach considered normal, or is there a better way?
Here is a sample fro... | stackexchange/codereview |
I did the following
Created DB and table in prepate_table function
Extracted data from binance in GetHistoricalData function
Saved the data to DB
My code works fine but I want to optimize my code and remove redundant steps
My solution
import os
import pandas as pd
import time
import clickhouse_driver
import datetime
... | stackexchange/codereview |
Iris Data Set consists of three classes in which versicolor and virginica are not linearly separable from each other.
I constructed a subset for these two classes, here is the code
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import numpy as np
iris = load_iris()
x_train =... | stackexchange/codereview |
I'm writing an application to sync files between two directories. In order to prevent simultaneous access to the shared directory from several computers, I implemented blocking of the shared directory. The class below implements this lock.
The application is built and at first glance works without errors.
But I'm new t... | stackexchange/codereview |
I really like functional programming in C#, it gives you a lot of flexibility.
I am wondering if it is the right idea to use functions instead of helper methods, and to make the code more readable.
So here is what I want, I have a method that needs to find Saturday and do something with it:
public void SomeMethod()
{
... | stackexchange/codereview |
The reason I used fields instead of automatic properties is because I am using tryparse which can not use properties... I know the Title setting could have been an automatic property but I decided to go with consistency and create a field for it. Is it ok to do so?
Do you see anything else that could go wrong?
Is it o... | stackexchange/codereview |
I used Python very occasionally, today I solved n queens in Python just for fun. I am sure there are better way of doing certain things in Python and can't wait for improvement suggestions!
#!/usr/bin/python3
def print_board(board):
for row in board:
for field in row:
print('Q ', end='') if fi... | stackexchange/codereview |
I am sure you know what Pythagorean triples are, in the extremely unlikely case that you don't know:
A Pythagorean triple consists of three positive integers a, b, and c, such that $$a^2 + b^2 = c^2$$
source
I have written four functions, the first one is a brute-force solution that gets all possible unique combinati... | stackexchange/codereview |
I'm still new to C++ and I am very open to any kind of suggestion on how write proper and understandable C++ code. I decided to create a class for the code to have everything closely tided together. Don't know if that was a good idea.
About signature scanners (aka. pattern matchers), see see wiki. Signature scanners ar... | stackexchange/codereview |
This post is a follow up question.
The purpose of this class should became clear without any further explanation. Raise your hand. If not, then I will have to improve the naming/structure.
I would like to know how to improve this code in terms of readability and complexity.
Data structure:
<?xml version="1.0" encoding... | stackexchange/codereview |
A few days ago I've faced an annoying problem.
Let's imagine we have 3 classes: Base, System, Handler.
The classes Systen and Handler both inherit from the class Base.
I want to access those classes this way: System::DoStuff();
I also need the Handler be available in the System, but do not want to instantiate it there... | stackexchange/codereview |
This is subconcious coding. This is not new by any means at all!
I am only keeping the question because I can't delete it.
I've just realized that subtracting negative numbers from zero gives the same result as adding the positive versions of the numbers together.
Here's a demo (in Python):
def plus(x, y):
return 0... | stackexchange/codereview |
Related to, but not exactly a follow up of this question. After fixing some issues discovered in the last review, I added a little more functionality to the Enumerable class. The problem is, I've never sorted before. I tried (and failed)to implement a few of the standard algorithms before coming up with this. It's not ... | stackexchange/codereview |
I wrote a small sitemap-checker.aspx, the goal of this code is to find the pages, that respond with the codes other than 200. I've only put the C# part here for the review:
void Start_Click(object sender, EventArgs e)
{
CheckUrls(UrlTextBox.Text);
}
private void CheckUrls(string url)
{
... | stackexchange/codereview |
I've done tutorials as well as searches. I need assistance in simplifying this code. Please don't do it for me- instead inform me of what, where and why you are trying to simplify or write less code. I'm already working on an if loop to exit on enter. This is just version 3 for me.
## Program gets the date, Employee ID... | stackexchange/codereview |
I have the following query that counts the number of vessels in each zone for each week:
SELECT zone, DATE_FORMAT(creation_date, '%Y%u') AS date, COUNT(DISTINCT vessel_imo) AS vessel_count FROM vessel_position
WHERE zone IS NOT NULL
AND creation_date >= DATE_SUB(CURDATE(), INTERVAL 12 MONTH)
GROUP BY zone, date;
The t... | stackexchange/codereview |
This function takes a list/array of booleans and converts them to an array that counts the number of either True/False values found next to each other.
I'd like to see this optimized for performance. It's not too slow, but I do use multiple loops with embedded if-else statements, I'm wondering if they're absolutely nec... | stackexchange/codereview |
Task: implement an algorithm to find graph center \$Z(G)\$ given undirected tree \$G\$.
This is my first time programming in C++ so any (elementary) feedback is appreciated.
The way I did it is:
Run BFS from any node \$v_0\$ in \$G\$. Find node \$v_1\$ with \$\max_{v_1\in V(G)} \text{dist} (v_0,v_1)\$.
Run BFS from \$... | stackexchange/codereview |
Code
List<Element> elements = GetElementsList();
ISet<string> usedInnerElements = new HashSet<string>();
foreach (Element element in elements)
{
foreach (InnerElement innerElement in element.InnerCollection.InnerElements)
{
usedInnerElements.Add(innerElement.SomeValue);
}
}
class Element
{
pu... | stackexchange/codereview |
Inspired by this question I wrote a memoized form of the collatz sequence calculator.
The idea was to cache the sequence lengths for as many sequences as possible, from 0 to some value. I managed to (on my PC) get that value up to 1427500000, which is a large number.
I ran this particular calculator and it eventually c... | stackexchange/codereview |
A generic blocking queue has the following properties:
It is thread-safe.
It allows queuing and de-queuing of items of a certain type (T).
If a de-queue operation is performed and the queue is empty, the de-queuing thread waits indefinitely for an item to be queued and then
retrieves it (i.e. a de-queue operation c... | stackexchange/codereview |
I have a tree processing application where some of the nodes are "executed" in parallel and some in series. I managed to do this but I feel that the solution looks a bit "hacked up" and can be improved on.
I have a JobObject class which I am using to build a tree:
[Serializable]
public class JobObject
{
public int ... | stackexchange/codereview |
I am new to programming and I have tried to recreate below lines into OOP's code. Please review and provide comments.
House has Rooms.Rooms are drawing room, bed room, bathroom etc.Each room has walls, ceiling,floor. Each room have different objects in it like drawing room has sofa, table , TV etc. , bedroom has TV etc... | stackexchange/codereview |
I've just started a course that will require knowledge and experience with Python for future projects, which I don't have, so I thought I'd give it a go to familiarize myself with it and get some feedback. I got a decent summary of the language's main features from a 2 hour long overview video (https://www.youtube.com/... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.