instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I would like some advice on improving/optimizing a small program I wrote. What it does is run a random walk on a torus manifold with 8 colors that loop around.
//RTM Test Using Random Walk Fractals, WIP
//Created by delta23
//This Code works on Minix, Unix, MacOSX, Linux
//This Code does not work on DOS or Windows (yet... | stackexchange/codereview |
Look at the code below. When I run the program. Only 'You're still a pup!...' gets printed out. No matter how high of a number I put. I DO know that it is taking the correct number because I echoed out the age to test separately.
<?php
function prompt($prompt_msg){
echo("<script type='text/javascript'> var answ... | stackexchange/codereview |
Could you help me further improve this code, which includes some feedback from this site already (Find common "characters" in 2 given strings (rev1))?
I have rewritten the code below, including feedback, as Rev3 @ Find common “characters” in 2 given strings (rev3).
import java.util.ArrayList;
import java.util.Arrays;
i... | stackexchange/codereview |
What I need is to remove first word from the string again and again until only one word is left, and put it all into array.
For example, I have this string as an input:
Chicago IL 12345 United States
What I need to achieve is this array:
[ 'Chicago IL 12345 United States',
'IL 12345 United States',
'12345 United State... | stackexchange/codereview |
This is used to change a Cyrillic word with a stress marker into the same Cyrillic word but with the stress marker separately represented as a number. As I want to return two values I pass two parameters by reference. I assume there is at most only one stress marker per word.
What could I improve here?
function seperat... | stackexchange/codereview |
I have a requirement to provide an API which would allow to change status of Order. The API is supposed to follow REST principles, so I have designed an endpoint like this:
/api/orders/{orderId}/status
The decision to expose separate resource of status rather than including it into order resource as a property was dr... | stackexchange/codereview |
I'm building a full stack exercise app and some of my objects include routines, exercises, exercise sets etc. Instead of writing out specific get, post, put and delete requests for each resource, I was wondering if there's a more dynamic way to make requests using a custom React hook. I've seen many examples of a useFe... | stackexchange/codereview |
I have this Java implementation of a Rubik's cube's state. My primary concern is DRYness of my code:
RubiksCubeNode.java
package net.coderodde.libid;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author Rodion "rodde" Efremov
* @version 1.6 (May 4, 2019)
*/
public final class R... | stackexchange/codereview |
I have some files such as .\image_1_01.bmp that will be created elsewhere. I am then moving these files to an output directory. If any are missing I inform the user that it's missing and instruct them to check the logs.
Given how similar all the code is, can I make this code shorter?
if not os.path.exists(".\image_1_01... | stackexchange/codereview |
Using Python's LXML I must read an XML file and print from each "basic" and "expert" tag, the name and email text from it. I've done a script that works but I don't think is the best way of doing this. Is there a better (simpler) way for getting the data of the XML without having to make 2 iterations on it?
Python so f... | stackexchange/codereview |
I am calculating a likelihood surface for a modified negative binomial distribution with two parameters: mean R and dispersion k (the probability distribution is 'modified' to account for total size distributions of networks, so cant use inherent MLE (i.e. MASS::fitdistr)). Thus, I'm running simulated data through the ... | stackexchange/codereview |
I am making a website which should host a lot of PDFs. These PDFs are stored on the HDD. There are DossierIds in the database which correspondent with the folder name. In these folders there is 1 layer of folders and in those layers are the PDFs.
To make the structure clear:
- ABC
- Dossier1
-File1.pdf
... | stackexchange/codereview |
I have two database tables UsersDownload, Non-UsersDownload. There is also two model object and two service that take in the object and insert the data into the correct table. Is this the best architecture for this? or is there a better way to handle this? Would it be better to use an interface?
public class UserLog
{
... | stackexchange/codereview |
/**
* takes a list of componentIDs to load, relative to componentRoot
* returns a promise to the map of (ComponentID -> componentCfg)
*/
function asyncLoadComponents (componentRoot, components) {
var componentCfgs = {};
function asyncLoadComponentCfg(component) {
var url = _.sprintf("%s/%s", compon... | stackexchange/codereview |
The Wikipedia article on the union find problem gives a very simple implementation, which I ported to C# and tested.
I know that the code should be, in the aggregate, asymptotically almost linear. But is it a practical implementation? Are there optimizations I should have used? Is there a way to cut down on the worst-c... | stackexchange/codereview |
I have a dataset with 16 million rows and may increase upwards of 30 million. I am using the parLapply to run across three cores in R. But it's taking two days to run to completion. When I try smaller datasets of about 60,000 it takes less than 5 minutes to run, what may be cause of this disparity.
Desktop Specs : Core... | stackexchange/codereview |
I'm working on a simple async TCP client server application, i'd like my network code to be reviewed. I really feel that I'm doing something wrong, especially in receiving code.
Interface for client:
public delegate void ConnectedHandler(IAsyncClient a);
public delegate void ClientMessageReceivedHandler(IAsyncClient a... | stackexchange/codereview |
I wanted a buffer like std::vector<uint8_t> which is very fast at resizing, and it does not require byte initialization (it resizes to 16K, then to 2-4 bytes, then goes back to 16K, and repeat, a lot. std::vector zeroes all the bytes every time it grows back to 16K, I thought I could avoid the zeroing-overhead with a c... | stackexchange/codereview |
I made a program (C#, .NET) that calculates time for XML and CSV export and please I have a question for improving my knowledge in programming. Do you think that I can improve the structure of the program? Or what do you think about code refactoring? Way of solve... Is it good? I uploaded the project to github.
Thanks ... | stackexchange/codereview |
This is another revision of my Psycho Productions database, this time refactored from MySQL to PostgreSQL, after I found out about some of the shortcomings of MySQL.
The following is a (simplified) version of relationships in a flowchart. The way I used arrows is: where the arrow originates = FK and where it points to... | stackexchange/codereview |
Preamble
So, as most of you have likely also noticed, chat components, at least at a basic level, are becoming very common with lots of apps. I found myself tweaking and redesigning the interface from my last project all the time, so I decided to just create an easy to drop in solution. I'd love to get some second ... | stackexchange/codereview |
I have a project in embedded systems and I have to write the code in C, and make it simple.
This is my first time, and it's only a simulation of how it should work.
#include<iostream.h>
#include<stdio.h>
void manualMode();
void defaultMode();
int temp, timeToWash, operation;
int main() {
int mode =0, part=3, w... | stackexchange/codereview |
I am piggybacking an iterator-based implementation of merge-sort to count array inversions. My first correct solution looks as follows:
#include <vector>
#include <iterator>
#include <stdio.h>
template<typename It>
std::vector<typename It::value_type> SortAndCountInversionsSubroutine(const It begin, const It middle, c... | stackexchange/codereview |
Kindly accept my apologies as Java is something my mind cannot digest no matter what I do. At the moment I have an assignment and have written a piece of code and have used Constructor (I think so) but not sure if I have used it correctly and if Yes then will need some guidance in order to refactor the code.
Anyhow I ... | stackexchange/codereview |
I recently implemented the Sieve of Atkin prime generating algorithm in Python. Though I know the term "pythonic" isn't exactly set in stone, I can tell that my program doesn't quite take advantage of python's inherent traits; my program looks like it was written with "C" in mind.
My question is two fold; (1) how can I... | stackexchange/codereview |
I've decided it would be best to break this project down into several parts. Consider this Part 1(GUI Design).
I'm looking for help making 2 main improvements:
Whenever I make a GUI, its always very repetitive to add JLabels, panels, buttons, adding panels to cards, etc. Is there a way to simplify this?
How can I Impr... | stackexchange/codereview |
The code opens some files and does some transformations. I am looking for syntactical help where I can do the same thing I am doing now but speed it up. I can supply some of the calls code if requested.
Can anyone help me optimize this? I need help limiting my access to workbooks in order to speed this up.
Public Sub g... | stackexchange/codereview |
I've been using std::unique_ptr for cases where I want to store a derived-type value with type erasure, and felt that unique_ptr being nullable was an undesirable degree of freedom. From Polymorphic (owned) reference wrapper for class hierarchies I understand Adobe poly and boost probably have similar features, but I'm... | stackexchange/codereview |
I'm working on a project where I pull data (JSON) from an API. I would like to manipulate this data and store this as useful information in my DB (MySQL). My code is working if I would like to make, for example 2000 requests.
My script step by step:
Get IDS from DB, store them in array urls.
Take a chunk
Set and exe... | stackexchange/codereview |
I've written a program following the instructions of an exam paper. There are no solutions available so I would appreciate a feedback. I'm concerned with main in particular (I've already posted a similar question here). I've tried to solve the problem as I've seen it's done in other solutions made available by our teac... | stackexchange/codereview |
I would like to write a C++ code for the n-queens problem using the permutation approach. This means I index the queens from 1 to n, and the state of the checkerboard will be defined by an array where the i-th entry stores the row of the queen at the i-th column.
Clearly, such array will contain a permutation of the se... | stackexchange/codereview |
This is an algorithm for finding the closest pair of points on a 2d plane by dividing the problem by half recursively, as illustrated here:
use point::Point;
type PairDistance = (Point, Point, f64);
// Divide and conquer approach for finding the closest pair of points
// See https://i.stack.imgur.com/O3Drf.png
pub... | stackexchange/codereview |
Given a pandas data frame containing objects with ids and latitudes and longitudes:
id latitude longitude
0 a 52.617960 1.717728
1 b 51.773427 -4.455351
2 c 52.206543 -4.345786
I would like to find the closest object with a different id in the same data frame resulting in the following data:
closest_i... | stackexchange/codereview |
I wrote an extension to create a string-representation by an object:
public static string ToString<T>(this T @this, Func<T, string> predicate) where T: class
{
return predicate(@this);
}
So I can do something like
return handler.GetUserById(id)?.ToString(x => $"{x.LastName}, {x.FirstName}");
which gives me eithe... | stackexchange/codereview |
I have a library for simple Word Sense Disambiguation (WSD).
I have a function for WSD based on the sum of maximum similarity score for every word. But it's slow because it iterates through all words in the input sentence and then finds the max similarity score between the every sense of each word.
How could I speed up... | 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 |
I am an experienced Java programmer, but fairly new to JavaScript.
I am creating a chat library in JavaScript, and have it working, but want to know if I am going about this correctly, and following correct JavaScript coding standards.
I have a SDK object, LiveChatConnection class, and LiveChatListener and Credentials ... | stackexchange/codereview |
I am writing a code to search Product database and return result to user.
user can select various options like product attributes that varies from product to product, also there may be case like for single attribute there can be multiple value. For Example user can select brand as filter and can select from given brand... | stackexchange/codereview |
My code works, but my IDE is giving me warnings for unchecked method invocation. I have found useful information about Comparable arrays here. I have found useful information about unchecked method invocation here. Despite this, I just can't figure out how to please my IDE. My intention is to have the method select... | stackexchange/codereview |
I have here a script called rwog (run without groups) that allow a user to run a shell without particular group memberships. rwog, in more detail...
Is primarily for a support staffer to pretend to be an ordinary user without su-ing to anybody.
Must be run as root, but those allowed to run it will be given an entry ... | stackexchange/codereview |
I have implemented an Array class using templates. I have used a std::allocator object for memory allocation. Will it be better to use operator new along with placement new for memory allocation?
array.h
#ifndef ARRAY_H
#define ARRAY_H
#include <memory>
#include <cstddef>
template <typename T> class Array;
template<... | stackexchange/codereview |
I require feedback on the plethora of bad practices that are definitely existing in the following code:
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>
//***************************************************************
// CLASSES USED ... | stackexchange/codereview |
I have a function that changes the image on a webpage every three seconds. I would like feedback on efficiency, good code practices, and anything else that can improve the quality of this code. It works, I just want any insight if it can work any better. Any and all feedback is welcomed and considered.
Slideshow Script... | stackexchange/codereview |
To continue learning I decided to try solving some of project Euler problems. Here is the first solution.
The things I'm interested the most from the review are:
The performance of the code
Overall review of the code structure, styling rules and naming conventions.
Problem: 1
Find the sum of all the multiples of 3... | stackexchange/codereview |
What would be the best way to format this code? It looks a bit messy to me in regards to indentation etc.
if (typeof _srwc != 'undefined') {
for (var i=0; i < _srwc.length; i++){
var currentArg = _srwc[i];;
if (typeof window[currentArg[0]] == 'function') {
window[currentArg[... | stackexchange/codereview |
I've been working on this for a while, and now that I've got a working program I thought I'd see what other people think about it.
Basically if there is anything you think would make it faster or make it simpler, or make it better in general, please share your thoughts. As for actual strength, I have no idea how to tes... | stackexchange/codereview |
I am trying to sum primary diagonal and secondary diagonal of 2D array of python like this:
records = [[12, 5, 2 , 1], [15, 6,10 , 1], [10, 8, 12,1], [10, 8, 12,1]]
primary_diagonal_sum = 0
array_size = len(records)
secondry_diagonal_sum = 0
for index , record in enumerate(records):
primary_diagonal_sum += re... | stackexchange/codereview |
The following code is a python script that removes duplicate files in a given directory. At first I considered the most basic thing: relying on identical names, but you might have 2 different files with the same name in 2 different directories. So I decided to rely on md5checksum, since any 2 files that yield the same ... | stackexchange/codereview |
I've put together a simple CRUD application to keep track of my library of books in an effort to learn the model-view-controller pattern, as well as better myself at PHP. Everything I have works so far, but I'm definitely looking to streamline/condense/refactor the more verbose parts of it, as well as address any possi... | stackexchange/codereview |
This is my Python3 code which solved the 10th problem of Project Euler. I haven't passed the last 2 time limit test cases.
def sieve_of_eratosthenes(n):
result = [True] * (n + 1)
result[0] = result[1] = False
for i in range(2, int(n**0.5)+1):
if result[i]:
for j in range(i*i, n+1, i):
... | stackexchange/codereview |
Recently I have discovered one thing, which makes me feel frustrated. The Perl is lack of syntax sugar for strings, to do the same things, those are applicable to lists. The implementation I posted here would require to be rewritten to work for lists.
Thus, I had to re-write the code to Python to work for list as effic... | stackexchange/codereview |
How can I improve and optimise this code?
#include <iostream>
#include <vector>
std::vector<bool> sieve_of_eratosthenes(int n)
{
std::vector<bool> primes(n+1, true);
primes[0] = false;
primes[1] = false;
for (int i = 2; i <= n; i++)
{
if (primes[i] == true)
{
for (int j... | stackexchange/codereview |
Here is my implementation of a linked list in Scala.It is a very basic implementation to understand generics and use of Option in Scala. Please let me how I can make it better and implement it more effectively.
class LinkedList[A] {
val element: A = element.asInstanceOf[A]
var head: Node[A] = Node(this.element, No... | stackexchange/codereview |
I have a function that converts any normal true-type font to my own font file .bff
That function works correct and am not going to post that function for that matter
(the function is also only compatible with a specific engine you may not hear about).
If I post the .bff file and you have an environment in which you cou... | stackexchange/codereview |
K caterpillars are eating their way through N leaves, each caterpillar
falls from leaf to leaf in a unique sequence, all caterpillars start
at a twig at position 0 and falls onto the leaves at position between
1 and N. Each caterpillar j has as associated jump number Aj. A
caterpillar with jump number j eats ... | stackexchange/codereview |
Problem
Given a square matrix of size N×N, calculate the absolute difference between the sums of its diagonals.
Input Format
The first line contains a single integer, N. The next N lines denote the matrix's rows, with each line containing N space-separated integers describing the columns.
Output Format
Print the absolu... | stackexchange/codereview |
I've just made this program and I want to know how to improve it. It just receives a word and prints it backwards. Sequences of numbers are also accepted, but not white spaces (that's why I used scanf).
#include <stdio.h>
#include <string.h>
int main(void)
{
const unsigned short MAX = 30;
char array[MAX];
... | stackexchange/codereview |
I am looking to alter one combobox between two DataSources depending on the button clicked.
Here are the 2 lists:
List<ComplaintModel> productNames = new List<ComplaintModel>();
List<ComplaintModel> specificProductNames = new List<ComplaintModel>();
This is the functions for both of the Data Sources:
public Complaints... | stackexchange/codereview |
I'm parsing out specific values on web pages with BeautifulSoup. However, since I'm using RegEx, my program is taking forever to run. Would love ideas on how to speed this up.
from bs4 import BeautifulSoup
import datetime
import json
from progressbar import progressbar
import pdb
import pickle
import re
class Listi... | stackexchange/codereview |
Listing all \$\binom{n}{k}\$ combinations of i is a well-solved problem in J. From that article, there is this implementation:
comb=: 4 : 0
k=. i.>:d=.y-x
z=. (d$<i.0 0),<i.1 0
for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
; z
)
used as follows:
4 comb 6
0 1 2 3
0 1 2 4
0 1 2 5
0 1 3 4
0 1 3 5
0 1 4 5
0 2 3 4... | stackexchange/codereview |
I encountered a problem at http://regexone.com/example/6?
You can view the problem by clicking the link.
There was required a regular expression to extract the method name, filename and the line number from a particular stack trace in an android development application.
I used the following regular expression to solve... | stackexchange/codereview |
I think many days ago, I randomly got introduced to cucumber developement, And it seemed like a conventional and interesting principle of software development.
At this very time, I'm concentrating on creating a Linux based terminal software.
For this sprint, I decided to use a principle of cucumber development which is... | stackexchange/codereview |
I have this simple code in Python:
input = open("baseforms.txt","r",encoding='utf8')
S = {}
for i in input:
words = i.split()
S.update( {j:words[0] for j in words} )
print(S.get("sometext","not found"))
print(len(S))
It requires 300MB for work. "baseforms.txt" size is 123M.
I've written the same code in Has... | stackexchange/codereview |
I wrote a PHP connector that will allow me to communicate with a REST API. This is the first time I am trying to make my code as clean as possible. I want to help myself learning how to better code.
I have done everything I can think of to make my code clean and easy to read, but I would like to get feedback from the e... | stackexchange/codereview |
It's a simple bash script but I'm hoping for feedback, advice and examples on how to improve the script and code. Can you guide me how to put more checks in the code and more if possible?
This code:
Sets IFS variable and backs it up
Sets a trap for signals that can kill the script and a trap for exit to do run a clean... | stackexchange/codereview |
This question is part of a series of posts about my massive Tic Tac Toe game with AI players, the previous question is: GUI Tic-Tac-Toe game with six AI players - part 1: the UI. This question includes all the code necessary to stylize the GUI.
The final part is: GUI Tic-Tac-Toe game with AI, part 3: control and logic
... | stackexchange/codereview |
I've implemented the well known Luhn Algorithm in Python. It's a simple one, so it's good for beginners.
import random
from math import ceil
def Luhn(digits):
if digits >= 2:
num = random.randrange(10**(digits-2),10**(digits-1))
num_digits = list(str(num))
for i in range(0,digits-1):
... | stackexchange/codereview |
What I am working on has sets of window controls. Controls are constantly being either destroyed, or created.
void ChangeControl() {
// remove all controls, existing, or not
hwnd = GetDlgItem(hWnd, IDC_BTN_FOOA);
DestroyWindow(hwnd);
hwnd = GetDlgItem(hWnd, IDC_BTN_FOOB);
DestroyWindow(hwnd);
hwnd = GetDlgItem(hWn... | stackexchange/codereview |
I have a situation where I am receiving data from a web service and the data is in all caps. I have to convert to HTML and format for display. In this case, we need the string to be normalized. The XML we receive has the possibility, and most of the time is, large, sometimes being over a MB in size. Performance is ... | stackexchange/codereview |
I'm new in this community and with Python 3!
I'm trying to optimize this exercise:
We have n strings stored in a txt file.
Inside the strings a secret word is hidden as a substring of
consecutive characters.
We know with certainty that the word repeats itself exactly once in each
string but we don't know where. ... | stackexchange/codereview |
My task is:
In this challenge, write a function CountLOC.count to count the lines
of code in a Java source file. A line of code is defined as any line
in the source which contains at least one character of executable
code. This excludes comments and whitespace. All input will be valid
Java code in string format.
Cou... | stackexchange/codereview |
In my small application, I need to use a variety of visual themes.
The simplified structure of this class:
Theme
|
.__ menu
| |
| .__ screenBackground
| .__ itemsColor
| .__ getRandomItemAnimation()
|
.__ game
| |
| .__ screenBackground
| .__ gameBoardBackground
| ... | stackexchange/codereview |
I am working on a Yahtzee game development for two players that consists of all the categories Full house, Yahtzee, ones, twos, threes, etc.
I have implemented the interface that works for two players and displays the winner at the end of the game, but I don't think it is efficient need feedback and suggestions to impr... | stackexchange/codereview |
I am developing a Java program on Windows. I want to access Wi-Fi interface details such as SSID, IP, subnet, enabled or not, connected or not and so on. I am currently trying with using netsh and ipconfig commands.
For example, here is how I get the connected SSID. Is this a good way? Is there any better, easier metho... | stackexchange/codereview |
I'm refactoring some code around a couple of ASP.NET Web Forms pages and decided to try out a variation of the Abstract Factory pattern of my own design. I need to create an implementer of an abstract class based on what query string value is available.
Here's (a simplified version of) what I have right now:
internal s... | stackexchange/codereview |
I am hoping to find a way to make the process a lot faster. The lists are made of rows of 6 numbers, i.e. [[float] * 6, ...]. The intent is to pass a list of cube co-ordinates (only two 3D co-ordinates, which are opposite corners) and get a shorter list of co-ordinates of 3D quadrilaterals.
# Merging by creating a list... | stackexchange/codereview |
I'm trying to replicate the attributes text that appears in File Explorer, for files and directories.
I can't just use the enum names, as the summary text uses a single character for each set flag, and that character isn't always the first character of the enum member. I'm also not using the reserved FileAttribute.Devi... | stackexchange/codereview |
Is there a better way to loop item of an array using forEach and make repeat it using setTimout/Interval or something else?
I need that each item of the array was repeated each value of delay for some time (duration):
const arr = [
{ delay: 1_000, duration: 3_000, msg: "Hello World" }, //repeat 3 times msg for 3 sec
... | stackexchange/codereview |
I'm learning how to write code in Python. This code makes an .ini that saves different cycles adding one new operation to the previous cycle. It starts at 1;1, saves that it has run 1 cycle and will start cycle 2 next time. So, next is 1;2 followed by 2;2. Next cycle is 3, so it will go up to three: 1;3, 2;3, 3;3, etc... | stackexchange/codereview |
I want to know if it is okay/safe to use a prepared statement and mysqli_num_rows like this:
public function getUnreadNumber() {
$userLoggedIn = $this->user_obj->getUsername();
// get_result for * and bind for select columns
// bind_result Doesn't work with SQL query that use *
$query = $this->con->pre... | stackexchange/codereview |
For the following question, the function
• should mutate the original list
• should NOT create any new lists
• should NOT return anything
Functions that do not create new lists are said to be ”in place.” Such functions are often desirable because they do not require extra memory to operate.
Implement the function map_... | stackexchange/codereview |
This is my first go at a Perl script to (semi-) automate setting the correct IP settings. I use it to configure a virtual machine after creation. It's also my first Perl script as a whole, so I'm looking for anyone who can give me pointers towards a better and more efficient coding style.
#!/usr/bin/perl
use strict;
... | stackexchange/codereview |
I created my cross-platform implementations of getline function in C.
It takes different arguments and have different return values than 'original' getline function, but aim is the same. The only argument input_file is file from which the line have to be read. Return value is the line read from file or NULL if nothing... | stackexchange/codereview |
I have completed an ETL project to collect, parse and load files. I decided to make it clean OOP way using interfaces and abstract, but have some questions below.
Sub Main()
Dim collectionOfParsers As New List(Of EtlParser)
Dim xmlparser1 As New XmlParser
Dim xmlparser2 As New XmlParser
... | stackexchange/codereview |
There's a new version of this as v2 - Adding a duplicate entry randomly into a list in haskell using random monad
I wrote this trying to set up a Haskell testcase. The aim is to take a list and add a single duplicate from any place in the list to anywhere else in the list.
I'm trying to learn to use the Random Monad p... | stackexchange/codereview |
I coded an executable program (.exe) that I only want run either from my home computer, our main server, or people in our development team.
I have coded logic that will only allow the program to be run from certain IP addresses.
The .txt file that's referenced in the getIPlist function looks like this:
[123.456.78.90]... | stackexchange/codereview |
I wrote code for determining the push button state whether it is long pressed or not. This function is called by timer interrupt routine every 1ms.
But it seems really dumb. How can I make it shorter and more efficient according to both readability and professional rules? What should I add or change to get double Tap p... | stackexchange/codereview |
I'm a beginner in C++ and I would appreciate advices to optimize the following function I wrote with Eigen (in fact, to be used with RcppEigen).
So far, I observe a 3.5x speed-up compared to the corresponding function written in R, and I was wondering whether I could gain more.
Note that I'm working with very large mat... | stackexchange/codereview |
I needed a special graph structure for my code and thought I'd write a generic one for later reuse.
At first I wanted to use pointers instead of indices as map keys but I quickly forfeited that idea once I realized, that changing the vertex vector might invalidate them. I'm especially interested if there are problems w... | stackexchange/codereview |
I've been working for few days to develop a basic Java Swing Calculator that could Add, Subtract, Multiply or Divide two numbers and also has other options like inverse(1/x) and square root
I would like you to analyze my code that it follows basic OOPS concepts like Abstraction, Encapsulation, Polymorphism etc.
impor... | stackexchange/codereview |
This is my first post here, so I apologize if anything is incorrect.
I have created an endless arcade stacker game (like the stacker games at the arcade, but when you hit the top the grid resets and you continue endlessly). My intention in the code was to separate out the core game logic (i.e. the code that moves the s... | stackexchange/codereview |
I've recently put together a library for working with Crypto in Go.
I did not roll my own, I'm relying on stdlib for the core parts of this, but I would still like to get this reviewed by some experts in case I've done something horrific.
If you're interested and want to view this in a more palatable format, you can fi... | stackexchange/codereview |
Inspired by a question on SO I was checking how to calculate the cube root of an integer and found a C-ish solution on Hacker's Delight:
// Program for computing the integer cube root.
// Max line length is 57, to fit in hacker.book.
#include <stdio.h>
#include <stdlib.h> //To define "exit", req'd by XLC.
// Execu... | stackexchange/codereview |
My goal was to get my hands dirty in OOP by designing and using classes and getting started with inheritance and other OOP concepts.
I have written a very small code to play a card Game called "War". The rules are simple. Each person playing the game is given 1 card. The person with the highest card wins. I am not wor... | stackexchange/codereview |
I'm looking for a general review of this AVL tree implementation:
#pragma once
#include <cmath>
#include <algorithm>
namespace mds {
template<
typename T,
typename Func = std::less<T>
>
class avl_tree {
struct Node {
T key;
int h;
Node *le... | stackexchange/codereview |
I'm working on a C# implementation of a tree class.
The tree will be used wherever I need to store data in a tree format. (Application Menu, File Infos etc.). Therefore, the tree should support a lot of different use cases.
I think my implementation is ok… but I'm not sure. I never implemented a tree before and I also ... | stackexchange/codereview |
I am writing a code that takes two numbers N and M and finds the greatest result of A mod M for all the numbers of A in the range 1,2,3,...,N-1,N.
1 ≤ N,M ≤ 10^9
My code is:
public static void main(String[] args) throws IOException {
long n=readLong(), m=readLong(), a=Integer.MIN_VALUE;
for(int i=1; i<=n; i++)... | stackexchange/codereview |
I have been developing a software driver for the internal a/d converter on this platform. The a/d converter peripheral is described in following document. The driver is written in C++ and is build upon existing driver which has been developed by the platform manufacturer in C language. The reason why I have decided to ... | stackexchange/codereview |
I am trying to learn how to tell if my code will be better off creating a class as opposed to using many functions. I am a new Python programmer trying to get the hang of when classes should be implemented.
Determines whether the username is valid or invalid:
def is_good_user(user):
is_user_good = True
if user ... | stackexchange/codereview |
I have created this method to do all my WebRequests.
Generally my question is, if this could be improved in any way.
As a side question, I would like to know if it be better to create methods for each type (PUT, POST, GET, UPDATE, DELETE) of a request separately?
/// <summary>
/// Test-Method
/// </summary>... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.