« first day (2238 days earlier)      last day (1769 days later) » 

12:00 AM
0
Q: A STL-like vector implementation in C++

Bilal AhmedI'm implementing a STL-like vector with the essential functionalities. I would like to know what is good in this code and what is bad. In terms of everything (memory usage, functions implementations, naming conventions, etc,...). The header: #ifndef BVECTOR_H #define BVECTOR_H #include <memory>

 
RELOAD! There are 6117 unanswered questions (89.8554% answered)
 
 
1 hour later…
1:20 AM
0
Q: Condensing a simple 'if' and 'else' C# "Credit check" program's code

Aaron aQQNThis is a working program to check an item's price against available credit. I'm trying to simplify this program to the bare min. it would require to run so I'll be better able to understand each part of the 'if' and 'else' processes. Is there a simpler way to write a program that accomplishes th...

 
1:40 AM
0
Q: Safe dynamic SQL for generic search

thisPrompted by discussion about SQL injection, I wanted to put a proof of concept forward to get feedback about whether this is in fact safe and protected against SQL injection or other malicious use. For good reference on the subject of constructing a dynamic search with dynamic SQL, I'd probably l...

 
2:20 AM
0
Q: Replacing Numerical Columns using pandas

Dylan HilligossI'm looking to replace the values of 2 specific columns (not including the header) of a data file that I have with randomly generated values. I already have the random values defined and now I'm looking to replace the columns of the original file with these new values. Each has 251 entries so it ...

 
 
4 hours later…
5:57 AM
@Peilonrayz IMO that would be preferred, but it's your question so your call.
Monking all
 
0
Q: how to use conditional #define in arduino?

user203227I am developing a code for arduino in which I am using "#define DEBUG" statement. If DEBUG is defnied, I need to print debug log (which I have included as Serial.print() statement.) and if DEBUG is not defined I don't need to print the data present in Serial.print() statement. I am not able to r...

 
 
1 hour later…
7:26 AM
0
Q: python : Collatz Sequence

coderI am a beginner in python. I found this problem in the book Automate the Boring Stuff with Python. How can I improve this program using latest version of python. def generateCollatzSequence(number): print(str(number) + " ") while number != 1: if number % 2 == 0: numb...

 
7:39 AM
I feel like I got a suspicious number of upvotes in hust three days
Are there bots around?
 
-1
Q: Best practices for developing a class

user4838962I have developed the following class header and source file. I need some advice on how can I improve this implementation according to C++ best practices: #ifndef AUTORAYCASTHANDLER_H #define AUTORAYCASTHANDLER_H #include <QObject> #include <Qt3DRender/QAbstractRayCaster> class SuppPoint; clas...

0
Q: Python maintain precision for currency

Bruno VermeulenWorking with currencies I am aware it is not good to work with floating point values due to rounding and maintaining precision. Better is to work with integers. Would the following Currency class make sense, where an amount is defined as an instance of Currency and converted to cents. class Curr...

0
Q: Email Generator needs the ability to retrieve lists

AkusasI've written a function that generates an HTML email and fills it with information from a database. Here is the Email Generator function. It is fairly generic, so that it can be used in a wide variety of email templates. public interface IMailObject { string Subject { get; } ...

 
 
1 hour later…
9:06 AM
0
Q: Padding multi-dimensional array to its max shape

pLOPeGGFor some machine learning purpose, I need to work with sequences with different lengths. To be able to process efficiently those sequences, I need to process them in batches of size size_batch. A batch typically has 4 dimensions and I want to convert it to a numpy's ndarray with 4 dimensions. For...

 
9:27 AM
Question is not ontopic here it should be asked on codereviewRaymond Nijland 5 secs ago
I'm voting to close this question as off-topic because it should be asked on codereview.stackexchange.comRaymond Nijland 53 secs ago
 
9:56 AM
Although for architectural related advice I would suggest codereview.stackexchange.com your fifth point is a really good point. Do note the OP update was wrong, check the edit in my answer because atm your answer would update the whole table. — bradbury9 52 secs ago
Some code review (that you did not ask for): the way you define collect_y is super confusing, you overwrite it multiple times. I speculate this is due to multiple tries to convert from string into floats, and that the desired effect is achieved by the single line collect_y = [float(s[0]) for s in lines[1:]] after the loop. Also, the x=[some_fun(x) for x in x] pattern might be valid Python, but it is an awful idea; use x=[some_fun(y) for y in x] instead for clarity, or even new_x=[some_fun(y) for y in x]. — Leporello 38 secs ago
 
10:26 AM
0
Q: Enter code block if no thread is there, otherwise continue

Geesh_SOMy goal is to essentially have something that performs a LockOrImmediatelyContinue instead of the current Lock which will wait until another thread has finished. With some setup elsewhere, I have a task that calls this job's Execute every 30 seconds (https://github.com/fluentscheduler/FluentSche...

 
11:06 AM
0
Q: python: Is there a winner in tic-toc game?

kharandziukBelow a function which answers: is there a winner in tic-tac-toe game? also, there is a self written test suite. def is_win(field): # check horizontal N = len(field) for i in range(N): if field[i][0] != 0 and len(set(field[i])) == 1: return True vertical ...

 
11:23 AM
@Mast I wrote an answer too saying what I think the problems with each solution is.
Feel free to mash the DV button
 
11:46 AM
0
Q: Traversing a graph without getting stuck in an infinite loop - making more understandable

FowlA People may have 0 to n delegate People, and any of their delegates may have any number of delegates, and so on. But what if they set up a loop? We could get stuck in an infinite loop if this happens so we better keep track. public IEnumerable<People> GetPeopleDelegatesRecursive(People p) { ...

 
12:06 PM
-1
Q: Async service bus mesage procesing

Adrian GodoyI want to do async processing of a service bus message and I ended up with this code. I don't know exactly why but I don't like it. it is the right way to proceed? queueClient.OnMessageAsync(message=> Task.Factory.StartNew(new Action(()=> ProcessMessage(message)))); the p...

 
12:21 PM
 
12:40 PM
possible answer invalidation by Daniel Foust on question by Daniel Foust: codereview.stackexchange.com/posts/222583/revisions
 
-1
Q: What is wrong with my 'except' code here?

william3031I am learning python and am working through some try and except codes. What is wrong here? The code aims to convert the input in to an integer unless it is not numeric. try: def get_integer(my_var): try: x = round(my_var, 0) return x except: ...

 
1:33 PM
I've got a security process question, for all the experts here.
Suppose I'm running a CMS and Alice bought an account.
Now, Eve doesn't like Alice and wants to deface her site, so is running a script to try to guess her password.
My CMS detects that the password is being guessed wrong, so it triggers a logarithmic timeout (first guess 10ms, second 100, third 1000, fourth 10000, etc.).
Meanwhile, Alice wants to log into her site, but Eve already has it spun up so her wait is long enough that she can't within any reasonable amount of time. How do I handle this?
I mean, I could ban Eve's IP after a certain number of failed attempts...
But Eve will just switch IPs.
Or, I could do a sort of honey-pot and not tell Eve her IP is banned, but always reject any login from that IP.
Basically, sandbox Eve's script. And let's assume Eve isn't trying to DDoS the CMS.
How do I help Alice get access here, but keep Eve out?
Because essentially Alice's account is being DDoSed, even if the whole site isn't.
 
1:56 PM
NVM, I just figured out how to tie my microservice in with ASP.NET Identity, which handles this.
 
2:08 PM
0
Q: Vue/PHP - Parsing a table-like layout

oliverbjSo I have a website, where my users can create "table-like" layout dynamically. So imagine that my users can upload a text document, and then append columns to the document, and the output will then be parsed into a table-like layout. For example: My text document Date: 20-06-2019 ...

0
Q: Web app that can trigger sirens for personally owned cameras in remote locations

HunterWeb-app summary: I'm a complete beginner in web development and I made a sample web application that can trigger sirens on security cameras located in remote locations. Here's the functionality seen by the user: Go to website and brought to a landing page with a search bar. Type in the name of...

-1
Q: O(E+V LOG V ) Implementation of Dijkstras Algorithm

justanothertechdudeI am trying to implement Dijkstras algorithm using python using complexity stated in title, could I get some feedback on code style and efficiency. Thank you def dijkstra(graph, start): distances = {vertex:float('inf') for vertex in graph} pq = [] pq_update = {} distances[start] = 0 ...

 
Greetings, Programs.
 
@Donald.McLean Greetings and Salutations. What offering did you bring your robot underlings this morning?
 
@Hosch250 The first rule of software security is - don't write it yourself if at all possible.
2
 
This question should have been asked on Code Review codereview.stackexchange.com/questions/tagged/swiftielyamani 26 secs ago
 
Yeah, I know :)
That's why asked for a procedure.
 
2:20 PM
My code violates that rule in several places and needs to be fixed. But I didn't understand that rule when I started this project - the project is seven years old and I've learned a lot in that time.
 
If the code is complete and working, it should be on Code Review, not here. — Carcigenicate 7 secs ago
 
0
Q: C reoganize code in order to have 2 function

CedI have the following code (that perfectly works) however I would like to make it more readable. Idealy I would like to cut it into 2 function. void list(char *dir, int i) { struct dirent **d; int n; int a = 0; dir = correct_dir(dir); if ((n = scandir(dir, &d, NULL, alphasort)) < 0...

0
Q: calculation performed in a string

user203260I'm getting n number of strings from the user.The first input is the item name, price and discount percentage separated by comma(,) Eg:book,10000,10 this is how the string looks like.Print the item that has the minimum discount offer.offer is calculated as (10000*10/1000). I calculated the offer ...

 
3:08 PM
-1
Q: Parent class wrapping child class method

itamarI have this Worker classes doing some job class WorkerOne implements IWorker { @Override public doWork(Resource resource){ // do some work } } I want all doWork() methods to be wrapped by the same operation. Currently it is done by sub-classing Worker classes from abstract cl...

 
3:25 PM
possible answer invalidation by Justin on question by emadboctor: codereview.stackexchange.com/posts/222647/revisions
 
1
Q: Python - Activity Selection - Greedy Algorithm

emadboctorI've done this activity selection piece of code, which is a greedy approach. I need some feedback/suggestions. import random import operator begin = [random.randint(1, 10) for i in range(10)] end = [x + random.randint(1, 4) for x in begin] pair = sorted(list(zip(begin, end)), key=operator.item...

 
|\/|<>[\]|{\|[\]6
 
@Peilonrayz stellar!
 
After the swearwords meta question I decided to make a leet converter... Some output is just illegible tho
 
3:51 PM
@Duga its fine - code fence was removed and regular HR line added
 
The best approach is to make an effort to try something. When you get stuck then ask a question here. If you solve the problem, and want feed back as to how to optimize it, then ask a question on code review stack exchange. — scrappedcola 23 secs ago
 
4:13 PM
Requests for commenting on code and suggesting improvements are more appropriate for Code Review. — Barmar 47 secs ago
 
Monking
 
4:49 PM
0
Q: Sticking to a working proxy generated by a rotating proxy script

MITHUI've created a script in python to make proxied requests by picking working proxies from a list of proxies scraped from a free proxy site. The bot traverses few links to parse the urls of the different posts from a website. The script however uses a new working proxy every time it makes a new req...

 
5:09 PM
0
Q: PHP Error handler class

K.DI set up an error handler class to handle all server errors, I know there are already quite a few out there, but I like creating my own for better learning and understanding of how things work. I am currently using this in a framework I am working on (again, for learning purposes), and its workin...

 
Please post this question on Code Review if you want feedback for working code. — Nico Schertler 28 secs ago
 
5:41 PM
If it works but you don't like the java-ness, i'd move that over to the code review stack exchange? If you want to change things, i'd start with using groovy features (e.g. use "var_${i+i}" GStrings, get rid of the stream stuff in the middle) and get rid of the copy-and-paste imperativeness (e.g. accumualte the keys to remove, than do a keys.each{ vars.remove it }; build a map for adding and use putAll, ...) — cfrick just now
 
6:00 PM
possible answer invalidation by Justin on question by emadboctor: codereview.stackexchange.com/posts/222647/revisions
 
0
Q: I need feedback / suggestions for improvements on Egyptian fraction, written in Python

emadboctorhere's my code for the Egyptian fraction written in Python, I need your feedback if there is any room for improvement. def eg_fr(n, d): ls = [] ls_str = [] fraction = n / d total = 0 for i in range(1, 1000): ls.append((1/i, str(1) + '/' + str(i))) for i in ls: ...

 
It is a question about optimising running code and should better asked at Code ReviewJens 44 secs ago
 
6:50 PM
0
Q: BASH script to obfuscate android/meterpreter payloads

graylagx2I have written a little script that does a pretty good job of obfuscating android/meterpreter payloads. It will generate payloads or used supplied msf payloads while also injecting a custom icon. The Original payload generated by metasploits msfvenom triggers 28 0f 60 anti-viruses on virustotal.c...

0
Q: Rock Paper Scissors C# game with rounds input

Alejandro HI have a Rock Paper Scissors project in c# and I was wondering if I could get some feedback on how to improve my code. I ask the user how many rounds the user wants to play. The maximum number of rounds allowed is 10, anything else besides a number 1-10, will exit the program. I would also like t...

 
7:34 PM
Except you haven't. As pointed out in code review, the problem exists at return "'" + context.Text + "'"; in GetValue because that's where the conversion from string value to string expression occurs. Regarding jokes: SQL injection is a major attack vector so SO is very vocal about it. Many, many jokes and analogies are used on SO to make the point because it needs to strike a dissonant chord to get the proper attention (and it's still quite often ignored). Plus, it gets very repetitive. — madreflection 36 secs ago
This may be a good question for the Code Review stack site — G. Anderson 37 secs ago
 
8:10 PM
0
Q: Excel - Visual Basic For Applications - Mastermind Game

learnAsWeGoFor those who are unfamiliar with the game: https://en.wikipedia.org/wiki/Mastermind_(board_game) A link to the workbook: https://github.com/Evanml2030/Excel-Mastermind Had trouble getting the form and scroll bar to adjust based on the resolution of the monitor that it is inside. It does not...

 
8:47 PM
@HS-nebula OP has stylistic issues that are better answered at Code Review Stack Exchange. The json_file.close() is one of them. — Akshat Mahajan 26 secs ago
 
9:30 PM
0
Q: Creating multiple lists of named tuples based on condition

brad999I have created a function which is used to create a list of named tuples. The tuple which is created is dependent on the format of 'instructions' in which there are 3 different formats. Instructions is just a list of lists. I wanted to improve the readability/maintainability of this function and ...

1
Q: Find matching dictionary words given a Scrabble tray

John HewsonThis is a question I was asked in an interview, below is a cleaned-up copy of the answer I gave. Apparently this answer was not satisfactory. How can it be improved? Question: Given a dictionary of words (a text file with 100000+ entries) and a list of n letters with possible repeats (i.e. a Scr...

0
Q: Program to delete directories that do not contain a file

lc74I'm an intern and have an ETL project I'm doing in python and part of it is to make sure after I move files I delete empty directories. I wrote this code to clean up directories that are empty and in testing it works for me but I want to make sure it won't end up deleting folders full of files. ...

0
Q: Python IMAP login bruteforcer

choketBelow is the code of a command line tool built with python that will download email via IMAP. Omitted from the code below are 2 important function parse_line and server_login. parse_line takes a string containing data and returns the email and password from that string as a dictionary. server_...

 
10:10 PM
0
Q: C - I need feedback and cleaning suggestions for my little program (multiplication exercise)

NevralgeekI'm a complete beginner, but I'd like to learn how to program. So I tried the common exercice, aka the multiplication table, but I tried to add little things I learnt recently in order to challenge myself, like functions, tables and pointers even if it's useless here. The code works well, but I...

 
10:47 PM
0
Q: Couldn't dismiss mr. robot

PeilonrayzToday I was greeted with MR. ROBOT, I wanted to close the prompt but the little x didn't work. Clicking above the prompt, to the right of the code, did close the prompt however.

 
11:10 PM
0
Q: Using an Array Constant to Store Multiple Values in Cell

TinManFor a recent project I needed to store id references to values of pivoted data. Usually, I would use helper columns to store the ids but in this case there could be anywhere from 1 to several hundred pivot values to track. My solution uses no helper columns. Instead it stores a row-header valu...

 
11:30 PM
0
Q: Hangman Program in Python

Parth PatelI am fairly new to coding and decided to test my skills and make a program from scratch on my own. I chose to make a Hangman game, it's pretty straight forward. The code reads a file consisting of ~40,000+ words to choose from when generating a word for the user. The user inputs the number of att...

0
Q: Building a consume function for iterators

JabSo I was reading into the proper way to consume an iterator on this question as well as here and I notices there is no actual proper function for this that clearly explains itself. Using: collections.deque(maxlen=0).extend(iterable) isn't exactly very descriptive whereas making a properly nam...

 
its been a busy day in the lesser-active review queues: 3 suggested edits, 3 reopen items, 2 late answers and a couple low quality posts
 

« first day (2238 days earlier)      last day (1769 days later) »