« first day (2924 days earlier)      last day (50 days later) » 

12:01 AM
RELOAD! There are 7541 unanswered questions (89.4682% answered)
Asking for recommendations is off-topic here. That said, for the Stack Exchange network, there is Code Review. Please make sure to read their help pages on how to properly ask a question there. — Gino Mempin 5 secs ago
1 hour later…
1:27 AM
Q: Best swifty way to optimise code

VizllxThis is a part of code, I want to optimize case let .background(medias): self.gMedias = medias.filter { ids.contains($0.id ?? "") } case let .sounds(series): let sounds = series.filter { !($0.media?.isEmpty ?? false) } Here is refactored code adding Sw...

Q: Subclass of Python's multiprocessing.Pool which allows progress reporting

gabe appletonFor context, the whole of the project code can be found here. This question was created specifically for the progress.py file. The goal behind it is to allow progress of long-running tasks to be reported to a tty terminal. This helps you quickly figure out if your jobs are progressing or stalled....

2 hours later…
3:33 AM
Q: FIVE string manipulation functions in C++ including a Pig Latin Translator and Rot13 Cypher

PERILUpon execution this code displays a menu asking the user to choose how they wish to manipulate a string. There are five string manipulation options. The user also has the option to exit. The only issue I have with the menu is that you must enter the string each time you choose a function option. ...

Q: Should my class "data" dependency be a repository, adapter or another pattern?

ThiagoI have a class called CheckUserUltraSecretInformation that is kind of a Use Case in "clean architecture terms", this class has a dependency that is responsible for retrieving a couple of information from a cache "provider", such as Redis, this is a crucial business rule for this use case, in orde...

3:50 AM
4:32 AM
I recommend posting on CodeReview to learn the best practices for code, but I can tell you from now that it's generally not optimal to generate 4 variables for something you can use a list to do.. — Xiddoc 34 secs ago
4 hours later…
8:30 AM
Apparently Python 3 has absolutely no problem with for file in files:
In Python 2, that was just waiting for trouble.
8:41 AM
Q: Take User's Desired Graph Input in Kruskal Algorithm. My code only takes amount of nodes from user's graph and not the graphs' edge list

user241812I used python code from geeksforgeeks.org and modified it a bit: Kruskal's algorithm in Python class Graph: def __init__(self, vertex): self.V = vertex self.graph = [] def add_edge(self, u, v, w): self.graph.append([u, v, w]) # Search function def find(self, parent, i): if pa...

9:18 AM
This kind of question is better suited for codereviewOcaso Protal 15 secs ago
9:32 AM
Q: Is this object oriented code ok? (“Algorithms 4th Edition” by Robert Sedgewick and Kevin Wayne.)

tchappy haI am reading "Algorithms 4th Edition" by Robert Sedgewick and Kevin Wayne. I know little about object oriented programming. https://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/Graph.java.html The public Graph(Graph G) constructor in the Graph class uses the fact that a linked list is used ...

9:57 AM
Q: filter tweets about a specific country in python

jzrealthis is a python program that eliminates tweets from outside of a specified country that checks the contact details of each tweet received and whether it belongs at least to a rectangle in a bounding box it takes it and stores it in a text file if it does belongs to the coordinates , otherwise it...

10:23 AM
Q: C# How to speed up datatable updation for high volume of data

MistReading data from xml file and load data into datatable. i can not load data into List because datatable has some dynamic column whose name is not known. I have one List and one datatable. _AllCommentsData is List and dtData has datatable. More or less _AllCommentsData has 10,000 to 20,000 data a...

10:57 AM
Hi Remy, I have tried to implement a pool of TCPClient, I need a code review, you can help me? stackoverflow.com/questions/67416724/…ar099968 14 secs ago
11:13 AM
Q: Calling a nested method of a class Python

AndreaI want to test the output of the "isPalindrome" function with parameters 0 and 1. How can I call isPalindrome function directly? I tried with: e = "aaabaaaa" result = Solution2.longestPalindrome(e) pal = result.isPalindrome(0, 1) class Solution2: @classmethod def longestPalindrome(self, ...

11:39 AM
12:20 PM
Monking @Vogel612
@Peilonrayz (or other Pythonista's) you don't happen to have a good, dumbed down source on how decorators work, do you? You've tried explaining them to me here, but I'm still having trouble understanding how they work and how I can use them in my current project.
I'm sure they'd be of use and I'd like to give them a shot before uploading the 'ugly' version on CR.
@Mast Possibly this answer
It's basically a function in a wrapper you attach to another function, but the details of how to interpret that as a human and use that system seem to be a bit beyond me.
@Peilonrayz Thank you, I'll give that a thorough read through.
Q: Bash script that helps in opening documents when using terminal

yan_khI just created my first bash script that helps me to launch documents from terminal using a pdf viewer, which is very helpful and fast (at least I think so) for people who don't use any files manager (and have lots of documents of course); therefore they launch their pdf viewer and documents from...

12:37 PM
Closures, dynamics, wrappers, factories and partials.
This stuff ain't easy...
I'm sure once you get over the hurdle it'll all become simple :)
Practice makes perfect. I don't practice enough.
Stacked decorators, decorators inside wrappers and now you're talking about descriptors.
Dependency injection even? In a duck-typed language?
@Mast What design patterns are you familiar with?
12:52 PM
@pacmaninbw Sketch it out on a flow chart, write it down imperitively, migrate to functions or classes/methods where it makes sense (the latter especially when doing multiple operations on the same dataset).
I know UML, I know next-to-nothing about design patterns.
Imperative and OO, that's about it.
I'm good with if/then, try/catch and switch-cases.
Context wrappers are nice, they help with not forgetting to close your resources.
Also bloody annoying if you need to pass a pointer to a different function, but that's because I don't do it enough.
I know to keep the nesting low. Not to use a loop in a loop in a loop in a loop.
I've done some minor recursion...
Q: Determine if a point is inside or ouside of an irregular shape on a bitmap

NoobCoderSo this is my task: You are given an irregular shape on a bitmap. How do you determine if a point is inside or ousdie of the shape? We are allowed to assume that helper functions are already available for us and we don't need to write them as well. So I decided that I can use a function that re...

When I learned programming, we had QBASIC and HTML. Pascal and C.
My first program was at least 2 decades ago and I'm still not sure what I'm doing.
@Mast I asked because decorators and factories are design patterns. Design patterns are recognized ways of implementing code.
In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. Rather, it is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. Object-oriented design patterns typically show relationships and interactions between classes or objects...
@Mast Python is both dynamically and statically typed. You can easily change validate_message to act like a 'standard' DI if you change to static typing and look at the annotations not the name. And also write the rest of the DI framework ;)
Oh, I've done some RAII. Very important.
1:01 PM
In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class. The decorator pattern is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern. Decorator use can be more efficient than subclassing, because an object's behavior can be augmented without defining an entirely new object. == Overview == The decorator design pattern is one of the twenty-three...
Done some hardware messaging in RTOS, but I doubt that's MDP.
FYI, this type of questions belongs on Code Review. — Gert Arnold 6 secs ago
But I guess you could state I have very, very little experience with design patterns.
That's something people learn by practicing those specifically, correct? I've seen questions like that on CR. "Done X using Strategy pattern, did I do ok?"
Feels like doing Chess puzzles I guess.
Is it a method of writing (like a style) or more like a building block (a recipe)?
IMO A building block. You build off patterns to make your code work in a certain way. However some people use patterns as a style and make code... not so good
1:17 PM
@Mast When I first learned programming, I was doing FORTRAN 4 on punched cards. :-)
I'll see which part of my code makes the most sense to start replacing by a decorator, but knowing I probably should use a decorator turns my mind into "Oh, that could be a decorator, and that, that too" and before I know it the entire code is a Christmas tree.
@Donald.McLean Did you have design patterns back then?
honestly, decorators are probably best used for AOP-like cross-cutting concerns
"hey I wanna log the execution time of this method"
"hey I wanna memoize this tail-recursive function"
def to_megabytes(size):
    size : int

        Turn Bytes into rounded MegaBytes.

    return "{0} MB".format(round(size / 1000000.0, 2))

def get_directory_size(directory):
    directory : pathlib.WindowsPath

        Size of the contents of the directory in Bytes.

    print("Calculating size of {0}".format(directory))
    size = 0
    for path, _, files in os.walk(directory):
@Mast The original concept for design patterns was created in 1977, so no.
Think I can turn to_megabytes relatively easily into a decorator.
1:20 PM
Though they didn't really become popular until much later - mid to late 90's?
The rise of OO in the mainstream due to C++ and Java was part of that.
Except for RAII, I'd never heard of any design patterns until 2011 or so. Thought it had something to do with mobile programming, that was loaded with buzzwords.
it's not like there was no design patterns before the late 70s though
they were just not as "obvious" and canonicalized
@Mast You're not returning to_megabytes(size) so I wouldn't recommend converting to_megabytes to a decorator. Even if you were I'm not sure
I've written a mess, again.
the print statements inside the getter are a pretty surefire sign of that :D
1:24 PM
I'm passing directories a lot to functions too, can't be good too.
def free_space(directory):
    directory : pathlib.WindowsPath

        Free space available on partition the directory belongs to.

    return psutil.disk_usage(str(directory)).free
def validate_directory(directory):
    directory : pathlib.WindowsPath

    Raise FileNotFoundError if directory does not exist.

    if not directory.exists():
        print("Invalid directory: {0}".format(directory))
        raise FileNotFoundError
Jul 10 '16 at 18:23, by N3buchadnezzar
I feel like Frankenstein now. My code looks like a monster, but it compiles and is alive! Muhahaha
You're using Py3 right, you can remove the need for most of your docstrings by using sphinx (with a plugin) and annotations. def free_space(directory: pathlib.Path) -> int:.
That last part is using type hints, right?
Yeah the example is using type hints
Is Sphinx something I can throw into Spyder that gives me a button "Go bake me a docstring"?
What I understood about Sphinx is it requires an entire Sphinx project.
Yeah Sphinx builds an entire project. I'd assume you can use Sphinx in Spyder but... I do not know
1:32 PM
That's nice for a 3+ files project, but by that time I'd do everything with a proper configuration anyway. Including nox and all.
I still have a multi-file project in C somewhere from 2016. Might pull the plug on that and do it in Python for practice so it would eventually get done (or at least have a higher chance of getting done). That's for later.
@Peilonrayz I was thinking about using type hints, but my code casts a lot of types around just to keep it from blowing up.
When I first read about Python, I was fairly sure that I wasn't going to like it. Then when I was forced to actually work in it, I found that I had severely overestimated the amount of like involved.
I'm using pathlib all over the place, but casting it back to str half the time because the functions didn't appear compatible.
@Donald.McLean I thought I wouldn't like it a bit, but the vast amount of libraries pre-written takes so much work out of my hands I can't help but using it a lot.
Since Java also has that, it isn't an advantage. In fact, I haven't found a single thing about it that I would count as an advantage over anything except, perhaps JavaScript. Or APL.
@Mast You using Python 3.5 or something? Would make sense IIRC Python 3.6 changed many functions to support pathlib/str
@Peilonrayz 3.8.5 today
1:41 PM
@Mast If you have intelisense you can get better auto-complete, but Python is a mix of static/dynamic typing. So you can type whatever is most helpful and ignore the rest.
I actually have very little limitations for a change. Just myself.
Oh thought CPython devs fixed all the pathlib/str incompatibilities. I guess I guessed wrong ;)
@Donald.McLean the one advantage that python has over java is that python is preinstalled on most UNIX systems.
then again, so is perl, soo ....
1:54 PM
@Donald.McLean I swear most times we talk Python in the 2nd you say how much you hate Python.
Ask him what he thinks about Scala. He'll be done sometime tomorrow.
Singing high praise.
Post your working code on the Code Reviews Stack Exchange (you can link to this earlier post here) and I (and others) will give you some significant feedback on your coding. — JDługosz 49 secs ago
2:13 PM
Q: Implementing range from_to with step

Ivan Petrushenko#include <vector> std::vector<int> Range(int from, int to, int step = 1) { std::vector<int> range; if (step > 0) { for(int i = from; i < to; i += step) { range.push_back(i); } } else if (step < 0) { for(int i = from; i > to; i += step) { ...

don't use sizeof to get an array element count! You don't need NB_FORMS at all in that code. I'll illustrate on Code Reviews if you post there. — JDługosz 53 secs ago
@ar099968 "I need a code review" - codereview.stackexchange.comRemy Lebeau 27 secs ago
@Mast No language is perfect, and it's more a matter of personal taste. I find it more natural to think in Scala.
mhh ok, i have also opened a question on code review codereview.stackexchange.com/questions/260418/…ar099968 49 secs ago
2:28 PM
in VBA Rubberducking, May 1 '18 at 18:48, by Vogel612
every language has something it sucks at. badly
2:39 PM
Q: Implementing Tensor SVD in Matlab

auroraI am working on Face recognition algorithm, Tensor SVD. It is based on this article: https://www.researchgate.net/publication/267473105_Facial_Recognition_Using_Tensor-Tensor_Decompositions and Yale extended database which can be downloaded from here http://databookuw.com/. There are 38 people in...

Q: Delphi TIdTCPClient connection pool in a multithread environment

ar099968I want to use TIdTCPClient to connect to Redis from a web server application made with Delphi and TWebModule. Currently on WebModule creation I create a new TIdTCPClient and on web module destroy, I disconnect and free the resource. All works... But this way I create a new connection on every new...

Please explain how you know “I guess this is the wrong way.” Is your test case giving false positives or false negatives or crashing or so forth? Did this test's source code fail a code review? — Andreas ZUERCHER 55 secs ago
I’m voting to close this question because it should be on Code Review instead (assuming that the code is working as expected, which isn't clear from the question). Please see: Why is "Is this correct?" an off topic question, and what should I ask instead?EJoshuaS - Reinstate Monica 1 min ago
@EJoshuaS-ReinstateMonica It was already posted and closed on Code Review, so suggesting to post it there is entirely unhelpful. Please don't do that again. — Mast 5 secs ago
3:08 PM
@Duga heh - good call @Mast
Code looked awfully familiar.
And then they wonder why SO is considered elitist.
@Duga I read the question (on CR) and nothing jumped out at me... Clearly not hard enough 🤦‍♀️ Yeah 100% is AoC
User with 10k rep, still no wiser.
oh 10k on SO ... initially I thought you meant on CR
apparently its been 4.5 years since 200 once corrected that user about CR posting instead of SO
Sep 22 '16 at 19:04, by Duga
@EJoshuaS The question asks to "get some help debugging". If the code is not working correctly as intended, then it would be off-topic for Code Review. As it stands, the question is also inappropriate for Stack Overflow, since there is no specific programming problem to be solved in this question. — 200_success 19 secs ago
actually argued a post couldn't be migrated to CR at one point
May 29 '20 at 22:49, by Duga
@EjoshuaS-ReinstateMonica While this may be on-topic on CR in the future, please don't use the existence of the Code Review site as a reason to close a question. Evaluate the request and use a reason like needs focus, primarily opinion-based, etc. Then you can mention to the OP that it can be posted on Code Review if it is on-topic. Please see Does being on-topic at another Stack Exchange site automatically make a question off-topic for Stack Overflow?Sᴀᴍ Onᴇᴌᴀ 45 secs ago
Doing it all the time.
3:30 PM
For feedback on existing code, consider posting at codereview.stackexchange.com instead. — François Andrieux 42 secs ago
Q: Java 8 ThreadLocal Date With Lambda

ALII'm using Java 8 lambdas to initialize thread local date variable. I am accessing these methods in multithreaded program. Is it going to create garbage references as I am not using .remove() method on thread local variable. ? As mentioned here: https://stackoverflow.com/questions/18589986/date-co...

I'd appreciate some direct feedback on the code. if you want to have feedback to the code, you have to include that with your question. Links to externals sites could become invalid anytime, which then might make the question, and answers userless. Besides that codereview.stackexchange.com might probably be a better place, or probably focus on one part of the problem, like how you could allow the casting, with a reduced part of the code. — t.niese 58 secs ago
3:55 PM
Thank you for pointing out codereview.stackexchange.com - I did not know that. Really appreciate the tip. — Silberling 36 secs ago
Where to call remove() in standalone multithreaded spring boot application. codereview.stackexchange.com/questions/260419/…ALI 38 secs ago
4:48 PM
Q: Find all combinations of numbers of a set that add up to a given target - avoid for loops

LukI am thinking about the following problem: Consider a 3-numbers lock, i.e. a lock which has three little number wheels that opens whenever the sum of these three numbers equals 75. I know, this doesn't make sense for a lock, but just imagine this. The number wheels have numbers 3, 15, 17, 35, 40,...

Q: RSA encryption/decryption using python

conoruwusI'm having slight trouble with a problem with python using Jupyter notebook. So far: ALPHABET64 = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789." R = RSA(ALPHABET64) n = "7231645985673347207280720222548553948759779729581" e = "3" d = "482109732378221562569254925133185532931460...

Q: awaitable event handler delegate for ASP.NET

joelmdevI have an ASP.NET MVC/WebAPI application where the domain logic depends on events in certain circumstances to decouple concerns. It's becoming increasingly difficult to avoid using async methods in the event handlers, but being that this is a web application I want to avoid using async void as th...

5:37 PM
Hi, @Mast. Is the OpenGL tag not enough? There's no language involved. — Rodia 14 mins ago
@Rodia OpenGL is cross-language and cross-platform. You've mentioned the platform (Android), but I still have to guess at the language. It looks like C++, but there are so many languages out there nowadays I can't be sure anymore. — Mast ♦ 18 secs ago
Q: How to combine two entry points?

AuricaThere is a two ways to activate editing mode: add, edit. I made two separated functions. public editObject(semantic: LayerItemGeneric, mode: 'add' | 'edit' = 'add'): void { this.mode = mode; this.editorLayers.editObject(semantic); this.editorLayers.createForm(); this.toolsService....

1 hour later…
6:45 PM
@JDługosz I uploaded it there, thanks : codereview.stackexchange.com/questions/260428/…sapristi12 31 secs ago
You're asking for open-ended refactoring of working code; this is suited for CodeReview, not StackOverflow. You also need to define your problem; asking for wholesale "reduce this code" shows more than you need to practice programming, or ask about one particular code block. — Prune 47 secs ago
Q: C++ method to call a specific function without if/elseif/elseif/elseif/else

sapristi12Here is the code's review of my problem that I solved on the post below the code. An user asked me to post it here to talk about my code) #include <iostream> #define NB_FORMS 3 /**/ class Form { public: Form() { } virtual ~Form() { } }; class Square : public Form { public: Squa...

Ok I'll use CodeReview sorry. @Barmar I tried putting it into a function but I couldn't stop it so It would never finish — Tassanix 32 secs ago
7:27 PM
Do I understand correctly that your question is actually a catalogue of solutions that you keep updated as comments come in? Any way, for working code, questions about efficiency are more suitable to be asked at Code Reviewtrincot 21 secs ago
@trincot thank you did not know about Code Review before, btw just waiting at least two options to accept the answer, thank you! — loretoparisi 39 secs ago
8:14 PM
Q: Repeat a function inside that function a certain time

TassanixIs there any way to reduce this code? It repeats itself, but I cannot find any way to reduce it because it is only repeating inside one elif. Sorry I'm a beginner my code is quite bad It repeats here: onze(joueurs) print("joueur", a + 1, "a", joueurs[a]) time.slee...

8:36 PM
If you want to ask for improvements of already working code, you should better ask that at SE Code Review. — πάντα ῥεῖ 47 secs ago
Q: Generate mask for non zero (or inverse) nibbles in integer

ZacariazApologies for the cryptic title, but the problem really is rather simple. I have a 64 bit integer which I enterpret as 16 4 tib nibbles, or a nibble array if you wish, and I needed generate a mask covering the nibbles which are zero, or the inverse. I have already come up with a solution, but it ...

9:30 PM
Questions asking for a review of working code should be asked on Code Review instead of Stack Overflow. This site is for specific programming questions with objective answers rather than general, stylistic reviews of full working code. — TylerH 16 secs ago
Q: Content aggregator using bs4 and requests

userStandard code review, tell me what's good, what's bad, and how to improve. Critical suggestions welcomed. This is a content aggregator using bs4 and requests. I did not use any tutorials or help. import requests from bs4 import BeautifulSoup as bs topic = input('Enter the topic: ').lower() print...

9:41 PM
hehe I noticed this HNQ
Q: Why is there no night shift in Monsters, Inc.?

TheLethalCarrotThe main arc in Monsters, Inc. is that there is a scream shortage/energy crisis. However, there doesn't appear to be any night shift. All the scenes that happen later on at night seem to be "after everyone has gone home", the hallways are dark and there's no one around, really. At the start of th...

One of the answers has an interesting statement:
> Pacific islanders don't get any monsters, scarers can take a break, and even get a nap or lunch break during the Atlantic.
10:08 PM
This question seems more inline with Code Review. Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Stackoverflow is more on-topic for questions about problems and algorithms. — lorem ipsum 24 secs ago
@loremipsum Please take a look at the CR Help center page What types of questions should I avoid asking? "It's OK to ask "Does this code follow common best practices?", but not "What is the best practice regarding X?"". If the OP presented fully working code with enough context then that would be on-topic. — Sᴀᴍ Onᴇᴌᴀ 20 secs ago
1 hour later…
11:38 PM
I don't think there is a "Code Review" category on SO but if you create a reproducible example, I'm sure someone will help you out. — Tanner Dolby just now
@TannerDolby Code Review is only for code that works properly. Please see What topics can I ask about here?Sᴀᴍ Onᴇᴌᴀ 18 secs ago
@SᴀᴍOnᴇᴌᴀ That's why I recommended the OP should create a reproducible example, so it would be fine for StackOverflow, and simply the Code Review exists on StackExchange. — Tanner Dolby 6 secs ago

« first day (2924 days earlier)      last day (50 days later) »