instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
public boolean connectedOnGameServer = false;
public final Object conGameServerMonitor = new Object();
public void connectedToGameServer() {
synchronized (conGameServerMonitor) {
if (connectedOnGameServer != false)
throw new RuntimeException("Player connected twice");
connectedOnGameSer... | stackexchange/codereview |
I'm not very familiar with MPI. I've written this little piece of code to draw the Mandelbrot fractal processing each row of the image in parallel. It works but it's really slow. I've written code to perform the same task with OpenMP and with no parallelization, and both run instantly with the default parameters, where... | stackexchange/codereview |
I believe this is considered value noise or possibly gradient noise in that I simply interpolate between random values (always returning the same values per coordinate).
I am using this currently to generate a basic heightmap in a 3D game that expands outward as the player moves (being nearly infinite, only restricted ... | stackexchange/codereview |
Issue: Code base has lots of data structures which are accessed between threads with >= 1 writer. Application logic becomes obfuscated due to lots of mutex locks.
Solution: Create a template class which provides synchronized access through member functions.
This seems very hacky -- Is this a futile effort / antipatte... | stackexchange/codereview |
Background
I decided to write build script as a gentle introduction to PowerShell. It builds and packages this Go application, which is an internal tool I decided to open source, and not the focus of this review.
This script is used primarily for packaging artifacts for release.
My approach
The script below gets, vets ... | stackexchange/codereview |
I am currently working on a bigger project where I found a part of it which seems very ugly to me from the code.
I stripped out the algorithm and made a working code, so it can be reviewed.
I have a data structure which contains several containers with several different objects:
struct Data {
std::vector<TypeA> a;
... | stackexchange/codereview |
I'm designing a login portal that has one angularjs page that displays/processes data queried from a database. I'm relying on a few php pages (a loginpage.php [verifies credentials/loads session variables], a check.php [page that is included in all php pages, verifies session variables are 'okay'], and a getter.php [qu... | stackexchange/codereview |
I recently started learning TypeScript and created a small space shooter. I would like to get some feedback on the structure of my code.
I have some classes with both static and instance methods with references back and forth and wonder if I could have done this cleaner somehow.
Link to full code: Github
Game: Firefly ... | stackexchange/codereview |
Before the interview for the Junior (i hope:)) position of Java developer, I was asked to do a test task. Kindly ask you to review my code. Riht now program arguments are hardcoded and not from args[], tomorrow I will add arguments processing.
You can see my code on GitHub also.
I would appreciate any feedback. Thanks!... | stackexchange/codereview |
This is one simple crawler that downloads images from websites, the website's URL to be crawled to must match the regex, as well as any image-to-download's URL.
(Also, I know, I made my own thread pool, because I did want to keep my crawler lightweight...)
Code:
import BeautifulSoup
import requests
import re
import jso... | stackexchange/codereview |
I have been doing OOP and imperative programming my whole career but I wanted to dabble in Scala along with functional programming. Rather than writing Java like code in Scala I wanted to try a more functional approach. I decided to try a simple Kata with Scala, Game of Life. The following is what I came up with. I adm... | stackexchange/codereview |
I have a string util method for finding potential "wrapping points" in a string.
For example, if " " and "-" are considered wrapping chars, then for input string
"Antoni Gil-Bao" the method would return the sorted set [6, 10].
private static final String WRAPPING_CHARS = " -";
private static final CharMatcher WRAP_CHAR... | stackexchange/codereview |
I am studying chemistry in the university, and then I try to write all the things in the textbook with Perl6 or Perl, like balancing the chemical formula or other process!
Then I encountered the problem is on perl6 custom operator.
I feel I have been repeating my code and myself when i use the feature.
It is hard to re... | stackexchange/codereview |
Preliminaries
I have optical sensor ADNS2610 (see datasheet here). There are a few problems which it can be used to solve, but for now let us focus on getting an image from that sensor. This sensor is kind of a small camera which has 400 cpi (counts per inch) resolution. And the resulting image consists of 324 = 18 x 1... | stackexchange/codereview |
I've written an interpreter for a simple assembly-like language and it's performing slower than I would like.
It's split into 3 files: the Parser that converts the source to a vector of ints, the VM that actually runs the bytecode, and Tests that has a bubble sort written in the language.
It sorts 100 numbers in about ... | stackexchange/codereview |
What my script does is:
Append data to a file on a continuous basis.
If an error pattern is observed, then do something.
I need feedback on the way I am grepping for patterns in the continuously appended file. For grep, I am creating a pattern file first and then using it with -f option to grep. Can I do this better?... | stackexchange/codereview |
I am creating a service (FaultTolerantCommunication) that wraps a call to a (web) service. Its responsibility is to switch the endpoint URL in the event of a TimeoutException.
Currently the web service is a soap web service but I am attempting to make it reusable for other remote services such as a JSON based web servi... | stackexchange/codereview |
Directive that shows text as particles on a canvas. Looking for a general review. Plunker here.
image.service.js:
(function () {
'use strict';
angular
.module('app')
.factory('ImageUtil', ImageUtil);
function ImageUtil () {
function preloadImages(srcs) {
function loadIm... | stackexchange/codereview |
I'm coding a Old Gameserver just to learn more about c++ and Reverse engineering.
I'm also studying about code refactoring and design patterns.
Currently I have this member functions :
void CommandManager::SetLevelCommand(char* command) const;
void CommandManager::SetPKCommand(char* command) const;
void CommandManager... | stackexchange/codereview |
Previous question:
Counting words in files - follow-up 2
For simplifying the code, I have implemented std::regex rather than templates.
How can I improve this code further?
//
//program name: WordCounter
//
//usage: C:\>WordCounter.exe test.txt test1.txt
//
#include <iostream>
#include <iomanip>
#include <fstream>
#i... | stackexchange/codereview |
Please review the code readability, I would like to have an easier to follow code.
Thanks
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ArrayQuestions
{
/// <summary>
/// https://www.geeksforgeeks.org/inplace-rotate-square-matrix-by-90-degrees/
/// </summary>
[TestClass]
public clas... | stackexchange/codereview |
In my application, well-defined operations on collections of business entities are modularized and carried out using one or more routines, each of which operates on a unique type of data associated with (but not necessarily contained in the objects that represent) these business entities.
A routine may have logic that... | stackexchange/codereview |
I made a PHP script to check value before update. This script is working fine. But, I wonder how to simplify this. If there are hundreds of columns to be checked then it's hundreds of PHP lines.
This is used for saving a log file for update. So, if data is updated then it stores a log in a table.
public function edit_p... | stackexchange/codereview |
I have just written something to guarantee a unique URL when creating pages within an old legacy system (sounds odd doing this retrospectively but we've just changed how the routing works). I don't often end up using while and I think this may be why I feel it can be improved.
private string GetUniqueUrl(Page parentPag... | stackexchange/codereview |
I've just started learning Erlang. Since my editor of choice doesn't have a syntax checker for Erlang, I decided to use the parser/linter in the standard library to make a standalone script. It works now, but I'd like my code to look cleaner, possibly handle edge cases better, be more ... what's the Erlang equivalent o... | stackexchange/codereview |
I have written this code base on AsciiEngine. How can I improve this code?
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <memory>
#include <algorithm>
#include <unordered_map>
#include <type_traits>
#include <random>
#include <chrono>
#include <cassert>
#include <Windows.h>
enum ... | stackexchange/codereview |
In my Player.java class, I want to incorporate a function that moves my player according to the left or right swipes. I also used time in seconds in order to vary the movement in an cyclic way:
'''
class MyGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1,... | stackexchange/codereview |
This is my first project I am doing in VB.NET, and also my first real programming project. There is sensitive data, so I am utilizing Microsoft's Encryption/Decryption class (clsCrypt).
For optimization, quality and best practice standards, which code the 'best' way to retrieve encrypted data from a MS SQL Server 2008... | stackexchange/codereview |
This is some code that I wrote for fun because in some of my classes I had to copy and paste between different Google docs I had. So, I decided to write a python script that would let me copy up to 5 different pieces of text and paste them.
I feel like the code is really inefficient and too verbose, though. Specificall... | stackexchange/codereview |
I have improved my BFS in Java according to vnp's suggestions. Again, we wish to find shortest paths in directed unweighted graphs using BFS, competitive style (no Maps, Set's or Lists):
import java.util.Arrays;
class BFS {
static int[] bfs(int[][] graph, int sourceNode, int targetNode) {
int[] queue = ne... | stackexchange/codereview |
I need to optimize this snippet to be faster:
Dim lst = (From t In DocElet.ChildNodes Select ID = t.item("ID").outerxml).Distinct().ToList()
Parallel.For(0, lst.Count, Sub(i)
Dim P As XmlElement = GetElement(lst(i))
Dim ls = (From t In DocElet.ChildNodes Where t.item("ID").innerText = P.InnerText... | stackexchange/codereview |
Given an unsorted array of integers \$A\$, the \$i\$th order statistic of \$A\$ is the \$i\$th smallest element of \$A\$. For example, \$0\$th order statistics of \$A\$ is the minimum of \$A\$; \$(|A| - 1)\$th order statistics of \$A\$ is the maximum of \$A\$; \$1\$th order statistics is the second smallest element, an... | stackexchange/codereview |
I have an assignment to solve this problem.
Problem Description
Bob the Cat is building a new system, dubbed the Cats Transmission
System (CTS). This horribly inefficient system utilises cats to help
transfer information. In this system, there are N cats lined up in
a line from cat 0 to cat N-1. If a message nee... | stackexchange/codereview |
I recently started solving programming challenges and this one is causing me performance trouble. The problem statement is the following:
You are given a 2d matrix where each cell contains an integer weight,
a start and an end position. The goal is to find the maximal
smallest element from all paths from start to ... | stackexchange/codereview |
I want to find all of the whole numbers in a string that starts with { and ends with }, and uses , to separate each number.
I use sscanf to find and match each item in the string—for example:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
const char *str = "{0,1,22,333,4,55,6,77777,8... | stackexchange/codereview |
For the real time control software I need square root calculation. I have heard that the sqrt function from the standard library isn't good choice due to the unpredictable number of iterations used during calculation. Based on that information I have decided to implement the sqrt function in my own based on the Newton ... | stackexchange/codereview |
I am dong a competitive programming problem I have passed all the tests.
but my program times out. I need help optimizing my code so it can run faster.
Task:
Finish method: BingoCaller.GetNumber()
Return all numbers in the range of 1 until 75 once and in random order
If there are no numbers left, return an empt... | stackexchange/codereview |
This is a interview practice question from BFE.dev.
Currying is a useful technique used in JavaScript applications.
Please implement a curry() function, which accepts a function and return a curried one.
The solution is pretty simple, but when implementing it with TypeScript the compiler will throw a warning about my... | stackexchange/codereview |
I've made this GUI program for my workplace that checks whether measured coordinates on machined components are within spec.
It takes in specified coordinates, tolerance and measured coordinates and uses Pythagoras to check whether the tolerance has been exceeded.
It then plots the measured point relative to the 'true ... | stackexchange/codereview |
I came across this interview question and it has been asked to print combinations of the characters in a string. For example: "abc" --> a, b, c, ab, ac, bc, abc. Also it has been mentioned that 'ab' and 'ba' are same.
I want to know if there is any improvement I can make in terms of memory usage/performance.
public st... | stackexchange/codereview |
While thinking about this question it struck me that one problem of linked data structures always seems to be loss of memory locality and performance could possibly be improved if all allocated nodes are in a contiguous block of memory. So hacked together an object pool implementation in C.
The code compiles with gcc -... | stackexchange/codereview |
I have a checking function that checks the correct type for a class Check_Annotation, I was wondering if there is a better way to implement this, my current code right now is:
def _check_list_or_tuple (self, param, annot, value, check_history):
assert isinstance(value, type(annot)), "AssertionError: 'x' failed ann... | stackexchange/codereview |
So, I did the CodeEval 'Longest Lines' problem and it works fine for any input data I can devise. When I upload it to CodeEval, it says it's wrong.
Because it's a "moderate" problem, input data is not provided. After some System.out.println nonsense I got the test data, and my solution seems to work. Am I missing so... | stackexchange/codereview |
What I'm basically wondering is if there's anything that is possible to improve in this C++ code:
#include <cstddef>
#include <string>
bool is_palindromic(std::string s)
{
std::size_t i = 0;
std::size_t j = s.length() - 1;
while (i < j) {
if (s[i++] != s[j--]) {
return false;
}
... | stackexchange/codereview |
This is a beginner's attempt at implementing a linked list in C. Please read the code and provide recommendations. I do not want to limit the reader's benevolence to only these questions, but my specific questions are as follows.
Am I treating errors, exit codes, and warning messages appropriately?
How can I improve m... | stackexchange/codereview |
I'm using the above piece of code to do some HTTP calls in parallel. This loop is running inside a NSOperation. I must throttle a bit the requests (so I don't overload the server). The code is working fine, but it doesn't seems to me the most elegant way to do it. It's OK to sleep the thread?
I'm using a two-level disp... | stackexchange/codereview |
I wish to take an XHTML source document (e.g. demo.in.xhtml below) and add class attributes to every td element whose content is one of the following six strings: A1, A2, B1, B2, C1, or C2. The corresponding classes will be mytable-a1, mytable-a2, mytable-b1, mytable-b2, mytable-c1, mytable-c2. Any other td elements in... | stackexchange/codereview |
To further generalize the algorithm (past the doc string): Given a list E(1) E(3) E(2) E(4) _ E(0) _ where E(N + 1) is ahead of E(N) when sorted and _ represents a "static element" (that is, an element whose index and value will remain unchanged despite the sorting), the list returned should be E(0) E(1) E(2) E(3) _ E(... | stackexchange/codereview |
I want to return a set of items with an attached score to the user so that the user can easily iterate from highest to lowest and get the n-th highest items.
Problems
The JavaDoc of SortedSet.first() says "Returns the first (lowest) element currently in this set.". However in this case it is actually the highest score... | stackexchange/codereview |
In many of my personal projects, I have a login system very similar to the one I am about to describe. I understand how difficult correctly implementing authorization systems can be. I do this as a hobby and if I can do this securely myself, I would very much like to. (At work, I avoid homebrewed login solutions). I wa... | stackexchange/codereview |
Having started a new software dev role recently I'm in the process of developing my first full web app project using the following stack HTML + CSS + JavaScript + PHP.
I'm new in terms of applying these lessons I have learnt in the recent past in each language (as you might see from my basic sounding earlier questions... | stackexchange/codereview |
I'm adding an onclick listener to the whole document then checking the source of the click. If the source of the click contains the attribute data-widget I want to go to the appropriate action. I did it but I'm hoping for a more efficient way of doing things and if I can do without the self invoking function.
<div dat... | stackexchange/codereview |
I just recently started with Javascript and jQuery. My background is in Python. I would be more than happy to get some feedback if this coding style of mine is optimal, or if in JS people generally write things differently.
The current task is to build different elements in a website that are always hosted in the same... | stackexchange/codereview |
1Note: This is the first post in - hopefully - a series of posts I plan to make.
Project background
Schemey is a project I've been working on for the past 3-4 weeks. It is an implementation of a subset of the Scheme programming language. The project is still very new and most likely has bugs in certain parts(which is w... | stackexchange/codereview |
I'm currently trying to improve my coding skills, so I'm trying to code a Tic Tac Toe game. At one point a "win check" is needed.I'm using this code to check:
public void CheckWin(States state)
{
if(fieldA1.GetState == state && fieldA2.GetState == state && fieldA3.GetState == state)
ReportWin(currentPlay... | stackexchange/codereview |
I'm trying to do a simple implementation of a scp wrapper in Elixir.
The code is working as intended, but I got a feeling that the error conditions can be simplified. Besides error handling, I don't the best way to append the -r flag if the source_path is a directory with a cond keyword.
defmodule Scp do
def scp(user... | stackexchange/codereview |
I need to process a bunch of completed orders (thousands). To make it faster, I'm using a SemaphoreSlim to schedule a number of orders to be processed in parallel. Every order goes through multiple web service calls to various APIs (SOAP, REST). Then I need to take the returned data and process it into a PDF. Here is w... | stackexchange/codereview |
This code is about manipulating each value in a 2D array. My method below is called based on how I want the values in the array to be manipulated (process).
For the first method in the switch statement - as an example, I am calling AllCaps() method to manipulate the value.
What I am trying to avoid is repeating stateme... | stackexchange/codereview |
Following my previous question about a FIFO for embedded systems and the very detailed answer I got, I made some modifications to convert a simple FIFO to double-ended queue for Embedded Systems.
It is using a circular buffer.
How it works: When an element is added and the queue is not empty, the corresponding index is... | stackexchange/codereview |
Was asked this in an interview yesterday:
You are given an array of numbers (not digits, but numbers: e.g. 9, 23, 184, 102, etc.) - you need to construct the largest number from it. For example: you get 21, 2, 10 - the largest number is 22110.
This is my solution, I wonder if you can improve this?
def maximum_number(a... | stackexchange/codereview |
I am implementing generic repository and unit of work for the first time. I would be glad if someone can correct me if I am doing something wrong here.
This is how I communicate with my DAL from controller:
public class HomeController : Controller
{
private UnitOfWork unitOfWork = new UnitOfWork();
... | stackexchange/codereview |
I am deleting rows based on a date.
I am loading the entire sheet into an array and doing the evaluation and building a string containing the rows I want to delete.
Option Explicit
Sub arrmaker()
ThisWorkbook.Activate
Dim i_LastRow, i_LastColumn, i_FirstRow, ictr, ictr2, i_row, i_col As Long
Dim Da_Array(), Da_Other_A... | stackexchange/codereview |
I wrote a simple multithread server to use as a base class for other different types of multithread servers. I haven't had a lot of opportunities to get code critique from other people, so I wanted to post here to see how much coding style was. Any constructive feedback on how to improve my code would be appreciated! I... | stackexchange/codereview |
This seems to work on some version of windows and acts weird on others. This is unstable and redundant.
How can I improve this in a way that it has the same expected behavior through every windows version starting from Windows XP to 10.
When the application starts it checks if a unique ID already exists. If it does, i... | stackexchange/codereview |
I'm working on an integration for Magento 2 with a 3rd party. This class will fetch the articledata resource. This resource contains multiple items, with a maximum of 750 per call. The class is designed to be used like do load() while next().
If there are more items than the current 750, there will be a value next_resu... | stackexchange/codereview |
I need to parse the data coming from a URL:
haschanged=true
version=1
timestamp=1389562122310
DATACENTER=/pr/hello/plc
TotalNumberOfServers:4
primary:{0=1, 1=2, 2=1, 3=2, 4=1, 5=2, 6=1, 7=2, 8=1, 9=2, 10=1, 11=2, 12=1, 13=2}
secondary:{0=0, 1=0, 2=0, 3=1, 4=0, 5=0, 6=0, 7=1, 8=0, 9=0, 10=0, 11=1, 12=0, 13=0... | stackexchange/codereview |
Description
I had to create a dictionary structure where one value can be referenced by several keys.
For example the keys a, b, c reference the value 1 and d, e reference the value 2. If two groups of keys intersect then I want to merge them, for example the group a, b and b, c should result to a, b, c.
I also need an... | stackexchange/codereview |
Is this the correct way to implement a thread-safe concurrent FIFO queue in C++? It requires passing unsigned char* arrays of binary data.
Thread Safe Concurrent Queue
#include <queue>
#include <pthread.h>
class concurrent_queue
{
private:
std::queue<unsigned char*> _queue_;
pthread_mutex_t push_mutex;
... | stackexchange/codereview |
I have written this script to install gcc (here in version 4.9.2) on Centos6.6. I am only interested in C and C++ support.
Please comment if this is any good and can I make it better before I get the packages for those.
#!/bin/bash
LOGFILE=/tmp/gcc_install.log
# $1 - package name
# $2 - status
errorIf(){
if [ $2 -ne ... | stackexchange/codereview |
I have the following PHP code but I'm unsure, based on the many things I've read, whether or not this is actually safe from an SQL injection attack.
$mysqli = new mysqli("address.address.address", "username", "password", "database");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n... | stackexchange/codereview |
I am a beginner in programming. And I am learning python as my first language. I went on to do some challenges on HackerRank and stumbled upon this problem. The problem goes like this:
There is an array of \$\ n \$ integers. There are also \$\ 2 \$
disjoint sets , \$\ A \$ and \$\ B \$ each containing \$\ m \$
int... | stackexchange/codereview |
How could I use enums in the following block of code to simplify it? The block is a program that has a command interpreter that returns different data based on user input. Is there a way I could easily apply enums and a match statement to the logic here?
use std::io;
fn main() {
let version = String::from("0.0.1")... | stackexchange/codereview |
I am trying to make my script maintenance-free by replacing some "static" variables and labels with dynamic ones. The main function of my code is to extract data from a SharePoint-list which contains a number of list items with several columns (including a column for school), then count the number of items based on a s... | stackexchange/codereview |
Below is one of the versions of my wifimap script:
#!/usr/bin/python
"""
Sniffs on the WiFi network and generates a graph showing the communication
between the devices, including information about the announced SSIDs. Will
loop infinitely - kill the program with SIGINT in order to stop it
gracefully. You can also use ... | stackexchange/codereview |
I have a class that always has 14 instances. I'm just wondering if there is a better or more effective way of doing this. In this class I also have an array that is filled by calling 4 functions multiple times. Because this class is instanced 14 times, the array is duplicated a lot. What would be a better way to do t... | stackexchange/codereview |
I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few things. I was docked a few points for an unnecessary mov in another project.
Problem 1:
"If—else (34 points): Write a program that asks the user to enter a
single d... | stackexchange/codereview |
I'm using Express 4 to provide routes to HTML/Jade files, and as well to provide an API.
I want to separate routes from server file, and go even further- separate API from WWW. My code now looks like this:
server.js
//================== ROUTES ======================================
require('./routes/api')(app, express... | stackexchange/codereview |
I have just started learning Python. This is code for a TicTacToe game. Can you please suggest any improvements?
pos_matrix=[[' ',' ',' '],[' ',' ',' '],[' ',' ',' ']]
def my_tictactoe(pos,symbol):
if pos_matrix[pos[0]-1][pos[1]-1]!=' ':
print('Invalid input')
exit
else:
pos_matrix[pos[0... | stackexchange/codereview |
Can someone please review this design I created for deck of cards in Java?
package prep.design;
import java.lang.reflect.Array;
import java.util.*;
/**
* Created by rohandalvi on 5/14/16.
*/
public class CardDeck {
private ArrayList<Card> cards;
CardDeck(){
cards = new ArrayList<>();
for(C... | stackexchange/codereview |
I'm building a hash table for this problem:
Implement a class for storing a set of integers:
class FixedSet {
public:
FixedSet();
void Initialize(const vector<int>& numbers);
bool Contains(int number) const;
};
After the call of the Initialize() function, FixedSet contains integers from the input vector. ... | stackexchange/codereview |
I have a Table that I store All setting in that , it is like below :
public class Setting:IEntity
{
public string Key { get; set; }
public string Value { get; set; }
}
and I have a service like this to update and read Setting Table :
public class SettingService : ISettingService
{
#region Fields
... | stackexchange/codereview |
I've always been told "never use goto, there's always a better way" and for the longest time I just accepted it. Lately though, I've been running into such scenarios in which I have to repeat this bit of code every time I return early.
I personally hate repeating myself, even the littlest bit of code. So I ask, Is this... | stackexchange/codereview |
Goal
Design a representation of a mage character from the World of Darkness RPG, as well their associated spells.
Here is a visual representation of the schema. You can see it more closely on LucidChart if you like.
You can also see my draft here and on YUML
I have already made an attempt at laying out the models, ... | stackexchange/codereview |
I have a number of functions that follow the basic pattern below. The intent is to provide a MongoDB implementation for a storage interface in a TypeScript application.
Is there a better way to clean this up so that is is simpler or more readable?
find(collection: string, query: any, sort = {}): Observable<[SyncedObje... | stackexchange/codereview |
Introduction
I have a spreadsheet in Excel, looking like this:
I collect and sort the values in the column labelled "Antal dagar venting", based on the values in the columns "Nivå 1" and "Nivå 2".
My current code for collecting this data is:
In a class-module:
Option Explicit
Private pAntalDagar As Long
Private pDelå... | stackexchange/codereview |
SCENARIO:
As a follow-up of this question on Stackoverflow asked few days back, I am working on a swing application(article tagging tool) where the user(on an initial jpanel) would fill up some mandatory fields and then proceed to different sections(front, body and back matter of the article) where the application woul... | stackexchange/codereview |
Had my first go at implementing infinite scrolling for UITableView's in my iOS app last night, and I noticed I ended up copying/pasting quite a bit of boilerplate from one VC to the next (if I wanted infinite scroll on it).
By the way, I'm fairly new to iOS, so this question is probably more broad than just specificall... | stackexchange/codereview |
With the following interface in mind
EasyRandom<unsigned int> prng(a, b);
auto x = prng(); // scalar
auto v = prng(10); // vector
I wrote the following class:
// https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution
template <typename T = unsigned int>
class EasyRandom
{
private:
std::random_de... | stackexchange/codereview |
I'm teaching myself programming.
I would like to know how I could make this Python3 could more flexibile, for example if I wanted to find students with the 3rd lowest grade, or the lowest, or any other value. Based on this piece of code (that it took me awhile to fathom out) I'm not convinced Python is the best tool fo... | stackexchange/codereview |
I have reviewed the FAQ and I believed it was yes to all 5 q's of "What questions are on-topic for this site?"
Basically, the code below is used to perform the operation shown in the picture. I'm wondering what I can improve in the attached code to clean it up for future reference. Thanks in advance!
Sub Button1_Click... | stackexchange/codereview |
As you know there is an algorithm in C++ standard library called std::merge, that merges two sorted ranges into another range. I try to write another merge (called multi_merge) that gets multiple sorted ranges (one or more), and merged them in one.
The code is as follows:
#include <utility>
#include <vector>
#include <... | stackexchange/codereview |
I am trying to implement squarelist by using iteration that points to the head element. I've create this iterator class to make my iterator id directional. I just want to see if I implemented it correctly.
class iterator : public std::iterator<std::bidirectional_iterator_tag , Object , int>
{
public:
... | stackexchange/codereview |
I am accepting dynamic input from the user if they have any i.e - Children/Siblings/Previous Employement etc through Vue Components.
A form is created and they input their data which is validated and then submitted. Submitted data is displayed in another Vue table component from which they can delete data if needed.
Th... | stackexchange/codereview |
I want to extend an app object with a widget that initializes itself immediately.
Immediately-Invoked Function Expression:
var app = {};
(function() {
app.widget = {
init: function() {
return true;
}
};
app.widget.init();
}());
Immediately-Invoked Object Expression:
var app = {};
({
init: func... | stackexchange/codereview |
On Linux, the file /proc/cpuinfo returns a set of key-value pairs, where the key and value are separated by a colon and each pair has its own line. It's a bit more complicated than that in reality, but for my needs that's as complicated as it needs to be. (I have only one processor core.)
My goal is to write a function... | stackexchange/codereview |
I am following the Wikipedia definition of the Bloom filter. My implementation uses the BitArray I created here. Here is an alternative implementation by Ilya Grigorik.
# n = Number of items in the filter
# p = Probability of false positives, float between 0 and 1 or a number indicating 1-in-p
# m = Number of bits in t... | stackexchange/codereview |
I have a long data.table, payoff_mat. I would like to select the rows containing the maximum value of column X by group Y. There are several posts on this, and I think I am well optimized in this regard.
The twist is that I would like to repeat this process several times, for which I think I could do better. This is ... | stackexchange/codereview |
I often write different applications in C++ using different libraries, and sometimes it takes a lot of time to find where are the *.dll files to distribute. I use Dependency Walker but it still takes a lot of time to look in the GUI. I wrote a PowerShell script that will find all used libraries and do something with th... | stackexchange/codereview |
Warning: lots of code. If it's too much, please focus primarly on channel.h and channel.hpp.
This is my first time posting on Code Review, so I apologize in advance if anything is unusual or could have been written better.
Context
The program in which I am using this data structure is a DAQ to CSV conversion tool. Put ... | stackexchange/codereview |
I'm wondering what the best way of initializing variables so that I don't over use the garbage collector with a for-loop. Assuming the variable is only used inside the for-loop. Is it better to declare the variable outside of the for-loop?
public void foo() {
String tempName;
for (Person person : personList) ... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.