instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I would like to refactor code below and get rid of if statements for classes from view.
.container
.tabbable.tabs-left
%ul.nav.nav-tabs
- @related_tasks.each do |task|
%li{class: ("active" if @task == task)}
= link_to task.name, "#tab#{task.id}", data: { toggle: 'tab' }, class: @current_us... | stackexchange/codereview |
I'm writing implementations of some numerical methods to solve linear equations systems, those implementations use the following Matrix class. I'm trying to get this class immutable, due to that the constructor and some methods create a copies of the backing two-dimesional array. The class have some basic functionality... | stackexchange/codereview |
I got inspired by Stack Overflow to build a simple state machine which can test if a sequence contains 0,1. I have two questions:
How can I get rid of line | _ -> (function `q0 -> `q0 | `q2 ->
`q2 | `q1 -> `q1)
How can I improve that code?
(If it is matters, I came from Python and many things in OCaml seem unusual to... | stackexchange/codereview |
I have refactored the code for this game thanks to some great suggestions from woxxom
Now, once again, any suggestions still welcome. I am going to be improving the UX as a next phase (giving hints to the user etc).
I have also improved the consistency of naming IDs and using single/double quotes etc.
There was one s... | stackexchange/codereview |
I would like to hear feedback from an interviewer's perspective on how to improve the following code:
from collections import Counter
def word_map(string):
word_dict = {}
stop_word_file=open("stopwords.txt", "r")
stop_words =stop_word_file.read().split()
for word in string.split():
word = filte... | stackexchange/codereview |
I need to run over all the IP addresses on the CIDR 10.96.0.0/12 network.
There are 1,048,574 IP addresses.
I created a multi threaded program in Go to do it, but even when I use 100 threads it takes lots of time (didn't check exactly but it is more than 10 minutes).
Is there are way I can do it more efficient?
By the ... | stackexchange/codereview |
I recently decided to learn how to multithread Java programs, so I made a small program to compare the performance of serial and multithreaded programs that perform the same task.
I created a serial program that calculates the number of primes from 1 to 10 million, and timed it 50 times using a test program. Here's the... | stackexchange/codereview |
The problem to the question is:
Write a program that takes 3 integers as an input from the user using input dialog messages and sorts the three numbers.
I just want to know: is there any major differences between my code and the book's code in terms of efficiency or anything specific that I could have done better in ... | stackexchange/codereview |
I want to remake and sort an array.
Is it possible to use "reduce" instead of "forEach" or "map"?
return beeProps.valueInfos.reduce (reduce()) would be great.
Anything else looks like it could be improved?
const makeTableArrayMap = (beeProps: beeOfProps) => {
const rowMap: Map<number, beeOfValue[]> = new Map();
... | stackexchange/codereview |
I've started building extension methods for my EF classes like below because it makes building queries so easy, and the intellisense provided helps keep people from writing a new Where() clause in code every time they do to do something.
Example Extensions to an EF User Class
public static class UserIQX
{
public ... | stackexchange/codereview |
I am new to OOP in general and have recently started trying to develop object-oriented PHP code instead of relying on a primarily procedural style, as this is a requirement for my studies. One part of this involves websites that may handle data exchange and connect to MySQL databases with users (which should also be co... | stackexchange/codereview |
I have been trying to improve my Discord sending webhooks functions where I have multiple dictionaries, as you will see in the code below:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import time
from threading import Thread
from discord_webhook import DiscordEmbed, DiscordWebhook
DISCORD_POSITIVE = {
"hello": {
... | stackexchange/codereview |
Note #2: This was a post from a while back. Although the top rated answer is useful (generally), I'm looking for something more specific to this issue including routing / architecture. I've even tried a bounty, which failed. As I don't have enough rep to keep adding bounties, I'll leave it open until someone decides t... | stackexchange/codereview |
This is a statement that I use a lot in my code base:
(LocalDateTime.now()).format(DateTimeFormatter.ofPattern("ssmmHHddMMMuu"))
Should I create a static method for this or is it overkill?
public static String getTodaysDateInFormat(String format){
return (LocalDateTime.now()).format(DateTimeFormatter.ofPattern(form... | stackexchange/codereview |
Use recursion in the solution.
I would really appreciate if you can help me to find a better way to do it.
public class AppendCharacterAfterEachCharacterInString
{
int index =0;
StringBuilder outputString = new StringBuilder();
public string AppendInputCharacterAfterEachCharacterInString(string sInputStrin... | stackexchange/codereview |
I have a function that returns rows from my database, and it works fine, but I was told that it was poorly written, and there is a lot of unnecessary code in it. I'm wondering if there is a simpler, easier way to rewrite this function.
function gd($query) {
global $connect;
$fetch = mysqli_query($connect, $que... | stackexchange/codereview |
I have a finance web-application in ASP.NET WebForms using Telerik RAD controls. Two event handlers wound up being very similar in implementation.
What steps could I take to improve the organization of and/or the efficiency or DRY-ness of the code? What other issues / code-smells are present?
The Code
Update Event
... | stackexchange/codereview |
messy json file is parsed and should output the N highest
record IDs & scores by score in descending order, highest score first.
the code works but i wonder if there is better readability, help me refactor it.
The function takes 2 args - the data file path and num of scores to return:
python myprogram.py highest score_... | stackexchange/codereview |
We have been learning C++ the previous semester and I made this simple TicTacToe game at the end of it. We haven't yet covered topics of vectors, classes, objects, exception handling etc. so with this code I mostly wanted to practise use of arrays. I would like to hear from you on suggestions on how to make this code m... | stackexchange/codereview |
I just finished Project Euler #14 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
The following iterative sequence is defined for the set of positive
integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and st... | stackexchange/codereview |
I've recently solved the "UTF-8 Validation" LeetCode problem:
A character in UTF8 can be from 1 to 4 bytes long, subjected to the
following rules:
For 1-byte character, the first bit is a 0, followed by its unicode
code.
For n-bytes character, the first n-bits are all one's, the n+1
bit is 0, followed by n-1 by... | stackexchange/codereview |
Well, it's not actually a schema validator but anyway...
Motivation
I'm writing a library which is a UI to work with some electronics - modules. Each real module is represented by a corresponding class in the library. I've decided to add the ability to program a module at once using the config entity. Also it should be... | stackexchange/codereview |
I am using this basic extension for a Swift project. It works well, but I want to make sure it is the absolute fastest way to get a substring.
extension String {
func substring(start: Int, end: Int) -> String {
if (start == end || self.strlen() == 0) {
return ""
}
let startIndex ... | stackexchange/codereview |
I am learning D. I'm trying to implement Haskell's intersperse in D. I want to use ranges. I feel that the intermediate "interspersed" value is wrong. Additionally, I suspect the concatenation character by character is inefficient. What is a more idiomatic way to implement this function, please?
string translateToSwed... | stackexchange/codereview |
I implemented the A* algorithm for pathfinding for a game of mine. The game uses hex rooms which are connected to each other by an int[] in the room class. Are there any pointers you can give me on my code?
public class Pathfinding
{
/// <summary>
/// Finds a path from one room to another using the ... | stackexchange/codereview |
Taking online college course and I'm new to Java. We just learned about input validation. I've used input validation pretty comfortably for strings, ints, and whatnot. But I had to validate a boolean value so I tried using a Boolean object (for a null assignment) and it worked.
Instructor feedback is slow at best and I... | stackexchange/codereview |
I've written a class for a project of mine whose responsibility is to perform basic statistic calculations like mean, median and mode. The aim is for it to be a helper class, so it should not be instantiable. I later want to extend it to include weighted mean and range/interquartile range as well as variance.
Here is t... | stackexchange/codereview |
I have written an isPalindrom-Function in TypeScript.
const isPalindrom = (word: String): boolean => {
const mid = Math.floor(word.length / 2);
for (let i = 0; i < mid; i++) {
const left = word[i].toLocaleLowerCase();
const right = word[word.length - 1 - i]
.toLocaleLowerCase();
... | stackexchange/codereview |
So, sᴉɔuɐɹɥԀ suggested I write a SEDE query to find first questions with answers posted within 24 hours, and here it is:
WITH QData(OwnerId, CDate)
AS
(
SELECT
Q.OwnerUserId [OwnerId]
,MIN(Q.CreationDate) [CDate]
FROM Posts Q
WHERE Q.PostTypeId = 1 AND Q.OwnerUserId IS NOT NULL
GROUP BY Q.OwnerUserId
),
Fi... | stackexchange/codereview |
Question:
One of Scotland Yard’s most wanted criminal (Mister X) is on the run
and needs to reach a certain destination safely. There are three modes
of transport available for him - By air, by train or by cab. With air
travel, he can go from station i to station i+3. Using a train would
make him reach stati... | stackexchange/codereview |
I have 4 panels that will contains tables for data. There will be instances where a panel will contain no data, so I have combated wasted space with the code below. I'm relatively new to both jquery and bootstrap and just wanted to ensure I was using the best practice.
$(document).ready(function() {
$('#panel1CB').... | stackexchange/codereview |
I have an array filled with 5 other arrays that consists of arrays of 2 values (first a date then a count):
[
[
[dt, cnt], [dt, cnt], ....
],
[
[dt, cnt], [dt, cnt], ....
],
[
[dt, cnt], [dt, cnt], ....
],
[
[dt, cnt], [dt, cnt], ....
],
[
[dt, cnt], [dt, cnt], ....
... | stackexchange/codereview |
I have two strings (aggregatePath and pathFromParent), either of which might be null or an empty string. I want to concatenate the two strings with a separator only if neither is null or empty. This is what I've ended up with:
FullPath =
aggregatePath +
aggregatePath is not (null or "") && pathFromParent is not... | stackexchange/codereview |
This shell script, with only a few configurations, has the goal of initializing a project on Gitlab.com without having to go through the go through the website's ui.
This means: Let's say you just a project with a few source files, but you haven't done anything with git yet. The goal of this script is to allow you to w... | stackexchange/codereview |
I've developed a C application for Ubuntu and created the installer. The file structure is
├── autom4te.cache
├── build-aux
├── contrib
├── debian
│ └── source
├── doc
├── gnulib
│ ├── lib
│ └── m4
├── man
├── po
├── src
└── tests
configure.ac
dnl Process this file with autoconf to produce a configure script.
dn... | stackexchange/codereview |
I have a menu, where a user selects one out of 4, and another 2 or 4 options will appear. I used big buttons; a picturebox + label to create the buttons.
The 4 main buttons are fixed, but the 4 other buttons depend on the first choice. Text and image will change. I programmed this, but I kinda feel this must be possibl... | stackexchange/codereview |
I'm creating some age-verification functionality for an iOS app. The user is presented with a UIDatePicker object, and the latest selectable date should be today minus 18 years. How vulnerable to inaccuracy is my code? How could it be leaner?
-(void)validateAge {
NSDateComponents *today = [[NSCalendar currentCalen... | stackexchange/codereview |
I have these easy-to-use methods for reading and writing binary data in files.
FileTools.java:
package net.coderodde.file;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import ... | stackexchange/codereview |
It might be a bit redundant, and I'm not experienced enough to wrap it all into one function. But,
I'm aiming for unicode email adresses and a quick loose but secure validation. How can I improve this?
note: I'm using PDO, so I'm mainly focusing on preventing HTML injection. Is this an issue ether way if I'm outputting... | stackexchange/codereview |
Fishstacks is a deadfish derivative based on a stack the stack can only hold four elements when a fifth element is pushed the bottom element is kicked out and eventually printed out to the screen.
I've come up with an interpreter in TI-BASIC for my calculator. However, I fell slightly guilty about using all four variab... | stackexchange/codereview |
How do I condense this gigantic monster into something more manageable? I heard about command pattern but I can't figure out how to use it. What other solutions are there?
public void AI(){
count++;
if(count % 2 == 0){
letter = "O";
}
if(((buttons[1].getText().equals("X") && buttons[2].getText... | stackexchange/codereview |
This function returns true if the string contains zero or one periods, and returns false if the string contains more than one period.
bool isStringValid(std::string str){
std::size_t pos = str.find('.', 0);
if(pos != std::string::npos){
pos = str.find('.', pos + 1);
if(pos != std::string::npos){... | stackexchange/codereview |
Uncle Bob in his Clean Code says:
So all the same rules apply. Functions that take variable arguments
can be monads, dyads, or even triads. But it would be a mistake to
give them more arguments than that.
void monad(Integer... args); void
dyad(String name, Integer... args);
void triad(String name, int count, Inte... | stackexchange/codereview |
I wrote this after using strtok_r and needing something similar that can copy the input string and handle multiple characters in the delimiter. Its functionally similar to Python's str.split(), as it keeps empty spaces without trimming.
tokens.h
#ifndef TOKENS_H
#define TOKENS_H
#include <string.h>
struct Tokens {
... | stackexchange/codereview |
Your method should accept a real number as a parameter representing a limit, and should add and print terms of the sequence until the sum of terms meets or exceeds that limit. For example, if your method is passed 2.0, print terms until the sum of those terms is at >= 2.0. You should round your answer to 3 digits past... | stackexchange/codereview |
This is an mqtt driven, interactive, and asynchronous remote shell daemon written in bash. I call it "MqSH" or simply "mq". It works with bash, the busybox ash shell, and perhaps other Bourne-like shells. It's designed for embedded devices with low system resource, so I wrote to be friendly to busybox-based systems.
It... | stackexchange/codereview |
My intent is to use Bash functions defined in functions.sh in a C program. I am doing this so that I don't have to rewrite the Bash functionality again in C. I want to use one common library for functions I need. Here is my C code and functions.sh.
#include <stdlib.h>
#include <sys/wait.h>
#include <stdio.h>
void shel... | stackexchange/codereview |
I have created the code below that compare two spreadsheets . It initially compares the range of value from sheet1 ("Status") to sheet2 ("Interface") . Whenever a range matches with the ranges present in other sheet , it does nothing .When the range does not any matches in the other sheet , then the entire record is co... | stackexchange/codereview |
I have 5 different forms where I am disabling the submit button when a valid form is submitted so the form can only be submitted once. I am using a hidden field on each form to get the form Id.
function OnSubmit(buttonId) {
var disableButton = false;
if ($('#formType').val() == 1) {
if ($('#CreateEntityName').val(... | stackexchange/codereview |
I'm learning Rust by completing a variety of coding challenges, such as the Google Codejam problem stated in the title. I completed a Python 3 implementation that I liked, which I then tried to port over to Rust.
To my surprise, the Python implementation appeared to be considerably faster: when I ran time python3 ..... | stackexchange/codereview |
This is my first "useful" Haskell program. It's invoked with filenames as arguments where the last filename is the destination to which the content of all other files will be concatenated. As far as I can tell it's working but I don't like the two returns in the main function and would like to know how I can get rid of... | stackexchange/codereview |
I have a data frame called data with lots of columns, and Country is one of them.
I created a new logical column called train, which is true when the row belongs to the train set and false otherwise. The data frame is already sampled.
Now I want to be sure that there are no countries in both train and test sets with t... | stackexchange/codereview |
I need to convert a list of dictionaries to a dictionary of dictionaries, with a particular item as the new key.
This is the way I'm currently doing it:
>>> a
[{'bar': 'baz', 'id': 'foo'}, {'bar': 'baz', 'id': 'qux'}]
>>> {
item['id']:{
sub_item:item[sub_item] for sub_item in item if sub_item != 'id'
} ... | stackexchange/codereview |
I have created a function in VBA as follows:
Private Enum gridInstruction 'in the class declarations section
Place_Break 'not enumerated to anything specific, so uses default 0,1,2...
Place_Chain
Place_Chain_Flag
Skip
End Enum
Private Function applyRules(ByVal imgGrid As Collection) As gridInstructi... | stackexchange/codereview |
This is my first script that I've written. As a result, I'm sure there are extra lines that are unneeded, or maybe better more concise ways of doing things than I have done here. I have tried to add explanations to each section so that it's a bit easier to understand what's going on, and why I'm doing what I'm doing.
... | stackexchange/codereview |
I have the following code where I try to manage user roles in teams:
Teams have entries, an entry has a creator. This creator is member of a team and has a specified role. Moderators may delete all entries, users may only delete their own entries. Here is how I implemented this:
public class TeamMember implements TeamR... | stackexchange/codereview |
A firm gave me a small take home assignment which asks you to implement text formatter. Given some text which only contains alphanumerics and spaces (only one space between words), we should align it either using one of LEFT, RIGHT or CENTER. Here's the main logic
This is the header file
#pragma once
#include <string>... | stackexchange/codereview |
From my previous question, I got great feedback which helped improve my code which I submitted. I went back and built upon that and came back to see if my code is an improvement.
try:
from tkinter import *
except ImportError:
from Tkinter import *
import time
import random
with open("NAME_FILE.txt") as f... | stackexchange/codereview |
(Also, see the next iteration.)
I have this tiny class for downloading files from internet:
package com.github.coderodde.utils.io;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.... | 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 am just trying to improve my coding and designing skills in C++ and for that
I am trying to solve same age old problem of mapping a http request to method.
Could you guys please look at my program and point me to mistakes I am doing with design and coding style?
resource.hpp
#include <functional>
#include <string>
... | stackexchange/codereview |
I know this is a lot of code, but I'm not looking for any kind of detailed review of the code. I'm just hoping some nice Javascript guru can give it a once over and offer any needed advice for using OOP in Javascript better than I am.
Here are a few areas of concern that I have, that don't quite seem like they're ide... | stackexchange/codereview |
I'm using Winforms and I find this pattern showing up in my code a lot. It works, but I'm unsure if it's best. The goal is to pass an IList of items through a view interface and then bind that list to a DataGridView in the concrete GUI class. I've been accomplishing this by keeping a private BindingList<T> in the contr... | stackexchange/codereview |
At work we have a need to know what printers are getting dangerously low on their toner, and paper consumption, etc..
So I've created a program that pulls the printer information off the websites the printers are located at and outputs the information. This program has the option to use two separate flags -e for every ... | stackexchange/codereview |
Can you assess source code of my client-server program?
I would like to get an advice about design, code security etc.
Thank you very much.
The program does the following:
Show files in directories;
Download and upload files (for now, only one file at a time).
Syntax:
./client <Server IP> <Server PORT> dir <PATH>
... | stackexchange/codereview |
I want to insert and edit values on the same button click. The code is working fine and I am using the same code for both insertion and deletion.
function saveToDB(){
var value= pageValidation();
if($('#jobid').val()==" "){
if(value!=false){
var data = {
"names": $('#names').val(),
"os"... | stackexchange/codereview |
I'm trying to practice and learn design patterns, and I decided to create a weather app using the revealing module pattern. How can I improve on this, and what mistakes did I make?
Main.js
import '../styles/main.scss';
import {weatherModule} from './weather';
import {dateModule} from './date';
dateModule.getCurrentDa... | stackexchange/codereview |
I am currently working on a binary serialization library written in C++11 for a personal project. I'd really like to have a review about my design, my implementation and everything else. The library is inspired from QDataStream.
Here is the GitLab repository containing the project.
Sery/Misc.hh
#ifndef SERY_MISC_HH_
#d... | stackexchange/codereview |
I have this little convenience method that takes an String array and returns an String where the values are separated by a provided separator (comma, pipe, etc).
For instance, if given an array with values "abc", "def" and "ghi", and a for separator we passed " | ", the end result would be "abc | def | ghi".
This is t... | stackexchange/codereview |
I've created a system to generate tokens that could potentially be used in some sort of program:
# _gen.py is simply to generate the tokens, not to check them.
import string, secrets, random
# String is for getting all ascii letters and digits.
# Secrets is for a cryptographically secure function to choose chars.
# R... | stackexchange/codereview |
My aim with the following is to have a way of registering a list of classes, which represent plugins. In the end, I want a boost::hana::set that contains type objects for all plugins' classes. I want everything to be as loosely coupled as possible: Basically, I should be able to just delete a plugin's files, and everyt... | stackexchange/codereview |
I have learned the question of solving Angular app optimization for search engines, and was frustrated that the most recommended option is prerendering HTML.
After some time spent, I suggested to create a directive that will load the bot after rendering templates or update scope.
Directive:
angular.module('test', []).... | stackexchange/codereview |
Could you give any suggestion on the following unit tests? How to make it more readable, maintainable and trustworthy. If it is not a problem - post some code with the suggestions.
[TestClass]
public class PropertyBagCompositeTests
{
private readonly IFixture fixture;
private readonly Mock<IPropertyBag> secondP... | stackexchange/codereview |
The code will ask for a directory and will then read the CSV file and then generate a file in that directory describing a social network for Pajek.
Does anyone know a way to load this CSV file to a Pajek file faster in Java?
Here's the csv file i want to load to a Pajek file. It contains 72180 lines, and looks like:
... | stackexchange/codereview |
Background is this question and to create something like Craigslist or olx.com i.e. classifieds advertisement webapp / site and I've basically solved the problem and had a mess of unstructured code that built other code and generated SQL and other stuff and now I've first rewritten it from Java which got the source dow... | stackexchange/codereview |
I am on the way implementing my own STL-like library in C language. The main reasons are learning DS&A better, as well as the C language itself. Here I am trying to implement Vector (a.k.a. array-list) data structure. Would really appreciate to hear constructive criticism. Please, kindly give your thoughts on how the c... | stackexchange/codereview |
I worked on a hybrid mobile application for a newspaper company.
They had a Wordpress website with news content (in a wp_posts table) which they wanted to be displayed in the application.
I built the hybrid application with HTML, CSS, JavaScript, JQuery mobile and packaged with Phonegap build.
I used php to make a conn... | stackexchange/codereview |
As an exercise, I wrote a simple function that composes a prototype chain from a list of objects by appending to the prototype chain of the first object, the rest of the objects. This is the code (example usage and tests in this gist):
var assign = Object.assign || require('object.assign');
// Non-enumerable propertie... | stackexchange/codereview |
The purpose of this code is to evaluate simple integer expressions that make use of the C arithmetic and bitwise operators while respecting C operator precedence and parenthesis. I wrote this code with portability in mind, making no use of implementation defined, or undefined constructs to my knowledge. However there a... | stackexchange/codereview |
I've got the following shell script (let say get_includes.sh):
#!/usr/bin/env bash
includes=($(grep ^#include file.c | grep -o '"[^"]\+"' | tr -d '"'))
echo "0: ${includes[0]}"
echo "1: ${includes[1]}"
which aims at finding relative include files in source code file.
So for given file like this (file.c):
#include "foo... | stackexchange/codereview |
package standardcalculator;
/**
*
* @author BSK
*/
public class calculator2 extends javax.swing.JFrame {
private String input="";//We have nothing to display on the screen,if we dont do this creates the problem of displaying the null.
private String firstOperand="0"; //Standard firstOperand.
private Strin... | stackexchange/codereview |
I'm learning Haskell on my own, and I'm wondering if this is idiomatic Haskell.
In particular: is it a common pattern to "wrap" the result in a list in order to make a function total? (that's what I ended up doing to ensure the function was total and no compiler warnings about not matching a pattern).
safeHead :: [a] -... | stackexchange/codereview |
I am making a library which can use different auth mechanisms. I have abstracted the code within an interface:
interface Authenticable
{
public function getName(): string;
/**
* Based on auth type, return the right format of credentials to be sent to the server
*
* @param Authenticable $credenti... | stackexchange/codereview |
This is my implementation of an AStar-like algorithm for maze solving.
A quick summary of the problem I am trying to solve with my algorithm might be:
A simple binary maze is given to you to solve, you may only go in the standard cardinal directions: north, east, west and south. There is a twist, however: You may also... | stackexchange/codereview |
Motivation: Have std::vector<std::unique_ptr<T>> accessibility at std::vector<T> speed.
std::vector have one inconvenience - you can't store pointers nor indexes to elements if the vector grows/alters.
To overcome this problem we usually use vector of pointers / deque (if only grow) / list / etc. Having our elements in... | stackexchange/codereview |
I made a small shell implementation in C.
It reads stdin and executes the command. It can also take in a file name from argv and execute all the arguments in the file.
It supports redirection with > and you can also run multiple commands with & in between commands.
It has 3 built in commands which are cd, path and exit... | stackexchange/codereview |
I've recently given a coding interview on a Java concurrency task and unfortunately didn't get the job. The worst part is I've given my best but now I'm not even sure where went wrong. Can anyone help give me some ideas about things I can improve on below code?
The question is pretty vague. Given 4 generic interface... | stackexchange/codereview |
I have an array of integers, I have to find all sub-arrays of different size from 1 to len(array). In every sub-array, I have to find the minimum value in it, once done I have to find the maximum value between the minimum values of all the subarrays of the same size. Finally, I have to return these maximum values in a ... | stackexchange/codereview |
I created the class ContinuousDimensionInterval, to model an interval of a continuous dimension interval, presented below.
namespace Minotaur.Math.Dimensions {
using System;
public sealed class ContinuousDimensionInterval: IDimensionInterval {
public int DimensionIndex { get; }
public readonly... | stackexchange/codereview |
I'm a beginner with C.
The below is the implementation of circular buffer using linked list. Please review my code and suggest any improvements to make it efficient or to improve in coding style.
#include<stdio.h>
#include <stdlib.h>
struct link_list
{
int item;
struct link_list *next;
};
struct link_list *re... | stackexchange/codereview |
Have a working version of MySQL implementation of ThorsSQL library done.
If you want to check it out you can find the whole thing on github ThorsSQL.
This is a follow on to previous code Reviews:
Part 3: Layer 1
Part 2
Part 1
The documentation for these classes is here:
Part 3 (Layer 2): The MySQL Implementation
MySQL ... | stackexchange/codereview |
Implementation:
static void ReverseMatrix<T>(T[,] matrix)
{
int width = matrix.GetLength(1);
int height = matrix.GetLength(0);
int startRow = 0;
int startCol = 0;
int endRow = height-1;
int endCol = width-1;
while (true)
{
if (startRow == height-1 || endRow == 0) return;
... | stackexchange/codereview |
I implemented an iterator pattern for C# using IEnumerator and IEnumerable. The goal of the implementation is to traverse a binary tree.
using System.Collections;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace DesignPatternsQuestions
{
[TestClass]
public class T... | stackexchange/codereview |
I've been working on an algorithm to declutter rectangles while keeping them as close as possible to their original location (and oriented the same way). It seems to work fine when I have less than 1,000 rectangles, but becomes much slower when there are 10,000, which I believe to be because the algorithm is inefficie... | stackexchange/codereview |
from typing import List
import itertools
my_string = "Atunci când citești un text trebuie să fii capabil să identifici ideea principală a textului și să o poți formula în propriile tale cuvinte"
my_list : List[str] = my_string.split(' ')
my_list2 : List[str| int] = [item for lis in list((len(word), word) if len(word)... | stackexchange/codereview |
Using the eclipse formatting on a class with some @NamedQueries created concatenations.
While I have been doing this for years without paying attention I just realised that may be it
is not a good usage.
So basically Which one of these Strings inside the queryis better ? Is the second one creating too many Strings? Sh... | stackexchange/codereview |
The objective of the program is to check that the weight of the bag that the user inputs and then calculate how many coins are needed to the added/removed to ensure the bag has the right amount of coins in. It needs to display the difference in weight and the number of coins to be added/removed and a total value of coi... | stackexchange/codereview |
How can I achieve a more performant tick code keeping my minimum frame rate high?
installLoops() {
window.requestAnimationFrame(this.loop.bind(this));
}
loop() {
this.now = Date.now();
var delta = this.now - this.last;
this.last = this.now;
this.dt = this.dt + delta;
... | stackexchange/codereview |
Context
I'm looking into design patterns. My first try is using the Decorator Pattern.
Question:
Is there another (maybe standard) approach to applying modifications in a decorator other than explicitly overwriting in the constructor?
-
Car Interface
<?php
interface CarInterface
{
public function drive();
}
C... | stackexchange/codereview |
I have solved Project Euler's problem number 47, which reads:
The first two consecutive numbers to have two distinct prime factors
are:
14 = 2 × 7
15 = 3 × 5
The first three consecutive numbers to have three distinct prime
factors are:
644 = 22 × 7 × 23
645 = 3 × 5 × 43
646 = 2 × 17 × 19.
Find the first fou... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.