instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I'm trying to have one WPF application to communicate with an other application when something change on the UI. For example : a slider changes and I send the new value or a textbox input change and I send the new input value.
The second application is listening and receive those changes to use them in some way, doesn... | stackexchange/codereview |
I created a program in python that reads a file and outputs a frequency graph of the words it contains. Any feedback or tips would be appreciated.
from re import split
from collections import Counter
size = int(input("Output window size(in chars): "))
with open("text.txt", "r") as f:
words = [w for w in split(r"[\W... | 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 a long running operation that I need to wait for or timeout.
I have working code, but I would like your opinion on improving it.
public bool RegisterEquipmentListUpdate(int ID)
{
if (Authentication.CheckSession(Session))
{
var wcfmonitoring = new WCFMonitoring.MonitoringDatabaseClient();
... | stackexchange/codereview |
I know as a matter of fact that there are many areas upon which my code could be improved. I was wondering if anyone can provide me with suggestions on how Taboo class and tests can be improved. Suggestions of any kind and scope are very welcomed. it would be even better if reasons can be provided along with the sugges... | stackexchange/codereview |
See the previous and initial iteration.
I have incorporated almost all the suggestions by Peter Taylor:
The actual method returns a BigInteger instead of String.
The actual method can deal with Fibonacci numbers with negative indices, so there is no any need to throw IllegalArgumentException.
The only base case that i... | stackexchange/codereview |
I'm trying to develop code to filter my e-mail with JavaMail, but I doubt it's the best way of doing this. And I want to collect all messages without attachment.
package service.forkinjoin;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.RecursiveAction;
impo... | stackexchange/codereview |
I'm relatively new to .Net/UWP networking and have been trying to make sense of the APIs. I'd like to implement a TCP client that is capable of reading and sending messages independently (there is no protocol and all messages are independent).
Typically (e.g. in a POSIX C++ server), this would be done by spinning up a ... | stackexchange/codereview |
It may seem a bit obsessive and/or pedantic, but the following script allows me to see when posts are ready for reviewing.
I developed this UserScript for use with TamperMonkey to allow me to have a tab open for a review queue, and then when an item is ready for review, the tab will be highlighted with an asterisk on t... | stackexchange/codereview |
Here I asked this question:
My goal is to go through the list of all English words (separated by
'\n' characters) and find the longest word which doesn't have any of
these characters: "gkmqvwxz". And I want to optimize it as much as
possible
I updated the code with the help of suggestions from answers, but I s... | stackexchange/codereview |
I have come up with a code that takes the total number of an array and creates ? for each, then separates them by a comma; leaving me a list like the one below:
?, ?, ?, ?, ?...
I am using this for my sql queries with prepared statements, instead of having to create the prepared statement each time, I want to just hav... | stackexchange/codereview |
I am quite new to the MVC concept. I already know how to program object-orientated from other languages like C++ or Java. I have implemented a little login system for test purpose.
I am not sure if my implementation is the best way to follow MVC. Any feedback is welcome.
The class ControllerUser is instantiated in a fi... | stackexchange/codereview |
I was asked by a friend to write a simple page for selecting members to various tasks. The members are listed in a textfile, along with how much they are willing to contribute (Usually a number between 0 and 1). Bellow is an example of such a list:
name, mebershipdegree
Noen, 4
John Doe, 1
The rock, 0.5
Ally MacBeal, 0... | stackexchange/codereview |
I need to divide scoreResult into pages (which is already ordered by score column from highest to lowest), and each page cannot contain too many records (e.g. 12 is a limitation in my example), and each page cannot contain duplicate id1, and each page needs to be ordered by score from highest to lowest.
Here is my work... | stackexchange/codereview |
I would like to aggregate rows of my dataframe together, following those rules:
Rows are grouped by "Id", and sorted by anticipation
One row can only be aggregated with rows next to it, with the same "Id"
The "Anticipation" of the new row is the weighted mean of the "Anticipation" (weighted by "Size") of aggregated r... | stackexchange/codereview |
I have found that there is a distinct lack of an RPN calculator available to me, so I decided to make my own. I am still adding new functions to it, but as of now, I would like to refactor my code.
Main of JavaRPN
Because this is a small problem, and I haven't made a GUI for it, I only use one class.
package owl;
impo... | stackexchange/codereview |
I want to reduce some repeated code in my Java 1.8/Spring Boot application, and to that end I tried to make a reuseable asynchronous utility module. In essence its an async List.forEach that takes a List and a consumer for each item of the list. Output is optional.
AsyncUtilImpl
import org.springframework.beans.factor... | stackexchange/codereview |
y is the value I am searching for. Is this the correct implementation for binary search?
y= 3
x= range(0,100)
left = 0
right = len(x)-1
mid=int((left+right)/2)
while x[mid]!=y:
if x[mid]>y:
right = mid
mid=int((left+right)/2)
if x[mid]<y:
left = mid
mid=int((left+right)/2)
| stackexchange/codereview |
I have some JS code that when the user clicks the "add" button, some text is displayed to a textarea.
The code seems to be working OK. However, I realize I must refactor the code so that I am using only the one on click function instead of the six that I have for each of the 6 add buttons.
$('#row_split_id_cover_letter... | stackexchange/codereview |
Problem Statement
Input Format
The first line contains a single string, a. The second line contains a single string, b.
Constraints
1<= |a|,|b| <= 10^4
It is guaranteed that and consist of lowercase English alphabetic letters (i.e., through ). Output Format
Print a single integer denoting the number of characters you m... | stackexchange/codereview |
I am working on a sql query for the following scenario:
Get all available offers for registered demand (offers from profiles
should not be from profile which had registered demand). After that
get all available offers from this initial profile which match any
demand from any other profile.
I ended up with this query:... | stackexchange/codereview |
Changed Program based on suggestions. New Code: Job Scheduling Algorithm 2
I have created an algorithm for job scheduling. The algorithm goes through sub-lists in order with two nested for loops. Inside the nested for loops, the algorithm counts how many tasks for each job are completed. If this is equal to the number ... | stackexchange/codereview |
I'm trying to loop through an array, add " before, ", after each member but ommit the , at the very last member in order to generate a JSON string:
const generate_list_data_attribute = (attribute_name, from_array) => {
let string = '';
from_array.forEach((element, key, array) => {
if(Object.is(array.le... | stackexchange/codereview |
I am taking Stanford's Introduction to Databases Self-Paced online course. I have gone through the videos in the SQL mini-course, and I am having trouble completing the exercises.
The following is the question from the SQL Social-Networking Query Exercises, Question 5:
For every situation where student A likes studen... | stackexchange/codereview |
I have the following code (for Country and City classes key_name is numeric id with addition of 'i' at the beginning):
def add_country(country, country_name):
if country and country_namef and country_name != '':
return Country.get_or_insert('i'+str(country), country_name=country_name)
else:
return None
d... | stackexchange/codereview |
The below code filters my contacts according to a search term the user typed.
Is there a way I can avoid explicitly writing all the object keys but keep the readability?
contacts = contacts.filter(
contact =>
contact.firstName.toLowerCase().includes(search) ||
contact.lastName.toLowerCase().includes(s... | stackexchange/codereview |
I tried implementing TLV(https://en.wikipedia.org/wiki/Type-length-value).
Actually my implementation is more than TLV because it supports additional "Tag" elements (which you can use for naming certain TLV objects) for TLV objects.
My goal is to serialize the array of TLV objects to byte array and vice versa (this I d... | stackexchange/codereview |
[This is a follow-up question to: Displaying TimeSpan as largest interval (with units). The code listed here has been refactored since the original question was posed. Please note that the scope of this question is limited to the declaration and implementation of the listed method.]
The method listed below is used in a... | stackexchange/codereview |
I try to generate with ansible a folder structure for a webserver with users and linked projects.
The playbook works. But with more users and projects it gets quite complex to handle.
How can I simplify my code or vars sections?
I read a hint about using blocks so that all tasks inside it could use the same loop.
Is t... | stackexchange/codereview |
This is a simple application that will eventually manage certain files for video games. For now, I'm only posting code that handles fetching, adding, and viewing games.
I'm trying to keep things incredibly simple and pure while learning WPF and MVVM, so my goal is to avoid frameworks. Please note that I'm not too conce... | stackexchange/codereview |
http://jsfiddle.net/xkuZF/6/
function func() {
document.body.scrollTop++;
}
window.onmouseover = function() {
clearInterval(interval);
};
window.onmouseout = function() {
interval = setInterval(func);
};
var interval = setInterval(func);
Do you think that there are any better ways of doing this code?
... | stackexchange/codereview |
In a larger project, I need a (rather simple) expression parser able to accept numerical values, operators and string identifiers. Fine, a lexical parser fed with some input which gives tokens one at the time to the syntactic parser. As a token can contain one single value type at a time, I decide to use an union. Prob... | stackexchange/codereview |
Is this code safe from injection, xss and whole other attacks or no ?
The below code is for search box :
if(isset($_POST["query"]))
{
$output = '';
$string = $_POST['query'];
$search = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
$stmt = $con->prepare(" SELECT * FROM topics_categories WHERE cat_name LIKE
? LIMIT 3"... | stackexchange/codereview |
After finally having enough of the hacky batch-based workflow for a project, I tried "porting" it to Maven. This is my first time using a build tool for Java, so there's probably a lot of room for improvement.
General setup
B:\WORKSPACE\COM.MSGPROGRAMS.AUDIRAS
│ .classpath
│ .project
│ icon.ico // icon used for t... | stackexchange/codereview |
I have a problem with my printing program, in which it uses up too much resources while printing (to paper or to .pdf). I try to manually dispose as much as I can, but for example, when I tried printing 300 pages, the program itself used up around 500mb of memory, and I would like to avoid that. When the program finish... | stackexchange/codereview |
the One of Unix core commands is yes which simply prints infinity number of letter y.
I read a blog post (https://matthias-endler.de/2017/yes/) about how people optimize it to output y with a speed of 10 GB/s. I get 7.5 GB/s on my machine using this command.
I tried to achieve similar results with Java but it stopped a... | stackexchange/codereview |
I just made this responsive image solution, but I'm not sure if it's the best way to do what I'm trying to achieve. Use cases can be found at http://responsimage.com/.
/* responsimage.com v0.2.3 */
(function ($, window, Date) {
'use strict';
$(function() {
var rPrefs = $('meta[name="responsimage"]'),... | stackexchange/codereview |
I just finished a course of functional programming in uni and continued to study Haskell because I found it very interesting! I made a simple hangman game and would like to hear any of your thoughts and ideas that may arise looking at the code! What, for example, could make it more dogmatic in a functional programming ... | stackexchange/codereview |
def forward_date_range(start_dt, end_dt, span_days):
#
# Generate tuples with intervals from given range of dates (forward)
#
# forward_date_range('2012-01-01', '2012-01-5', 2)
#
# 1st yield = ('2012-01-01', '2012-01-03')
# 2nd yield = ('2012-01-04', '2012-01-05')
start_dt = datetime.dat... | stackexchange/codereview |
This question is an improvement I did based on recommendations from these other questions:
Simple object-oriented calculator
Simple object-oriented calculator - follow-up
Simple object-oriented calculator - part 3
To those looking at this question for the first time, I'm trying to find a correct OOP model I can use in ... | stackexchange/codereview |
I have made this program to simulate polybar's bspwm module. So far, it works flawlessly; however, it consumes too much RAM and CPU (16-30%). I suspect it is the while loop causing the trouble, but what can be done to reduce resource usage?
use strict;
use warnings;
use Switch;
use List::MoreUtils qw(first_index);
$SI... | stackexchange/codereview |
I have created the following user defined function in order to get the element at the position POSI (starting at 0) in the string EXPR. Each element is separated by a separator (SEP).
CREATE FUNCTION [dbo].[getStringElement_Expr_Pos_Sep]
(
@EXPR nvarchar(MAX),
@POSI int,
@SEP nchar
)
RETURNS nvarchar(MAX)
AS
BE... | stackexchange/codereview |
This program offers 8 notes C, D, ..., A, B, C on keyboard keys 1, 2, ..., 8. Also, by typing Left or Right, you can cycle over MIDI instruments.
KeyboardPiano.java:
package net.coderodde.music;
import java.awt.Canvas;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.sound.midi.Instrumen... | stackexchange/codereview |
I created the below comparer to allow me to use a generic dictionary as a key to another generic dictionary.
My GetHashCode implementation creates a hash based on all keys and their values; but I suspect its distribution could be improved?
Also my Equals method returns true only if the two arguments have exactly the sa... | stackexchange/codereview |
I finally have a working trampoline mechanism. Would anyone care to critique it?
Ideone
#include <iostream>
using namespace std;
#include <map>
template<typename T>
class Base
{
public:
typedef void (T::*PFunc)(void);
typedef void (*PHandler)(void*);
using method_map_t = map< string, PHandler >;
... | stackexchange/codereview |
Code is posted after explanation.
Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused.
Post 1 of 3, Core: Newspaper Bill Calculator CLI with Python (1 of 3, Core)
Post 2 of 3, CLI: Newspaper Bill Calculator CLI with Python (2 of 3, CLI)
What is th... | stackexchange/codereview |
I have created a bash script to generate a HTML file, which will have the duration of the audio/video files in the current folder. The script uses ffprobe to fetch the duration in the quiet mode and file to get the mime-type. Although, the script works as intended, it feels a bit slow. I was wondering if it is possible... | stackexchange/codereview |
I want to have a layout for desktop screens, so mostly wide screens with 4:3 or 16:9 aspect ratio.
The layout is made out of 2 sections: right and left. The left section takes 2/3 of the width and the right section should take the remaining 1/3 of the width.
I have 2 options but I am not sure which one is better, or if... | stackexchange/codereview |
I've coded a working implementation of the A* Algorithm however it's not meeting my performance expectations - it explores way too many nodes and takes a lot longer to find a route than I expect.
private Vertex dijkstra(Vertex startLocation, Vertex endLocation, int routetype)
{
Long startTime = System.nanoTime();
... | stackexchange/codereview |
I've been working on a simple forum website as a toy project, to start learning PHP and SQL. I've implemented all of the functionality I want, but I thought I'd run the code by the Code Review community to see how I could improve it.
<?php
session_start();
class database{
protected static $connection;
protected $st... | stackexchange/codereview |
In this post I asked about what would be idiomatic haskell database abstraction. I had been thinking for it a while, and the first answer was similar to what I had in mind, and I wrote a proof-of-concept of it. Discarding the abomination that is the schema, what would you change, and why?
Database.hs
{-# LANGUAGE Gener... | stackexchange/codereview |
I've used Stirling's approximation to compute a factorial but I want to know if it is a cleaner and more concise way to solve this kind of problem.
Here is my code:
from numba import jit
from decimal import Decimal
from math import pi
getcontext().prec = 128
@jit
def stirling(n):
return Decimal((2.0*n+1.0/3.0)*pi... | stackexchange/codereview |
I find that I often have to maintain a singleton primarily to hold an array that is sometimes persisted between user sessions, that should have only one class of items, and that sometimes needs to be ordered. I got tired of writing the same boilerplate over and over so came up with this. I'd welcome critiques (particul... | stackexchange/codereview |
I need to turn a lot of html elements as editable elements. You will double click on the element to edit, press enter to validate (send a PUT to the RESTapi), press esc to undo.
I've written this piece of code. Are there any performance improvements to be made?
var editable = (function() {
var DELAY = 300,
... | stackexchange/codereview |
I have created a function that adds "shadow" to the content of a canvas. The algorithm for adding shadow follows these rules:
If the either x or y is 0, ignore.
If the pixel on the current pixel's top left corner is not completely transparent, set current pixel's alpha value to 0.1.
This algorithm runs from top to bo... | stackexchange/codereview |
I have a NodeJS/Typescript project.
In server.js, I want to set my environment variables from a .env file. To achieve this, I am using the dotenv npm package.
However, rather than leaving everything hanging in server.ts, I want to encapsulate this code. The solution I've come up is as follows.
The goal is for my projec... | stackexchange/codereview |
I am trying to extend the JSON format (for private use) to include an include statement. This could be used to include other .json files into a master file, for example.
#! /usr/bin/perl
use warnings;
use strict;
use File::Slurp 'read_file';
my $str=parseFile('t.json');
sub parseFile {
my ($fn)=@_;
my $str=read... | stackexchange/codereview |
Cost of nodes are represented by a matrix (called world), heuristic cost estimate/g score/f score are all represented in matrices.
The world and its size are stored in global dynamic variables. It looks like this:
1 1 1 1 1
1999 1999 1999 1999 1
1 1 1 1 1
1 1999 1999 1999 1999
1 1 1 ... | stackexchange/codereview |
I'm writing a very simple fading slider plugin for my own use. I would like to know what I could do to improve upon what I've already done.
I think I've done well, but I am certain there are things that I can do to improve.
(function($){
$.fn.slider = function(options){
var settings = $.extend({
... | stackexchange/codereview |
I am having a Python list of lists, that I get as an output of python-igraph (membership to clusters). The integers represent an association of a vertex to a certain cluster at a certain subgraph. I would like to organise this list in a way that the biggest cluster in the whole (unconnected) graph is getting the lowest... | stackexchange/codereview |
I have some experience with PHP but I have never even try to do this wit pure PHP, but now a friend of mine asked me to help him with this task so I sat down and write some code. What I'm asking is for opinion if this is the right way to do this when you want to use only PHP and is there anything I can change to make t... | stackexchange/codereview |
So I needed very basic state management and notification for a small game-like thing I'm building. I decided to implement something like a finite state machine (but not quite, it doesn't transition upon events, but instead is told to transition). This is mostly used for changing visual behavior and animation or whatnot... | stackexchange/codereview |
Here is a part of my new code replacing the old and deprecated old-school one.
Let's get to business right away:
I document everything with Documentation comments, which are proving very useful so far.
I present you my new tiny class called Validity, of which goal is to indicate if something is valid or not, and if n... | stackexchange/codereview |
By any means, if any can tell me if this code can be more optimized than it already is, please say so. It's a select statement to my PDO class. When I glare over my code, I'm certain there is a lot of easy improvements.
public function select($table, $where = array(), $Innerjoin = array(), $group = array(), $select... | stackexchange/codereview |
I've just started a new class learning Java, and since it's been a long time since I've programmed in it I thought I'd put up my first project to get back in the swing of things. Here is my first assignment:
Welcome to the Bridge Crossing Problem. Person Pn can cross the bridge
in n minutes. Only one or two persons... | stackexchange/codereview |
In order to concisify the handling of a failed call to malloc, realloc, or calloc, I have made a few files to dictate "safe" memory management. This is part of my project stac, so the prefix will appear in the following code snippets. Further, I have made the decision to use snake_case as opposed to standard camelCase... | stackexchange/codereview |
The VBEMenuButton class simplifies creating menu items in the VBE Editor. When Excel opens, the Auto_Open() routine in my Personal Macros book is triggered and my commands are added to the VBE Editor Menus.
The example code adds two menu items to the Menu toolbar Tools popup menu: "Backup ActiveWorkbook" and "Update A... | stackexchange/codereview |
I needed a general-purpose function that accepts some sequence_container<sequence_container<T>> and iterates all permutations of the inner container. To be more precise, the outer sequence_container should be described by an iterator pair to easily allow selecting parts of it.
For example {{1,2},{},{3,4}} shall iterate... | stackexchange/codereview |
I am trying to write a class that will enable me to hold an std::vector of some unique objects, but faster finding elements already stored in a vector. I want the uniqueness to be based on some key element of the held objects (not based on compare operator).
I considered Boost::multi_index_container which is almost exa... | stackexchange/codereview |
I wrote a simple program to encode a local text file with password and decode it back. There is one text file and it is either encoded with a password or is in plain text.
I had a version in Python for this, but nim compiles to an executable, so I gave it a try.
I'm not perfectly happy with command line argument handli... | stackexchange/codereview |
I have recently written a jQuery plugin called Pageee.
Pageee is a jQuery plugin to scroll through full pages automatically, by arrow buttons, or by dragging the page.
I have now come to Code Review to ask you if you have any suggestions to the code appearance (readability), the browser support (should only support ... | stackexchange/codereview |
I was supposed to implement set without using any implemented structures. I would love to know what can I correct in my code, because I am not that much satisfied with its quality, so if you have any ideas I will be so grateful!
import java.util.Objects;
abstract class Set {
Object elements[] = null;
abstract ... | stackexchange/codereview |
The problem
My intention is to have a class A and class B. class B has a std::list from a pointers of class A. I need three operations to complete very fast:
Inserting new A elements into the list in B
Removing these very fast
Iterate through the A-s already registered in B sequentially. Their order is irrelevant.
My... | stackexchange/codereview |
I have written two programs to find out a loopy path in a directed graphs.
The first version is a pure functional recursive solution, but its complexity is exponential. The second version following it achieves a linear complexity, but it doesn't look perfect either.
def GetACycle(start: String, maps: Map[String, List[... | stackexchange/codereview |
Here is an async Tcp server using async/await I have written. I would be very appreciate if anyone can help to improve my code. Thank you!
public class TcpServer
{
private int DefaultPort = 6340;
public TcpListener TcpListener { get; set; }
public TcpServer()
{
var ip = NetworkHelper.GetLocalIP... | stackexchange/codereview |
this is a really short code, but I'm trying to improve my Python skills. I've got a DataFrame, with a week variable, for every week I want to know the number of different id's in that week, and then get the maximum number of id's among all weeks. I achieve that doing this:
listt=[]
for i in range(df.week.max()):
li... | stackexchange/codereview |
I am writing a python3 implementation of palindromes checker.
import string
def is_palindrome(text):
"""A string of characters is a palindrome if it reads the same forwards and
backwards, ignoring punctuation, whitespace, and letter casing"""
# implement is_palindrome_iterative and is_palindrome_recursive... | stackexchange/codereview |
I'm trying to account for the fact that my program will contain calculations such as:
v(t) = w ∗ v(t−1)+ c1∗r1∗( pBest − x(t −1)) + c2∗r2∗(gBest − x(t−1))
where v, x, pBest, gBest are vectors (std::arrays). I'm a little worried if I make correct use of the move semantics.
Here's the relevant snippet:
template<class T... | stackexchange/codereview |
I created a Letterpress solver that will take a string of letters and return a list of valid words that can be constructer with the provided letters. Not all letters need to be used in each word.
This works by reading all words into a list named dictionary, transforming that list of words into a map, letter-permutation... | stackexchange/codereview |
Recently I have been looking into Symfony framework and I am working on a task where I need to upload a file using a form. Once the form has been submitted I need to insert the user input along with image name and path in database using Symfony framework strictly (not standard PHP), the upload process also need to cons... | stackexchange/codereview |
I'm building an events app using Rails. I've installed a code block in my controller to ensure that over-booking doesn't occur once the total number of spaces for the event have been allocated/booked.
The issue is that it only seems to work after the payment has been taken rather than before. I need the code to bring ... | stackexchange/codereview |
I'd like some input on my implementation of bst-range, which follows below.
Before we can get to bst-range, we first need some setup code to build the BST.
(You can imagine that node label count didn't exist if you want, as it's not used for range search).
Setup
(defstruct
(node (:print-function
(lambda (n ... | stackexchange/codereview |
I've created a simple game, in which the user needs to guess 4 digits number between 0-9, generated randomly using Random() Each of the 4 digits are different from each other, with no repeated digits. The user has 5 attempts to guess, and each failed (almost correct) guess will tell the user in which part they got it ... | stackexchange/codereview |
The code creates 4 timers that control 4 semaphores with which the tasks will work when they take the semaphore. There are 3 sender tasks and 1 receiver, the sender sends to the queue that was created (first 2 senders are of same priority while the third is of higher priority) in a random period of time that is passed ... | stackexchange/codereview |
Mainly used Stack Overflow, so first time over here for a code review. I am trying to make some enhancements to a legacy application. I have some minor experience using Laravel, but this application is using quite a heavy procedural approach, and I am struggling to work out the best way to structure thing in an OO sens... | stackexchange/codereview |
I have used multiple lines of code in one if condition without using curly braces, which is executing properly. So what is the main necessity of using curly braces in if statements for multiple lines?
if (ggcCompareGrid.TopLevelTable != null)
foreach (GridRow row in ggcCompareGrid.TopLevelTable.Rows)
... | stackexchange/codereview |
I am still new to VBA. I recorded several actions that I need to perform to ensure that a specific worksheet is formatted properly.
Row 1 contains headers. Other than the headers, there is no data in the sheet when this should be run. I know that the raw code from the recording can be shrunk down, but I would appreciat... | stackexchange/codereview |
Currently I find out which is the biggest array and from it I generate a while loop and I go around errors with try catch:
function stackoverflow() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Ratings Time A');
var menu = [
['Atletico Lanus'],
['1795.72'],
['Atletico Lanus'],
['Independi... | stackexchange/codereview |
The usecase of my app I am trying to build is about Inventory Management System for a single company. I have
attached a layout depicting what table or model should look like. I have designed the model the following way
class Office(models.Model):
title = models.CharField(max_length=200, blank=True, null=True)
... | stackexchange/codereview |
This is my first real program in python (and my first real program) and I would like to have input by some more advanced programmers on the code, on the writing style and on the amount of comments (is it clear enough?).
new_name(scheme) does seems a bit bloated to me, but I can't figure out how to write it in a simpler... | stackexchange/codereview |
Please verify whether the code for a move constructor and a move assignment operator is correct.
#include <iostream>
using namespace std;
class MyVector {
size_t m_Size;
int* m_pInt;
public:`enter code here`
~MyVector()
{
delete[] m_pInt;
}
MyVector():m_Size(0), m_pInt(nullptr)
{ ... | stackexchange/codereview |
I'm writing a virtual machine in Python using RPython and the PyPy toolchain. The RPython will still work in the ordinary Python 2 interpreter; it's just a bit slow unless it's compiled to C code with PyPy.
Does anyone have any positive or negative feedback about my VM?
The virtual machine has 4 instructions:
EOP - En... | stackexchange/codereview |
I've been reading a lot about repository patterns these days. At first, the pattern seemed easy.
Most of the examples I read over the web use an ORM like below.
interface MemberRepositoryInterface {
public function find($id);
}
class MemberRepository implements MemberRepositoryInterface {
// here we're passin... | stackexchange/codereview |
I have solved this problem but I am looking for a better way to do it, in fewer lines of code.
The problem was from this previous question on Stack Overflow.
My solution:
/// <summary>
/// For a given square number, tells you the corresponding row and column numbers.
/// Pre: none.
/// Post... | stackexchange/codereview |
I'm working with TCP Sockets and I've build a simple packet struct that turns it into a datagram protocol. I've created a class which returns "promise" Tasks for Packets. Packets are very simple, they consist of:
struct TCPPacket
{
unsigned short size; // contains size-1
// such that size r... | stackexchange/codereview |
UPDATED
I have a POCO class that is populated with _context.Categories.Load():
[Table("bma_ec_categories")]
public class Category
{
[Key]
[Column("category_id")]
public int CategoryId { get; set; }
[Column("parent_category_id")]
public int? ParentCategoryId { get; set; }
[Required]
[Colum... | stackexchange/codereview |
I am currently writing my first actual C++ project. I like Chess and I would like to see how good I'm doing on a monthly basis, so the idea is to read the log files (.pgn files) from the games and tell me how many games I won and such.
My question specially relates to Games.cpp where I'm not sure I have done the right ... | stackexchange/codereview |
Minor question on String null check and trim.
// given a function func() that might return either a string or null
String func() {
return " hello ";
}
Which one of the following is better - i.e. more readable, preferable, etc.?
List<String> list = new ArrayList<>();
String value = func(); // may return null
if (... | stackexchange/codereview |
My aim is to simulate the following model by means of a Monte Carlo simulation. I wonder if my R code is correct for generating the data.
Could somebody check?
The model:
$$Y = \sum_{j=1}^{100} (1+(-1)^{j}A_j X_j + B_j \sin(6X_j)) \sum_{j=1}^{50} (1+X_j/50) + \epsilon$$
where
\$A_1, \dots, A_{100}\$ are i.i.d. \$∼ ... | stackexchange/codereview |
Challenge can be found here
Problem Statement
Watson gives Sherlock an array A of length N. Then he
asks him to determine if there exists an element in the array such
that the sum of the elements on its left is equal to the sum of the
elements on its right. If there are no elements to the left/right,
then the ... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.