« first day (3187 days earlier)   

12:00 AM
REFRESH! There are 8030 unanswered questions (89.2163 answered)
12:32 AM
Q: Generically calculate powers of two below a number

Simon ShineThe following function is an attempt to generate powers of two below the input number max. So powers_of_two_below(15u8, u8::BITS) generates 1, 2, 4, 8. It does calculate 16, but does not include it. This function avoids calculating powers that cause overflow by taking bits as input (since there d...

12:58 AM
Q: Try-catch-finally with 'using' in ADO.NET

Pablo Aguirre de SouzaI want to check if I'm correctly disposing of resources using Ado.NET. I'm not sure when the 'using' statement makes .Dispose() irrelevant. Please bear in mind I'm aware I shouldn't hardcode my SQL commands, this is just for training purposes. Thanks in advance! internal void CreateTable(string...

Q: Recursively delete directory using relative file system calls?

user254467int SavesFD; static int Recursive(const int File, const char *const Name) { const int File0 = openat(File, Name, O_DIRECTORY); if (File0 == -1) return 1; DIR *const Dir = fdopendir(File0); if (!Dir) return 1; for (struct dirent *Dirent; (Dirent = readdir(Dir));...

1 hour later…
2:01 AM
Welcome to Stack Overflow. Please take the tour and read about what's on-topic in the help center. We're not here to do open-ended code review. Specifically, what do you mean by 'I feel the "output_file" is too long'? — Chris 50 secs ago
2:17 AM
Q: Alpha Beta pruning minimax chess algorithm optimizations

syntaxerrorI'm a new programmer currently coding a javascript alpha-beta pruning minimax algorithm for my chess engine, using Chess.js and Chessboard.js. I've implemented a basic algorithm with move ordering. Currently, it's evaluating around 14000 nodes for 8 seconds, which is way too slow. Is there someth...

2 hours later…
4:21 AM
This question belongs to [codereview](codereview.stackexchange.com) — Reblochon Masque 10 secs ago
Q: Categorize similar transactions

user254476Please review the code to categorize some uncategorized objects: const categorizeSimilarTransactions = (transactions) => { if (!(Array.isArray(transactions) && transactions.length)) return []; const uncategorized = []; const categorized = []; const orderIds = transactions.map(t...

Q: C++ : Garage Sale Algorithm

frozencaI'm studying Dasgupta's "Algorithms". I solved this problem in C++: The garage sale problem. On a given Sunday morning, there are \$n\$ garage sales going on, \$g_{1}, \cdots, g_{n}\$. For each garage sale \$g_{j}\$ , you have an estimate of its value to you, \$v_{j}\$ . For any two garage sales...

5:16 AM
Q: Finding the minimum element of a stack of numbers

gparyaniAs part of an online programming challenge, I wrote a program that implements a stack of integers, supporting adding and removing elements, finding the last inserted element, and the minimum element. The premise is that all methods must be implemented in constant O(1) time. In my code, I opted to...

6:03 AM
possible answer invalidation by Susheel Busi on question by Susheel Busi: codereview.stackexchange.com/posts/273261/revisions
6:20 AM
@Duga seems ok. Adding example data
6:43 AM
@TipTop´╝î you may looking for code review codereview.stackexchange.com, not stackoveflow. Also you should asking several questions on 1 question, this is considered not focused. You could consider accepting the answer if it solves one of questions — Shawn 33 secs ago
@Mast, sorry my misunderstanding about code review — Shawn 29 secs ago
2 hours later…
8:31 AM
@ChayimFriedman Ok I got your point. Yes, it does generate for addition, although with a different message. godbolt.org/z/n4v7qoqP6. But still, this is very useful within code reviews. I take it. — Jellyboy 31 secs ago
8:51 AM
codereview.stackexchange.com is a better forum for this. — Tyler Durden 14 secs ago
@TylerDurden No! If there are error messages, the code doesn't work yet. If the code doesn't work, it's explicitly off-topic at Code Review. — Mast 40 secs ago
Q: Pytorch: RuntimeError: mat1 dim 1 must match mat2 dim 0 using 2D CNN model with pretrained vgg_16

user254485 I am working on cardiac CT data(axial, sagittal, coronal). I am using the pre-trained model vgg_16. But got the following error. According to this error, my dimension is not correct but according to my code, I write things correctly Can somebody guide me regarding this I try to correct my code a...

9:49 AM
Q: Generic REST API feedback

sibertMy intention is to create an API as generic and DRY as possible using Go. To achieve this, I have made some more or less common decisions: To use AJAX call to avoid reloading page when updating the web page. Instead of using Go. To exclude hard coded queries from the API to reduce the endpoints ...

Q: Sim Registration Script for access to Internet

NathanDetails: Based on the input parameter to return corresponding output which is needed for setting & accessing Internet over interface [ppp0]. If the SIM is registered[ status = 1]. This script will be called in another based on cli. Code: #!/usr/bin/env python3 import os import datetime import sys...

10:15 AM
Q: Python: best way to setup a config library

pee2peeI am refactoring some legacy Python code and thought I'd put the config into it's own file as below. My question is whether I'm trying to be too clever with the last part? Could I just return the dictionary of endpoints and be done with it? The idea for the dictionary is that it could be shared a...

10:41 AM
Q: Python: How to use

pee2peeThis moves on from Python: best way to setup a config library slightly I have the following code which builds up a dictionary of endpoints that I iterate through later on. Is this the cleanest, most scalable and performant way? I was thinking of adding a list as a key to the library file with key...

11:13 AM
possible answer invalidation by AlwaysLearning on question by AlwaysLearning: codereview.stackexchange.com/posts/273282/revisions
11:34 AM
Q: How to use collection from Postman to send HTTP request and after updating the bearer token?

DurgaI am currently trying to automate API testing using Python. I have stored the API endpoints in a CSV file and read the data through the loop to fire the requests. But I am getting HTTP Error 400. The requested URL is invalid as it's unable to encode the link while extracting the URL from CSV. The...

11:50 AM
This question may be better suited for Code Review. — Bram Vanroy 33 secs ago
12:01 PM
Q: How can I optimize my code that contains 3 nested for loops

yosraI would appreciate to have your opinion on this code and whether I can refactor it and make it cleaner, I don't like the fact that I have 3 nested for loops, wi-hich makes the complexity of this code O(n3). categories = {} for k1, v1 in res["relationship_types"].items(): for k2, v...

12:53 PM
Q: Pandas: process data on dataframe subsets

Achille GI have written a piece of code which select each ID whose value equals something, then select a subset for each ID and then work with the subdata. My dataset has over a million entries, thus the code execution is very slow. Am I doing this the most appropriated way ? condition = (df["TYPE_APPEL"]...

1:20 PM
Q: Python: iterating with .items() or not?

pee2peeI have this code for endpoint in endpoints: if key in endpoints[endpoint]['keys']: yield endpoint pylint suggests iterating it with .items() for parent,child in endpoints.items(): if key in child['keys']: yield child Now when I do, I get a warning about an unused variabl...

1:46 PM
Q: linear search through an array

user1095108If you check the generated code for these functions: int a[]{1, 2, 3, 4, 5, 6, 7, 8}; auto find1(int const v) noexcept { auto p(a); [&]<auto ...I>(std::index_sequence<I...>) noexcept { ((*p == v ? true : (++p, I - I)) || ...); }(std::make_index_sequence<std::size(a)>()); return p...

1:58 PM
Maybe you're looking for a Code Review? — Fred Larson 58 secs ago
2:11 PM
I think this question is better post to codereview.stackexchange.comSimone Rossaini 38 secs ago
1 hour later…
3:17 PM
Alternatively, consider posting on Code Review: codereview.stackexchange.com/questions/tagged/mysql. Stackoverflow is for help with specific coding tasks that produce an expected error and can be solved. If you have working code, then Code Review is the better place to post this. — Tim Lewis 15 secs ago

« first day (3187 days earlier)