instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
This is solution to the assembly line problem. Here is complete description, which is too big and verbose to re-describe. I apologize for the inconvenience of the hyperlink.
Note: I do understand merits of unit testing in separate files. But deliberately added it to main method for personal convenience, so I request t... | stackexchange/codereview |
I've written this class that downloads an images, the URLs for which are read from a local .txt file. I'm keen to make sure my code is safe and efficient.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include<cassert>
#include <algorithm>
#include <numeric>
#include <functional>
#include <... | stackexchange/codereview |
I've been working a strategy game for iOS for a little while, and each time I add functionality to the game model I'm finding myself building a lot of UI code to sync up with it. I believe that my latest creation could use some code review.
The basic idea is that each worker can have certain job permissions turned on ... | stackexchange/codereview |
I'm trying to build an iterator (enumerator) that can select specific elements in an Expression tree by traversing the tree and deferring further iteration until needed.
My following implementation intends to keep it simple by leveraging the ExpressionVisitor. But since a visitor-pattern uses recursive stack calls to ... | stackexchange/codereview |
I'm trying out a new continuous histogram coloring method for Mandelbrot rendering in R, and since it requires three loops (three passes), each of them doubly nested, there should be a way to vectorize the code to speed it up.
However, I'm not yet familiar enough with vectorization in R, especially when conditionals a... | stackexchange/codereview |
Consider the following C++03 code:
#include <algorithm>
#include <deque>
#include <boost/iterator/counting_iterator.hpp>
const unsigned int _count = 0x10000;
struct recentFunctor {
recentFunctor(const int base, const int firstOffset)
: _base(base),
_firstOffset(firstOffset) {
}
int getIndex(const int... | stackexchange/codereview |
The code reads in integer array from user input and builds a minimum heap via an iterative scheme.
Are there any edge cases in which this approach would fail?
For the following test case/command sequence:
1 4 3 10 12 6 -1
remove
remove
print
My output is 4 6 10 12 instead of 4 10 6 12, is this an invalid implementatio... | stackexchange/codereview |
To find the days off for our custom accounting software there is this method used to find when is Easter in any given year.
private static DateTime Easter(int year) {
int a = year%19;
int b = year/100;
int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30;
int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*(... | stackexchange/codereview |
I wrote code that replaces integers from 0 to 3 with strings. I was only allowed to use getchar() and putchar(). If the input is 1, the output will become "one".
#include <stdio.h>
int main()
{
int c;
char* arr[4] = {"zero", "one", "two","three"};
int i;
while ((c = getchar ()) != EOF)
{
... | stackexchange/codereview |
This is my first Scala program, so I'd appreciate any feedback but especially feedback specific to Scala, for example situations where I could have utilised a feature better or where I've done something unidiomatic.
import scala.collection.mutable.HashMap
object Main extends App {
// Type alias to shorten the Teams ... | stackexchange/codereview |
Intro
In order to get familiar with and improve my Rust skills I coded Tic-Tac-Toe. I want to write good Rust code, any feedback regarding why my code isn't in a Rust style or improvements that could be made would be very helpful.
Question
Is there a better way to implement my "new" method for the Ttt struct? I don't p... | stackexchange/codereview |
I have written an implementation of malloc() and free() for Linux using the sbrk() system call.
When memory is requested, it checks if there is a large enough chunk available already, if there is then that gets returned to the user, otherwise a new block of memory will be requested from the kernel. When memory is free'... | stackexchange/codereview |
The code below extracts data from one web page - I emulate search, select all results from the list and when the list appears (42000 items) I loop through these items.
I get an id value from their href to create a proper link (example href is href="javascript:NeuFenster('rb_id=570964&land_abk=bw', so I don't want any J... | stackexchange/codereview |
I'm currently going through a large Python program, with an eye to making it more readable and maintainable. Currently using Pylint and other code review tools throws a lot of unused variable warnings because of the way I've been using .format(). Since this program manipulates a lot of text, I use .format() quite a lot... | stackexchange/codereview |
I wrote an extension method for bitmaps which finds the brightest rectangle (with specified width & height) within an image.
Hopefully my code comments eliminate any confusion. If not, please let me know what I need to elaborate on.
I would like some help reducing repetitive calls to the conjoined Bitmap.GetPixel & Col... | stackexchange/codereview |
I am writing code to implement data sync from multiple sources. I want code to be maintainable to add more data sources if required.
Here is the pattern I wish to follow:
class Source1Client:
def get_domain(self):
pass
def get_endpoint(self):
pass
def get_headers(self):
pass
... | stackexchange/codereview |
I generally prefer to work with EF by specifying exactly the data to fetch from the DB with regards to Navigation Properties/Lookups and the like, so we wrote this cache system to limit the number of calls to the database.
public class DBCache<TContext, TKey, T> : ICache<TKey, T> where T : class, IDbPk<T>, IAutoInclud... | stackexchange/codereview |
This is a recursive descent parser for simple language with following grammar:
PROGRAM <- {STATEMENT ';'}* RETURN_STMT ';'
STATEMENT <- NAME_BINDING | TYPE_DECLARATION
TYPE_DECLARATION <- named_param identifier
NAME_BINDING <- identifier '=' EXPRESSION
EXPRESSION <- (simple arithmetics with (), +-*/ and unary minus, ar... | stackexchange/codereview |
I'm learning how to use SequelizeJS.
What i found was that (at least for me) the definition of the DB model was too invasive in my code when creating object.
I was thinking that the user of your model should not have to learn how to use sequelize (or even that i use it at all)
So I created 2 class that add a layer on t... | stackexchange/codereview |
I'm using Codefights to improve my skills. This challenge is to change the number submitted as total minutes into the digital read out on a clock i.e. hh:mm and then add all the numbers to together. So h + h + m + m.
My code works and I've passed all the tests, but it duplicates the same process for variables I've name... | stackexchange/codereview |
I am calling a C library via P/Invoke. That library needs to be called in sucession with an increasing unsigned int, and returns a pointer. That pointer is then mapped to a managed type, until it returns a NULL pointer.
In C, the idiomatic way to write it, is probably for(i=0;;i++), but what is the most idiomatic way ... | stackexchange/codereview |
This is a challenge on Codewars I took years ago. Task is to find all prime numbers that are also a prime number when reversed, i.e. 13 -> 31 is such a number.
This is still the answer with the most upvotes in the categories 'Best practice' as well as in 'Clever'.
Any improvements or thoughts about this piece of code? ... | stackexchange/codereview |
So I decided to make a more efficient solution to a Google interview question where they ask you to either find the lowest or second lowest value in an array without using the max or min methods. I believe it is more efficient because you can use my method to find any nth lowest value in the array so it solves for all ... | stackexchange/codereview |
Not sure if I am overcomplicating the requirement but this is what I need (for simplicity I will show a the List<Map<String, Object>> as a JSON):
[
{
"project": "Project1",
"workType": "Dev",
"taskTitle": "Dev Title 1",
"effort": 150
},
{
"project": "Project1",
... | stackexchange/codereview |
I wanted to build similar to lodash get method. Where you put the object and key name to get value if exist. I have done this but just wanted to have more better approach. Here is what has been done so bar.
var x = {
d: 'new vale',
a: {
b: {
c: {
e: 'value'
}
}
}
}
function getVal(ob... | stackexchange/codereview |
I tried to create a class for porting Java's synchronized keyword to C++ using below code using *nix pthread's library.
In general my test cases seem to work, but since this is a very critical topic I would like to have someone else have a look on it in case I missed something which might invalidate my test cases.
The ... | stackexchange/codereview |
I've recently had time to devise another program so this time I decided to write the Perlin Noise algorithm in code. I have succeeded and the code works but I can't help but feel that my practices while writing are still not as good as they should be (especially since I'm still pretty new to the topic of programming). ... | stackexchange/codereview |
Recently wrote a brainfuck interpreter in Go.
Here's the Github Repo Brainfuck
Areas that need work
The parsing for brackets [] is still buggy and is known to fail when dealing with nested loops i.e [[]] any hints on how to approach the problem would be greatly appreciated.
After looking at this repo. He creates a comp... | stackexchange/codereview |
Related to this code golf challenge, I tried to find acronyms with Haskell without using regular expressions.
The idea is to split the input string at every space or dash before finally gluing the heads of these parts together, if they are uppercase.
This is my code:
import System.Environment
import Data.Char
main :: ... | stackexchange/codereview |
The idea about this code is that it's a full replacement of Redux — in 22 lines of code.
let state = null
const beforeSetStateCallbacks = []
const afterSetStateCallbacks = []
export const beforeSetState = (fn) => beforeSetStateCallbacks.push(fn)
export const afterSetState = (fn) => afterSetStateCallbacks.push(fn)
exp... | stackexchange/codereview |
This program is made, so it graphs a spiral with N steps.
What else could I add to this program?
Can this code be improved?
import matplotlib.pyplot as plt
N = 100
arr = [(0, 0)]
x = []
y = []
for u in range(1, N):
for i in range(1, 5):
if i % 4 == 1: # first corner
arr.... | stackexchange/codereview |
I'm trying to change how our system generates PDF files. Currently I have a class for each PDF that goes through the model for the PDF and fills in the properties. I want to change that to a self contained class that can be called in the background through Hangfire. To that end I've settled on decorating the properties... | stackexchange/codereview |
Purpose: write Java program that downloads a list of URLs specified on commandline in parallel (simultaneously), reporting download completion every second.
My solution follows below, please point out areas for improvement / things you would redesign.
package org.test.mk.pjwget;
import java.io.*;
import java.net.URL... | stackexchange/codereview |
I have written below code to create/get a dict with n number of key, value pairs. Main idea is to use the same instantiated class object across my code and play around with k/v pairs.
Current implementation:
class DataForm:
def __init__(self):
self.data_dict = dict()
def create_key_value_pair(self, ke... | stackexchange/codereview |
I have 2 Dictionaries. I am trying to optimize this code to run as fast as possible.
This is for solving Shanks Baby Step Giant Step Algorithm
Algorithm:
Given b = a^x (mod p)
First choose n, such that n^2 >= p-1
Then create 2 lists:
1. a^j (mod p) for 0 <= j < n
2. b*(a(inverse)^n)^k for 0 <= k < n
Finally loo... | stackexchange/codereview |
I recently answered a question that had an interesting problem statement (I've slightly modified the wording):
I have an abstract class A which is base for the other classes, let's
say B and C.
Classes B and C should have a handle_input() method, but
argument number and types may vary from B to C.
I also have a fu... | stackexchange/codereview |
I'm making a Windows service that watches a directory for new files to process them.
I hit a race condition between the file copying going on and me trying to process it. Going by a SO answer I wrote the following wait-and-retry method to make sure I can work with the file:
public static void WaitForFile(string file, C... | stackexchange/codereview |
I've written some code that uses a SortedDictionary to count the number of occurrences of a character in a string.
How can I improve this code? What should I be doing differently? Any advice at all would be helpful.
static void Main(string[] args)
{
string longText = @"The quick brown fox jumps over the... | stackexchange/codereview |
I have created a code for filtering a list of strings and redisplaying this list. I check if string is starting with a certain letter.
It seems to work, but I wonder if I did all right? Havent I forgot about something?
public class AlternateRowArrayAdapter extends ArrayAdapter
{
private int[] colors;
private Li... | stackexchange/codereview |
A situation has come up in which we have a block of code that will be repeated in multiple files, and this block of code has to:
Create some object based on the values of other controls/properties.
Set a property on another object to be the object from #1.
Here is an example of what this looks like:
Repeated code be... | stackexchange/codereview |
from itertools import izip_longest
def partition(n, iterable):
p = izip_longest(*([iter(iterable)] * n))
r = []
for x in p:
s = set(x)
s.discard(None)
r.append(list(s))
return r
print partition(2, range(100))
I saw it from a recruit and the company said there were potential problems,... | stackexchange/codereview |
I'm writing a pretty complicated piece of UI with angularjs. I've been using angular for about 2 weeks. I'm going to post the controllers I feel are the most confusing to read, and am wondering the following:
Could these be more "angular" (done in a more angular way?)
Is it normal to have this much logic in controller... | stackexchange/codereview |
Thanks to the discussion in this issue combined with issue 1886 and issue 716 and issue 570 I was able to integrate the Toolbar of react-native-paper and with react-navigation.
As I am quite new to react-native development I am unsure if I might have broken some don'ts. I am also unsure about the prop-types I have defi... | stackexchange/codereview |
Long time coder, but very very new to C++. I'm trying to put together my first real-sized project and figuring out what I need to change about my script-kiddie style of C++ to get there. Below is my working code.
#include <math.h>
#include <vector>
#include <iostream>
#include <stdexcept>
enum class Metric { Cosine, E... | stackexchange/codereview |
From a previous question, I got the idea of moving boilerplate code structures into a helper function and passing in a lambda function to it.
I then applied the idea to a data access class (code below). I'm not sure how to handle the result of my ProcessDatabaseCall helper function; it seems irrelevant to my pattern o... | stackexchange/codereview |
Okay so I built this search page that searches for posts but my current code seems so bloated and inefficient.
My script(search page)
if(isset($_GET['title']))$title = $_GET['title'];else{ $title = ''; }
if(isset($_GET['ad_brand']))$brand = $_GET['ad_brand'];else{ $brand = ''; }
if(isset($_GET['min_range']))$min_range ... | stackexchange/codereview |
The purpose of the code is to apply adapter pattern to put an extra feature for searching through json object.
I hate deep nested json object because it makes my code look messy when access through each node. I made an adapter class that can search through this deep json. So basically instead of having this messy code
... | 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 had an interview recently and discovered that I'd forgotten some of the basics. I've been playing around again and have written a function that will take a binary string (there is no validation yet) and returns the ASCII representation of said string.
I'm looking for advice or tips on how it could be improved. I don... | stackexchange/codereview |
In the prior obsolete implementation of std::deque, I used two std::vectors to contain the elements. But the standard guarantees that pointers and references to elements aren't invalidated when an element at either end is erased or when an element is inserted into either end, which the prior implementation doesn't:
To... | stackexchange/codereview |
I am practicing object oriented design and have taken Tic Tac Toe as an example. I have written first all the requirements and then started writing code. I would like to get it reviewed so that I can improve my skill further. Please provide suggestions.
I have placed code at this GitHub repo.
Square.js
//Square class
f... | stackexchange/codereview |
I tried to make a social media slider with jQuery, HTML and CSS. This is available as a Fiddle.
Can I improve or debug any elements of it?
$(document).ready(function() {
$('.sa').hover(
function() {
$(this).css("margin-left") == "130px"
{
$('#sociallili').stop().animate({"margin-left": '+=130'})... | stackexchange/codereview |
I have a String which is coming in particular format so I want to parse that string into map. I have a below method which parses String to a Map and it works fine.
public static Map<String, String> parseStringToMap(String payload) {
Map<String, String> map = new HashMap<>();
try {
for (String part : pay... | stackexchange/codereview |
I had to write a RPN calculator in C as one of my homework problems, but if someone could critique my code and suggest any improvements, that would be fantastic! I haven't added any overflow errors or input errors, but I will add that eventually.
My code takes operands and operators from the command line (e.g., 3 4 - ... | stackexchange/codereview |
When using MVC 4 Razor (I am new to web development), I get concerned about my understanding of interactions between the database and the client. Much like all appilications these days, there is a lot of data that is presented to the user and in different fashions. I have looked around, and I can't find a concrete C# e... | stackexchange/codereview |
I made a PHP mailer script does the basic validation of fields, return errors, else submit if all is good. But it also has a honeypot field that is not required to be filled in (I'm assuming by hiding it using CSS a spambot will fill in the field anyway). If the field is not empty, it opens a text file and writes/appe... | stackexchange/codereview |
Users can define custom controls that are added to an entry form at run-time. The values of these controls are later stored in a MySQL database. Optionally, users can define 'recipes' to auto calculate some controls.
For an example, a user could enter Gross and Tare weight and use a FieldCalc for the Net Weight. In th... | stackexchange/codereview |
Using only Python 2.7 and the standard library (no imports):
Determine if a point is inside the rotated rectangle.
Test point 1: 670831 4867989
Test point 2: 675097 4869543
Rectangle:
Vertex 1: 670273 4879507
Vertex 2: 677241 4859302
Vertex 3: 670388 4856938
Vertex 4: 663420 4877144
Can th... | stackexchange/codereview |
I have been working on this project for a little bit and it's my first major python program. It downloads information about current and upcoming weather warnings for Ireland and displays them with tkinter. Would be grateful of suggestions or critique!
https://github.com/Sn4u/met-eireann-status/tree/master
met_eireann_s... | stackexchange/codereview |
I'm developing on a web application where I have a start and a finish date and time and have to set the duration between it.
There are inputs for dates and times.
Then, I have this function which calculates the duration between the two of them, and they are working properly. The duration, though, needs to be dynamic. S... | stackexchange/codereview |
I was messing around with ssh and decided to write a python program that scans for any connections that aren't from the system, then terminates them. It works well for many connections from my iMac to my MacBook. A more in-depth explanation of the program is written at the top of the code. I'd appreciate feedback on an... | stackexchange/codereview |
I created a code that runs 60 optimizations through solver through 4 series of loops (each with 15 'iterations'). The code works great but it is taking FOREVER to run through (over an hour). Each optimization is a simple linear model (global solution is found), just changing which month I am looking at.
Problem setup: ... | stackexchange/codereview |
I have the following function and want to simplify the code to make it more readable by eliminating redundant lines:
Function AddSheet(shtName As String, Optional readOnlyFlag As Boolean = True) As Boolean 'Add new worksheet to current workbook at the end
If readOnlyFlag And IsSheet(shtName) Then
AddSheet... | stackexchange/codereview |
I'm reading an array (of unknown length) of modules package.json files in order to extract the "style" property and store it in an array of its own:
var gulp = require('gulp')
, path = require('path')
, Promise = require('bluebird')
, fs = Promise.promisifyAll(require('fs-extra'));
let components = [
'comp1'... | stackexchange/codereview |
I am trying to get the value from the from and and pass it to the API and output the result to the DOM. The code works fine but I am 1000% sure there is a better way to write THIS. Thanks for the help and I am new so trying to learn.
JS CODE
const textInput = document.querySelector(`#search__box`);
const btn = docume... | stackexchange/codereview |
I currently use a data structure like this:
(def sample-board
[[{:mine true} {:warn 2 } {:warn 1} { }]
[{:warn 2 } {:mine true} {:warn 1} { }]
[{:warn 1 } {:warn 1 } {:warn 2} {:warn 1 }]
[{ } { } {:warn 1} {:mine true}]])
Now I want to create a copy of the fi... | stackexchange/codereview |
hashdic.h -- suggested for direct include or copy paste to your project.
#include "string.h" // memcpy/memcmp
typedef __uint32_t u32;
typedef __int8_t i8;
typedef __uint8_t u8;
u32 MurMur(const char* key, int count) {
#define muR(x, r) (((x) << r) | ((x) >> (32 - r)))
u32 seed = 0x8e96a8f2;
int n = count ... | stackexchange/codereview |
This code is supposed to grab live camera feed, display feed in a window, mark in rectangles all detected faces, get the biggest detected face (by total area), display it in separate window, convert it to grayscale and finally save as PNG to hard disk, in project directory.
Any ideas for optimizing this code? It has to... | stackexchange/codereview |
I tried to implement as many changes suggested as possible as well as expanding the code base according to the suggested link. The original question can be found here. It does solve 4x4 and 9x9 Sodukus.
What should I do to make it more Pythonic?
This is what I came up with:
from numpy import *
import sys
TEXT = '.1234... | stackexchange/codereview |
Sita shortlists 4 gifts priced at r1, r2, r3 and r4
respectively. She wants to buy 3 of these gifts such that it doesn't
exceed her budget of x.
Input and Output Format:
Input consists of 5 integers that correspond
to r1, r2, r3, r4 and x. Output consists of 2 integers. The first
integer corresponds to the min... | stackexchange/codereview |
My php page displays a slider of images and when the user clicks on an image(.item), the div below (#team_single) changes the content without reloading the page. Content of the div changes also when the user clicks the arrow of the slider (.slick-prev, .slick-next, .slick-arrow).
I'm looking for a way to improve the fo... | stackexchange/codereview |
Edit - here is my modified code: http://jsfiddle.net/#&togetherjs=GzytydCsRh
Can someone take a look and give me some feedback? It seems a bit long still but that is the first time I used functions.
I am reading a bunch of CSV files and using glob to concatenate them all together into separate dataframes. I eventuall... | stackexchange/codereview |
There's a csv file with format:
x0, y0, v00
x0, y1, v01
...
x1, y0 v10
...
And what I want to do is to plot a heat map, in which at location (x, y) the value v is plotted with corresponding color. Below is my current implementation.
import random
import numpy as np
import matplotlib.pyplot as plt
def create_test_csv... | stackexchange/codereview |
I am trying to cleanup a dataframe (and the code) in Pandas.
I used to use the modin library before but I have since switched from Win 10 to Win 11 and none of ray and dask libraries work on Windows 11 and I have raised an issue with respective repositories.
In the meanwhile, I am intending to use multiprocessing as an... | stackexchange/codereview |
I have been trying my hand a bit at creating a big integer class in C++. This is a continuation of a homework assignment.
The class stores a big integer in a double linked list. Each slot contains 8 digits of the number. It is possible to create an instance from an integer or char array. Negative numbers are supported... | stackexchange/codereview |
In this class I made a webscraper for a cryptocurrency website to get the name and the price of each currency. There are maybe API's that I can also use, but I thought it is better to gain some knowledge doing it with scraping.
import requests
from bs4 import BeautifulSoup
import json
class Coins:
def __init__(s... | stackexchange/codereview |
I've just picked coding back up for the first time in a long time, so I understand if your eyes bleed looking at this code. It all works, but I'd be grateful for any tips (how to improve the python code, how to use Spacy's semantic similarity vector feature better, how to make it work faster, etc).
The main product of ... | stackexchange/codereview |
I'm learning CUDA C++ (and C++). Can you guys give me some feedback on my basic templated matrix implementation?
A brief explanation of my decisions:
First things first: I can't use STL classes/functions in my CUDA code.
I can't use C++ 14 (or newer) features.
I'm using templates to give support to floats, doubles and... | stackexchange/codereview |
I have written the solution of the Mars Rover problem in JavaScript, with a sort of functional approach. I would like to know how I can improve it and if there are any additional edge cases I missed in the tests.
A rover’s position and location is represented by a combination of x and y co-ordinates and a letter repre... | stackexchange/codereview |
Suppose we have stock price history, and we are allowed to buy only once and sell only once. The problem is to find the maximum profit we can make. Here is my code that I tested for basic test cases. I'm wondering if there are possible improvements for logic correctness.
My major idea is to keep record of in history mi... | stackexchange/codereview |
I've made this implementation of a classroom with teacher and students using mediator pattern. Mediator is the teacher and colleague are studends.
Main function is the following. Main function creates a teacher and then she says will teach to some students. Finally, she try to spread a concept and a student will tell w... | stackexchange/codereview |
I'm thinking about a unified error handling interface.
I've come to conclusion that the errno global variable style isn't so bad, and decided to implement an improved version of it: every function called sets an error code to a global error variable through the get/set functions.
The difference with the errno pattern ... | stackexchange/codereview |
There's a part in my page where you can add, edit or delete school details, and it wasn't supposed to save entries to the database until the user hits Enter, so I save all data in an object first.
My object looks like this:
schooldetails : {
"1": {
"school_ctr":"schoolctr_1",
"school":"Fiat Lux Academe",
... | stackexchange/codereview |
I am relatively new to C++ and I had this task to solve, where you are given a number and you have to create an nxn array of integers, where you would have to continually switch directions (right, down, up, left) until you fill it.
Example:
1 2 3 4
12 11 10 5
13 14 9 6
16 ... | stackexchange/codereview |
Write a method range that accepts an ArrayList of integers as a parameter and that returns the range of values contained in the list, which is defined as 1 more than the difference between the largest and smallest elements.
I feel like I'm beginning to understand conditionals, but for some reason this just makes me c... | stackexchange/codereview |
I have 3 tables such as books, tags, book_tags. my objective is to insert books info along with tags (tags can be multiple or single). I have two methods one is insert books info 1st and then add tags for that last added book. my code is working but I'm not sure this is the best way to do it
public function addTag($tag... | stackexchange/codereview |
Django implements a System Check framework that enables apps to perform checks on settings, runtime, etc. When creating an app, one can plug checks with the framework by following some requirements, one of them being how errors are reported.
The integrations are actually ok, but the error management system is a bit too... | stackexchange/codereview |
This program asks the user for a players name, # of goals, saves, games played, etc. This information is ten organized on a .txt file along with the time the information was logged. users can also compare the players based on # of goals, Assists and saves made.
If anything can be improved, cleaned or replaced let me kn... | stackexchange/codereview |
The div and add functions are located randomly in my package structure. I have a function with this signature:
def calc(x, y, func_name='add')
How do I implement this function?
My idea is to import all the modules, then use the dir function, like so:
def import_submodules(package, recursive=True):
""" Import all s... | stackexchange/codereview |
I was trying to solve this problem. I thought of any possible relation between the number of matches among subsequent substrings, but could not find one. So, the probably naive solution that I drafted was:
#include <iostream>
#include <cstring>
using namespace std;
int n;
char str[1000000];
int sim(int i, int len)
... | stackexchange/codereview |
I am new to C, and I have very little formal education on programming (Although I am currently in college). I work as a Robot Automation technician, and me and my team are required to document a lot of things. I wrote a program that we run on our robot computers to do this, but the language (RAPID by ABB Robotics) had ... | stackexchange/codereview |
I am building a .Net Core 6.0 application that uses Entity Framework.
I have situation where I need to apply the filter(Where clause) based on two properties (eg: Guid? skillType, string skillName). These properties may or may not have values, means that
Neither of the property will have value
Either of the property w... | stackexchange/codereview |
I have a modal for adding new contacts, in order to disable the save button if no data has entered I check if the contact object is empty, is there a shorter way to check for an empty complex object?
let isContactEmpty = true
Object.keys(contact).forEach(field => {
if (typeof contact[field] === 'string' && con... | stackexchange/codereview |
The following is some code that is used to provide the frontend with certain parameters when rendering a form. The parameters are conditional based around what data is being changed, getNewSaleFormOptions provides a way of quering these options using a GET request and url params (ie /sales/new?dealership=11&vehicle=2),... | stackexchange/codereview |
My application will accept textarea content that is submitted by a user, and i would like some people to review my code to make sure there is no security vulnerability such as XSS.
My mySQL column that will save this information is a column of type TEXT and is not required and nullable.
When storing the data to databa... | stackexchange/codereview |
Description
This is my code for the Weekend Challenge Reboot - Tic Tac Toe Ultimate.
The game can be played here: http://www.zomis.net/ttt (along with some other variations that are also use the same code base, but with other 'controllers').
This question contains the game model and a 'controller' for the TicTacToe Ult... | stackexchange/codereview |
I'm writing a class that acts as the base for almost all objects in my project. I know this class technically doesn't represent a tree structure, because it can have more than 2 children. What should I change? Should I be using smart pointers? I'm a self-taught C++ programmer, so I've got much more to learn.
Here's the... | stackexchange/codereview |
I am building a store. When a user decides to make a purchase I need to store it in the database, but since the purchase might be of more than 1 item I'm wondering which way is the best to insert multiple rows, here are my 3 options.
I use a database object that combines PDO with PDOStatement, which is why I don't defi... | stackexchange/codereview |
The netlink service is used, among other things, to notify userspace about hotplug events (e.g. "a device has been connected"). These events come in the form of packets, which follow the following format, explained here:
The netlink packet contains a set of null terminated text lines. The
first line of the netlink p... | stackexchange/codereview |
I'm updating an Excel workbook that I've inherited and had to figure out if/when/where Functions/Subs were being called. Ran into instances where in the code I couldn't find it being called and deleted/comment out, only to have it run into an error later on since a button uses it. The code that follows is an attempt to... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.