« first day (2806 days earlier)      last day (1213 days later) » 

12:00 AM
RELOAD! There are 7255 unanswered questions (89.6387% answered)
 
12:15 AM
1
Q: Smart tooltip using vanilla JS, any better way?

Rinkesh GolwalaSmart tooltip means the tooltip should adjust according to the available space. If there is no space below an element, then it should be shown on top of the element and it should decide automatically. I have created a smart tooltip using javascript and it is working perfectly fine, but the code l...

 
 
3 hours later…
2:51 AM
0
Q: Basic COBOL Calculator

1ctinusSmall Calculator I made for myself while trying to learn COBOL for fun. Compiler used is GNUCOBOL. Just asks for input and will either do multiplication, subtraction, or addition. Completes run after input is asked. MATH IDENTIFICATION DIVISION. PROGRAM-ID. MATH. DATA DIVISI...

0
Q: Faster map function

LinnyFor my job I was tasked with writing a faster version of Arduino's map. The requirements were only use addition and subtraction, since these are cheap operations on our board. For reference, here is Arduino's implementation: long map(long x, long in_min, long in_max, long out_min, long out_max) {...

 
 
2 hours later…
4:42 AM
Monking
 
5:27 AM
0
Q: 16 line python string obfuscator - reduce/compress output size/and increase speed

FreakAnonHere you have it: Possibly the smallest feasible python obfuscator without any real "cheats" when it comes to making something one line, no semicolons etc. all with variable concatenation. some is redundant as hell, but it works, and its surprisingly fast for how inefficient it is. import sys,zli...

 
(1) For something so simple, yes? No, doesn't appear anything is missing. (2) What state? (3) Depends, both are valid patterns for different use cases. Please try to narrow the focus of your question to a more specific issue that won't lead to opinionated answers. If the code works and you are simply looking for a code review then may I suggest codereview.stackexchange.com? — Drew Reese 36 secs ago
 
6:52 AM
Seems this question would be a better fit for CodeReviewtrincot 1 min ago
 
 
1 hour later…
8:03 AM
0
Q: Booking ticket simulation

gurka583newI am sort of new to python and would like feedback on this program. It is a booking system for trains, where passengers (the user) can change what train they want to take and also what wagon they'd like to sit in and they can also book or print their tickets. So I would like feedback on the gener...

0
Q: How to remove duplicates from array?

PoojaI am trying to remove duplicates but stuck with this. Main Array : [ [ "Recruitment", "Assessment" ], [ "Recruitment", "Checklist" ], [ "Recruitment", "Sop" ], [ "Onboarding", "Assessment" ] ] Wants something like this : [ { "Rec...

 
8:29 AM
0
Q: Is there a shorter/better way to do this simple problem in Swift?

BoredToDeathI am learning swift and then I came across this problem. Converting each start letter to capitalized form if its lowercased. func upperCaseFirstCharacter(str:String){ let myArr = str.components(separatedBy: " ") var finalStr :String="" for word in myArr { let myStr = word.repl...

 
 
1 hour later…
9:33 AM
Stack Overflow is for help with non-working code. If your code works and you want comments on it post it at codereview.stackexchange.com. That's their bread and butter. — John Kugelman 1 min ago
@JohnKugelman sorry about that! Didn't know about Code Review, thank you! I'll go ahead and delete this post. — user3175585 46 secs ago
 
 
1 hour later…
10:38 AM
0
Q: Creates a series of folders from a given starting date

user3175585I made this python script to create dated folders within a directory. This is my first practical automation project and I don't want to cement any bad habits so I was wondering if there is anything I can improve in the code I have written here. Any feedback will be appreciated! The main challenge...

 
11:14 AM
Monking
 
11:30 AM
-1
Q: Need help to reduce complexity of my code

Us3rI have this code, outer loop does 1000 iterations, it takes a minute to run and profiling it I discovered that the most of cpu is used on the found assignment. Can you suggest me some implementations to run it faster? for (int j = 0; j < numero_iterazioni; j++) { ...

 
Your code won't even compile. Anyway, this is not a code review site. Test your code and ask about real problems you encounter. — Martin Prikryl 22 secs ago
 
@CaptainObvious I bet talking through this code in Italian sounds more majestic than in English
more passionate
 
@CaptainObvious Seems like the user translated the code from Matlab into C#, but doesn't really understand the code.
 
11:51 AM
Maybe this question would be more suited to codereview.stackexchange.com ? — Joffrey 8 secs ago
 
 
1 hour later…
1:15 PM
Hmpf, creating a Microsoft Teams bot seems like rocket science
 
@Aziuth hi and thanks for advise, as you recommended I post a working cod in CodeReview, and ask if its the best way or not. here is a link to it Best way to access Qt ui from other classfile-tracer 42 secs ago
 
1:40 PM
0
Q: Best way to access Qt ui from other class

file-tracerI'm trying to access UI from a class outside of my main windows class, I've tried some ways like declare my functions in the main window header, and then use the main window in those function in CPP files to access the UI (But its clearly not a good way) so I think it's better to use signal and s...

0
Q: Suggestion for refactoring of an API client/wrapper class

slooffmasterFirst question here and I understand it's a very open question. I adopted a PHP-based API client several years ago that is used to interact with the API of the UniFi network management platform provided by Ubiquiti. This client leverages cURL, has grown quite a bit over time through contributions...

0
Q: How to organize and formating my code while maintaining all OOP principles

user235835I want to create a snake game with pygame in python That can fit for multiple players. at the start, i created classes for snake, button and snake-game... Now i want to create an graficall GUI with pygame that help the user to define the game properties, like a settings screen for define things l...

 
2:04 PM
@skiwi Rocket science is more about the application rather than the technology. :-)
 
If I could create a bot to attend all of my meetings for me, that would be a real time saver.
 
2:24 PM
I think a good bot would probably provide a more intelligent contribution than some meeting attendees I've seen.
 
Say... have we been in a meeting together recently? :)
 
@Edward Wait what would you be doing then? ;)
 
Very, very little.
 
Probably actual work. That's what I do when I blow off meetings.
Not that I have that many meetings. I'm very fortunate that way.
 
I assume this is homework so I'm not going to write it for you. If you have specific questions about how to do something specific, ask that, but Stack Overflow is not a tutoring service, and comments aren't the right place for a back-and-forth tutoring session. An example of the kind of data structure you might use to track the state of the snake is Beginner's snake game using PyGame (in Python), but see the answers for ways it could be simpler. — Peter Cordes 1 min ago
 
2:30 PM
@Donald.McLean Shhh! Don't let them take that away from me!
 
What do you classify as actual work?
 
Writing code, writing reports, reading technical papers.
Actually doing research instead of hearing about the latest announcements that SHOULD have been sent via email.
 
Ryan Donovan on January 08, 2021
Welcome to ISSUE #55 of the Overflow! This newsletter is by developers, for developers, written and curated by the Stack Overflow team and Cassidy Williams at Netlify. It’s a whole new year, and we’re kicking it off with fresh and tasty links: a teardown of the techniques behind the SolarWinds hack, preparing for school-mandated spyware, and how the…
 
@Edward Hmm, sounds interesting
 
It is to me.
 
3:04 PM
@rcs (facepalm), ok thanks for the code review. I made that change and fixed my typo (in my actual code and in my question), but I'm still getting the same response. — Ryan Tensmeyer 1 min ago
 
3:24 PM
0
Q: Basic python GUI Calculator using tkinter

RagovCould anyone review my code for a calculator using tkinter? I'm attempting to use two classes, one with the functions of the calculator and a second which creates the GUI. It seems to work fine (although I'd like to add keyboard functionality), so I'd like to ask if there is anything that I could...

 
3:34 PM
@skiwi Writing code, reviewing other people's code, installing apps (the ones that I do code for), ensuring that systems are configured correctly for the apps, trouble shooting.
 
4:05 PM
possible answer invalidation by Chocolate on question by Ragov: codereview.stackexchange.com/posts/254447/revisions
 
Greetings! Happy Friday!
 
5:03 PM
@SᴀᴍOnᴇᴌᴀ I know it's quite a while later - never had the need to use this until today. It's pretty neat. Thanks!
 
5:33 PM
@Peilonrayz No problem
I've been meaning to review your todo list VueJS stuff- I started something a while back but haven't gotten around to doing it (no pun intended)
 
5:54 PM
A Stack Overflow question should be about a specific problem. We don't do general code review here; if you can't identify something specific that's wrong with enough clarity to build a minimal reproducible example demonstrating that issue, a question isn't ready to be asked. — Charles Duffy 51 secs ago
Hi SamNoob! You can also out codereview.stackexchange.com or consider posting over at reddit on r/learnpython if you're just looking for general feedback. — chris 42 secs ago
 
@Lurch thats okay - code fence and Thanks removed from end of post
 
@chris when suggesting users post on CR it would be great if there was also a suggestion like "Please read the relevant help center pages like 'What topics can I ask about here?' and 'How do I ask a good question?". In the current form the code above would likely be closed as off-topic because it is missing context. — Sᴀᴍ Onᴇᴌᴀ 14 secs ago
 
6:12 PM
You never populate result in that fiddle. But this comment section is not intended to do code review. So please, if you have a new question, post it as one after doing enough testing and getting stuck on an issue. If however you have working code and need advise on efficiency and code style, then ask on CodeReview, as such questions are off-topic here. — trincot 14 secs ago
 
@Peilonrayz What did you Vue together?
Next iteration of the to-do?
 
I’m voting to close this question because it would better fit into codereview.stackexchange.comrkosegi 52 secs ago
 
6:43 PM
@rkosegi 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 more focus (as I have done here), primarily opinion-based, etc. Please see Does being on-topic at another Stack Exchange site automatically make a question off-topic for Stack Overflow?. In the current form the post would be off-topic on CR because the code is not embedded directly. — Sᴀᴍ Onᴇᴌᴀ 51 secs ago
coding is some times as personal as one's fingerprints. I personally do not like Do/While loops, but like to find the end and do a For loop instead. The best thing is to get the code working by coming here for specific help overcoming specific issues, then when it is working take the whole code to code review with a full explanation of what you have and what you are trying to accomplish and they can help make it better. — Scott Craner 45 secs ago
 
0
Q: Programming a Coinflip on C

Henri KI have to program the following Simulation in C! My exercise is: What’s the minimum number of times you have to flip a coin before you can have three consecutive flips that result in the same outcome (either all three are heads or all three are tails)? What’s the maximum number of flips that migh...

0
Q: Generates barcodes using iterator objects and an iterable objects

Matthew Doughtyfirst allow me to explain the what the purpose of this program is: a "barcode" as I'm calling it consists of three parts: plant_id=['ATX','HOU','CHS'] Serial Number: a string of 9-digits mod 10 digit: A digit (as a chr()) between 0-9 that is assigned randomly to the end of a barcode. So a full ...

 
7:08 PM
@SᴀᴍOnᴇᴌᴀ No problem! I still have answers I want to write for Mathias, but I don't remember what any more...
@Mast As my website has gotten bigger I've needed to make my component framework, called Pue - I'm sure you can guess why ;) - stand-alone. I now have a Requests/sessions like interface/pattern that alerts the user if there are any server errors. I.E. if there is a 500 internal server error it says so in the top left of the screen. So I've connected Pue to Pue ;) But I only call that code from other modules.
IDK if there is a proper name for the Requests/session interface/pattern. I define it as; when you apply things like caching / transformations in a sort of 'pipeline' to build a standardized bespoke output. If done correctly the code is really simple, like this answer codereview.stackexchange.com/a/242749
 
7:38 PM
If the code works and you're looking for advice on improving it, Code Review is the appropriate place. But see codereview.meta.stackexchange.com/questions/5777/… first. — Barmar 22 secs ago
 
8:08 PM
Welcome to Stack Overflow! If you want help improving working code, you should post this on CodeReview.SE. If you do decide to do so, please delete the question here. — NathanOliver 24 secs ago
Thanks @Barmar, I asked my question in Code Review, here. I was not aware of that site. — user171780 41 secs ago
 
8:36 PM
0
Q: Optimizing code that reads a JSON file and a CSV file and compares them and outputs to a file

OmarEI have written this code that reads a JSON and CSV files compares them and outputs to a text file This output file will contains the association that my program has created in the following format <CSV_SENSOR_ID>:<JSON_SENSOR_ID>. If a flying object was only picked up by one of the sensors, the o...

0
Q: Data set with many variables in Python, many indented dictionaries?

user171780I am working with a data set that has many variables. Currently I am storing the data in many indented dictionaries in the following way: import numpy as np X_POSITIONS = [0,1.5,1] Y_POSITIONS = [0,1,2] CHANNELS = ['left pad', 'right pad', 'top pad', 'bottom pad'] data = {} for x in X_POSITIONS...

 
Sounds more like you're asking for a code review in terms of optimization, rather than how to complete the task at hand. One thing to keep in mind is that if the task can be solved purely through CSS, then that is preferred as JavaScript is heavier to run. — Martin 37 secs ago
 
9:12 PM
@Edward Don't take this the wrong way, but did you ever get around to writing that PR describing how to put Duga into a container?
I'd be terribly interested in reading that.
 
I didn't do a PR, but made a tiny project for it that pulls the image from Duga:
Let me know if you have any questions and I'd be happy to answer them if I know the answer.
 
Yea, you lost me at multi-stage builds.
The build image doesn't end up in the container, it's just a temporary construct as intermediary, right?
 
Exactly right.
It's like preparing an apple pie in the kitchen with flour, eggs, butter and fruit and utensils and an oven.
Then all you do is bring the pie out to the dining room and leave the rest behind.
 
Yet the Docker file still does everything, including the build, it seems.
After all, it pulls straight from the original git.
RUN ./gradlew build

FROM tomcat:8-jdk8-openjdk-slim-buster
WORKDIR /usr/local/tomcat/webapps
COPY --from=builder /tmp/Duga/build/libs/*.war .
 
Yes, that's right. Building is all the way down to the line that starts "RUN ./gradelew build"
 
9:22 PM
This basically builds and copies.
 
Then the "pie" is cooked (the .war file) and all we do is copy it into a fresh new image.
 
So while the Docker still does all the preparation, it discards part of the results to only copy the resulting war file, the pie.
So a container can do a truckload of things while only caring about the relevant parts of it?
 
Right, and by default it's only the last image that is saved.
So when you write podman build . -t beroset/duga it's that last image that is locally saved under the name beroset/duga.
All the rest is still present on your machine, but unnamed.
I usually purge all of that using podman system prune once I have what I want.
 
Is it possible to make that part of the docker/podman file?
The pruning?
Or would the unnamed rest simply be overwritten on each execution anyway?
 
It might be possible. I don't know.
 
9:26 PM
Why's the timezone relevant?
You also appear to be declaring 2 different environments.
Or is that simply adding 2 different configuration options to the same environment?
 
It's the latter.
The reason for it is that most build systems use timestamps to figure out what to rebuild.
 
Ah, so you needed to set a reference. Any reference, really.
 
Right.
By default I believe it's UTC, but then if you pull things in from the local machine (which is something other than UTC) the build system tends to get confused.
So it's probably not strictly necessary for this particular image, but it's good practice.
 
So, put it at local time.
 
Right. It's also possible to set the timezone for all containers or on the command line (for some versions of podman and docker).
But this method always works.
 
9:35 PM
That link specifies a problem with pulled docker files, but you're building your own, right?
 
Right, but note that the timezone is only set for the builder.
When we run, it's convenient (i.e. to have container timestamps mirror the local time)
but it's not required.
 
Ok.
 
There's no build system to mess up.
 
So it's basically for logging.
 
For logging but mostly for the build system.
Note that on line 8 we copy a local file duga.groovy into the container.
If that's got a timestamp that's 5 hours ahead of the rest of the files in the image just pulled,
 
9:39 PM
Yea, I can see the problem there.
 
the build system will get confused.
 
It will take the older file instead of the newly build one, probably.
Because it sees the old one as newer.
 
It depends on the particular build system. I don't really know exactly how gradle does it.
 
The alternative would be setting the default from UTC to local, probably.
But it's nice to make it explicit.
Except now it seems like it won't properly work on devices that are in a different timezone, which couldn't possibly be the desired effect.
 
Exactly right, but it works for anybody in my timezone. :)
There are other ways to accomplish this, but all of them require either command line options or global configurations which are outside my control.
I could have written it to demand to be fed a timezone instead.
Arguably, that's a better way to accomplish this.
 
9:43 PM
Like forcing to require userinput?
I didn't know that was possible.
 
Yes, or requiring that $TZ exists on the host.
 
As an environment variable?
 
57
Q: How to make a build arg mandatory during Docker build?

konradstrackIs there any way to make a build argument mandatory during docker build? The expected behaviour would be for the build to fail if the argument is missing. For example, for the following Dockerfile: FROM ubuntu ARG MY_VARIABLE ENV MY_VARIABLE $MY_VARIABLE RUN ... I would like the build to fa...

 
Oh, that makes sense really.
 
Yes, I was just lazy there, because I'd already spent two days figuring out the recipe!
 
9:48 PM
What's with the final CMD ["catalina.sh", "run"]?
Catalina is macOS, right?
 
That's just how you run Tomcat.
 
Oooooh
So this is basically where you fire up Tomcat to actually serve the war you just fed it.
 
Yes, or technically, fire up Tomcat for it to discover the war file waiting for it to run.
 
Naturally, considering you copied it into the correct folder earlier.
 
Right, that's why that particular folder and that particular version of Tomcat
 
9:51 PM
You don't have to initialize/download Tomcat in the container?
Like you did with maven?
Or gradle.
 
No, because I'm pulling a Debian image that somebody else already build with Tomcat already installed.
You only have to install the parts that aren't already there.
In this case, that's the empty set.
 
Will it throw a stacktrace if I mess-up one of the steps?
 
Better - it stops building at that point.
However, it keeps all of the results of previous steps, so it's faster the second try.
 
That's nice, helps with figuring out what went wrong too.
 
It works by doing overlays. Each "layer" adds or subtracts from the previous, so what you end up with is a list of deltas.
And yes, the diagnostics are usually excellent
 
9:56 PM
I'm not sure where the configuration is located.
 
Which configuration do you mean?
 
Well, the Duga project requires logging in with some user to the SE network.
I'm assuming the credentials are saved somewhere.
The room which to post in could be hardcoded, but the credentials hopefully aren't.
 
Ah, yes. All of that is the duga.groovy file that you have to supply.
I made one with my credentials. That was one of the hardest things to figure out.
Duga's documentation is not thorough on that point.
 
That's a modified version of src/main/resources/duga_example.groovy?
 
Yes, that's right. On the github site I noted some of the missing explanations under the heading "A word on Duga customization."
 
10:02 PM
botName, rootUrl, email, password, stackAPI, githubAPI, adminDefaultPass, commandPrefix, dataSource
@Edward That's not in the Readme, where's that?
 
It's at the bottom of the README.md file here:
 
Ah, it's in your Readme.
 
Yes, because it's missing in the other one. :)
 
Right.
So now all I need is a sock and the description you just provided and I should be able to run my own clone.
Which would be the perfect practice for a) when we run into trouble again and b) turning other projects into containers.
 
Yes indeed!
On that latter bit, here's how I usually write a Dockerfile
I start with a plain image and then perform steps manually and interactively within the container.
 
10:06 PM
I just move that to spot #1 on my to-do list, which makes the probability of me actually finishing it this weekend roughly 50%.
 
At each step, I move that instruction to the proposed Dockerfile
If I mess up, I revert to an earlier image (or run the partial Dockerfile) and start again.
It's usually not too hard -- just tedious.
 
Like all automation.
 
Exactly.
 
Try manually step-by-step. Automate step-by-step.
 
And then sit back and let the robots do all the hard work.
 
10:08 PM
How did you figure out what to use in your FROM commands?
 
I have a question about this CV queue item. There is 1 CV for missing context- is that because there are header files referenced that are not included?
 
@SᴀᴍOnᴇᴌᴀ Not mine, but probably because the code has been turned into example code too far.
 
@Mast Educated guess. Sometimes I try it a bunch of different ways and see how they work:
 
@SᴀᴍOnᴇᴌᴀ I agree with the CV, but there should've been a comment.
The header files missing just makes it worse.
 
@Mast I agree it's probably cause it looks very much like example code
 
10:11 PM
I agree too.
 
@Peilonrayz Left a comment @SᴀᴍOnᴇᴌᴀ
@Edward This definitely warrants a closer look. I'll see how far I get tomorrow.
That question is at 3 CV now by the way.
Thanks for the detailed explanation @Edward
It's much appreciated.
@SimonForsberg might want to take a look too, scroll up.
Doing this all in a container seems like the sensible thing to do and the way-to-go going forward.
 
@Mast FWIW I don't know any C++ so I don't want to VTC outside my domain of knowledge
 
@Mast look at what?
 
@Peilonrayz It's definitely anonymized too far, turning it into an example.
@SimonForsberg How Edward put Duga into a container.
 
@Mast bravo
 
10:16 PM
It makes a lot of sense how he explained it.
 
@Mast I've heard about it already I think
 
If even I can understand it, it must be simple.
 
Where to start reading?
 
Eh, lemme look.
@SimonForsberg Here
It's mostly me verifying how to container with Edward explaining how he went about things.
Considering you had a branch dedicated to putting Duga in a docker that's way behind, I thought you could be interested.
Save you the trouble of reinventing the wheel and all that.
It was more of an obligatory ping to keep you in the loop than pushing you into doing any work really.
I'm glad you build Duga and I'm glad Edward managed to take over on such short notice.
Honestly, for testing purposes, this should just as well work with my main account... It doesn't really need a sock, that's just proper decorum.
 
10:33 PM
33 mins ago, by Edward
Duga's documentation is not thorough on that point.
s/that/any/
@Mast I'm also glad to see parts of @Duga be back that quickly
although I still miss the webhook functionality
but it's probably time for it to become two separate projects
A big ugly part about @Duga is that it runs in Tomcat.
If I would rewrite it today, I would use Kotlin and not Groovy.
 
that should be comparatively easy to fix, tbh
 
And I would use Javalin and not Grails
@Vogel612 By fixing my motivation?
 
what is wrong with tomcat, though?
 
It's not standalone.
Embedded Tomcat is just fine (like Spring Boot, or is that using Jetty? I can never remember)
but the actual real Tomcat... that's been a lot of pain
 
yea, I can understand that.
 
10:39 PM
Javalin is super easy to use and works very well with Kotlin, so that's what I am mainly using these days.
And Spring and Spring Boot is a ¤"()/¤)/("¤/)=(¤" ton of black magic
 
~shudders, yea it is
 
With Javalin, the solution to problems is code, not bloody annotations
 
lol :D
 
0
Q: Does this feedforward neural network work like i think it works?

Off_grid_coderI seem to have taught myself the basics of c++ living off grig in the woods of Alaska. Most of this has been done on my android phone using cpp droid. This is the first time anyone has seen any of my code and I am curious what you think of it. There no error checking and the style may look a litt...

0
Q: Clean code for dealing with combinations of booleans

Sai Sreekanth majetiI am looking for some advice on how to refactor code that deals with combinations of multiple boolean variables, rather than having complex and endless conditional statements. For example, if we have a Customer with 3 boolean properties say, isBlocked, isInternational, isPremium . How can I write...

 
Hi and welcome to Code Review. In order to help you out, we need to see concrete working code that you have. Without embedded code in the question (your real code), this will be put on hold — Simon Forsberg 7 secs ago
 
This isn't a particularly bad goto, but it's easy to replace. I find you spend more time defending all but the best use of goto in code reviews than you save using the goto. Plus the co-op maintaining your code a few years down the road will probably <expletive deleted> it up. — user4581301 27 secs ago
 
11:33 PM
@Vogel612 Which part were you thinking of btw?
 
@SimonForsberg migrating away from tomcat
basically replacing the application server...
 

« first day (2806 days earlier)      last day (1213 days later) »