Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

General Q&A about programming, scripting, software design & architecture, process, tools, testing, and more.

Filters (None)
80%
+6 −0
When does it not work to dereference the pointer for sizeof during malloc?

Background This is kind of a subquestion to How to properly use malloc? When allocating, there are basically two common ways of using the sizeof operator: int *p; p = malloc(n * sizeof *p); /...

1 answer  ·  posted 2y ago by klutt‭  ·  edited 2y ago by hkotsubo‭

66%
+2 −0
Why is my last input box not centering (class: powerwall-battery-input)?

I found a form I wanted to duplicate on a roof construction website. All my input boxes are centered except the last one that's a bit off and I cannot figure out why. Here is my code: HTML <...

1 answer  ·  posted 2y ago by WannaBeAWebDev‭  ·  last activity 2y ago by meriton‭

80%
+6 −0
When using the compare function in Array.prototype.sort, how to avoid an element to be processed more than once?

When using the Array.prototype.sort method, we can pass a compare function as argument. Then, this function can be used to process array's elements, so the comparison is made using some custom crit...

2 answers  ·  posted 2y ago by hkotsubo‭  ·  last activity 10mo ago by matthewsnyder‭

72%
+6 −1
Best practices in setting up a development & production environments

I am developing a web app that is tied to a database. My codebase is stored on a private GitLab instance. I would like to set up a workflow that would look something like this: I have a developm...

1 answer  ·  posted 2y ago by Mu3‭  ·  last activity 1y ago by Mithical‭

85%
+10 −0
How to properly use malloc?

I have seen this construct quite a lot: int *p = (int*) malloc(n * sizeof(int)); Is this how it should be? What is the proper way to use malloc? I have also seen this: int *p = malloc(n * size...

3 answers  ·  posted 2y ago by klutt‭  ·  last activity 8mo ago by Lundin‭

80%
+6 −0
Are static pointers implicitly initialized to NULL?

Consider this code: #include <stdio.h> int main(void) { static void *ptr; if(ptr == NULL) puts("It's NULL!"); } I wonder if this is guaranteed to print "It's NULL!" I know ...

1 answer  ·  posted 2y ago by klutt‭  ·  last activity 2y ago by Lundin‭

60%
+1 −0
Preloading some data at application startup as fast as possible

I am caching some very static information (changes once per day) in my ASP.NET Core application. This is normally done when needed ("lazy"). One such cache item is a 50K list of items that are tak...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

77%
+5 −0
How to prevent token from being refreshed

I have an Angular application. The frontend has a mechanism that periodically fetches some information like this: ngOnInit(): void { setInterval( () => { this.http.get(... ).sub...

1 answer  ·  posted 2y ago by klutt‭  ·  last activity 2y ago by meriton‭

66%
+2 −0
What are the drawbacks of using data snapshot testing?

Our team is finally focusing on writing more automatic testing and one of my ex-colleagues recommended to try out the Verify library. The tool does the following: runs the test and compares the...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Derek Elkins‭

50%
+2 −2
Alternative to Google Adsense [closed]

I'm starting a small site with some online tools. Tried to include Google Adsense but I initially got rejected because the site was still on construction. Yet I've seen in the forums that they are...

0 answers  ·  posted 2y ago by nelson777‭  ·  closed 2y ago by Alexei‭

71%
+3 −0
Detecting if a user has stopped interacting with a web view for a certain time

I am interested in finding out all the aspects I need to cover in order to correctly assess if a user has stopped interacting with a web page. So far, I found the following: Idle Detection API -...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by meriton‭

66%
+2 −0
How to write database friendly code when using an ORM?

There are a lot of articles and presentations that show little love for ORMs. This is mainly because some queries are so complex and heavy on the database that they lead to significant issues in p...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

71%
+3 −0
Why static code analyzers such as SonarQube indicate a high code complexity for switch statements?

During a presentation of a pipeline configuration, a colleague showed a SonarQube integration and one of its reports. A warning was caused by overrunning the max value for the code complexity thres...

2 answers  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Derek Elkins‭

50%
+0 −0
Migrating HTML strings to a more secure alternative

Our team will have to migrate an old application to use a new tech stack. One of the features involves the usage of HTML editors which serialized the content as HTML and I am able to see valid HTML...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by r~~‭

77%
+5 −0
bootstrap : how to align text with a button inside a grid

I have this bootstrap code (grid) <div class="container p-3 center"> <div class="row"> <div class="bg-light border-bottom border-secondary border-top col-6 te...

0 answers  ·  posted 2y ago by meneguzzo68‭  ·  edited 2y ago by Alexei‭

66%
+2 −0
Rationale of using database-level transactions inside a store procedure when application layer already manages a transaction

One of the legacy applications my team has to maintain has almost always this pattern for dealing with data modification: try { // get the connection // begin transaction // optional...

0 answers  ·  posted 2y ago by Alexei‭  ·  edited 2y ago by Canina‭

66%
+2 −0
Collapsing AppBar with two Toolbars

I am trying to create an app with two toolbars on top and a specific collapsing/expanding behaviour on scrolling. See the mockup to get a deeper understanding of what I'm trying to achieve: I fo...

0 answers  ·  posted 2y ago by BenjyTec‭

66%
+4 −1
Load environment variables from .env file in Python 3 [closed]

In Python 2, I was able to create a file named .env within a project folder like so: # .env MY_ID=abc123 TOKEN=4567890 Then in a Python file in the same directory, I could read these variable...

0 answers  ·  posted 2y ago by qohelet‭  ·  closed 2y ago by Alexei‭

37%
+1 −3
Cannot write multipart message to byte array [closed]

I'm trying to write a MIME message to the console. ByteArrayOutputStream out = new ByteArrayOutputStream(); MimeMultipart replyMsg = mdnCreator.createMDNData(); replyMsg.writeTo(out); out.close...

0 answers  ·  posted 2y ago by artaxerxe‭  ·  closed 2y ago by Alexei‭

75%
+4 −0
What are the disadvantages of using auto mapper libraries?

I have noticed that lots of projects (both in real-world and within online courses) use Automapper to map domain models to view models, API models. The main advantage seems to be convenience by re...

2 answers  ·  posted 2y ago by Alexei‭  ·  edited 2y ago by Alexei‭

75%
+4 −0
What advantages does Agner Fog's VCL have over OpenMP?

Agner Fog has this C++ Vector Class Library, which is ... useful for improving code performance where speed is critical and where the compiler is unable to vectorize the code automatically in an...

1 answer  ·  posted 2y ago by anatolyg‭  ·  edited 2y ago by Alexei‭

75%
+4 −0
In the current development context (2020+), is there any reason to use database triggers?

I have not used a database trigger in years in the projects of the teams I have worked in, but I have seen them being used by other teams. Back in 2009, it seemed like a heated debate, but I am wo...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Derek Elkins‭

80%
+6 −0
When stored procedures are preferred over application layer code?

A person I used to work with several years ago was hired to rewrite a product using a .NET-based modern tech stack. One of the aspects that stroke me was that he believes that the product should mo...

2 answers  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Derek Elkins‭

77%
+5 −0
Kotlin FloatArray from Iterable<Float>

Suppose I am using a Java API from Kotlin and I want to call a function that takes a FloatArray (represented as float[] in Java), and I have an Iterable<Float> as my input data type. To be mo...

1 answer  ·  posted 2y ago by Josh Hyatt‭  ·  edited 2y ago by Alexei‭

66%
+6 −2
Why object-oriented instead of class-oriented?

I understand that in object-oriented programming, an object is an instance of a class. If it's an instance, I misunderstand why does it need the term object at all (we could just say "instance"). ...

4 answers  ·  posted 2y ago by deleted user  ·  last activity 2y ago by hkotsubo‭

84%
+9 −0
Are there references in C?

When reading posts at programming sites such as this one, I frequently encounter people saying things like: "There is no pass-by-reference in C, everything is passed by value." People claiming su...

3 answers  ·  posted 2y ago by Lundin‭  ·  last activity 10mo ago by Alexei‭

62%
+3 −1
cannot initialize a variable of type 'CFDictionaryRef'

Background story: I'm on mac OS 11.6 and would like to access an identifier for the current space/desktop from the command line. I found a helpful article at https://ianyh.com/blog/identifying-spac...

1 answer  ·  posted 2y ago by foobar‭  ·  edited 2y ago by Alexei‭

70%
+5 −1
A keydown event succeeds for an English letter but not for an Hebrew one, sharing the same key

I am trying to listen to the event in which the keyboard key containing the Hebrew final-letter ך is pressed. This key stands for both the English letter L and the Hebrew final letter ך. If my op...

0 answers  ·  posted 2y ago by deleted user  ·  edited 2y ago by deleted user

77%
+5 −0
C Language Standard Linking Specifications

What (if anything) does the C standard have to say about linking objects? My guess is that, because C only defines language->behavior rules, it completely ignores any potential intermediate form...

1 answer  ·  posted 2y ago by Josh Hyatt‭  ·  edited 2y ago by Josh Hyatt‭

60%
+4 −2
Question regarding an error message in my compiler to do with my code on linked list.

Can anyone help me, I'm currently learning pointers, this is the code I wrote to try and insert a node at the beginning of the list. However at the part where I included the comment of "error at th...

1 answer  ·  posted 2y ago by hamburgersarecool‭  ·  edited 2y ago by hamburgersarecool‭

28%
+0 −3
How to implement "Loss leader" marketing pattern in ecommerce websites? [closed]

Loss leader is a marketing pattern implemented in stores: A customer enters a store and while heading to some most desired expensive products far from entrance, that customer picks some products s...

0 answers  ·  posted 2y ago by deleted user  ·  closed 2y ago by Alexei‭

80%
+6 −0
Continuously read from piped input using Vim

In Vim, it's possible to tell it to read from stdin instead of a file, by using vim -. This is so that you can pipe the output of one command into Vim, to view/edit it there. The problem I'm facin...

2 answers  ·  posted 2y ago by Hyperlynx‭  ·  last activity 2y ago by deleted user

75%
+4 −0
Appropriate HTTP status code for "user confirmation required"

I'm working on a system where the frontend will make a call to the backend to perform an action. Sometimes this action can cause other unintended consequences (like charging the customer), in thes...

2 answers  ·  posted 2y ago by Welz‭  ·  last activity 2y ago by Alexei‭

40%
+0 −1
How to mock LazyCache when performing unit testing?

A few of my services rely on LazyCache and they use it by injecting IAppCache. For unit testing, I would like to mock this. I have found MockCachingService, but it does not do any caching (as spec...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

66%
+2 −0
How to create fire and forget tasks Q&A in ASP.NET Core with dependency injection support?

One of the legacy applications our team manages contained the following pattern (in the controller): // initialization private readonly IServiceScopeFactory _serviceScopeFactory; public FooCon...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Alexei‭

77%
+5 −0
How to deeply clone an array in Angular / TypeScript?

I have an array that I need to clone in Angular / Typescript. That is, any change done on an element from the cloned array should not affect the content of the initial array. How can I achieve thi...

2 answers  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by hkotsubo‭

77%
+5 −0
Using nested paths vs. flat ones for API resources

This is based on a code review discussion that I had with a colleague about the way I have designed the resources paths for an ASP.NET Core controller that is currently consumed only internally (by...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by meriton‭

62%
+3 −1
java.lang.UnsupportedClassVersionError: when trying to connect to JDBC with JDK 14 in Eclipse

I'm trying to connect to a db file in my project but having some troubles. I'm using JDK 14 with ojdbc11 however I am still getting this when trying to connect: java.lang.UnsupportedClassVersionEr...

1 answer  ·  posted 2y ago by cuzzo‭  ·  edited 2y ago by Alexei‭

80%
+6 −0
Can I set a memory limit for the .NET Core garbage collector to collect objects more aggressively?

I have an ASP.NET Core 5 web application that provides functionality that involves file upload + rather large processing (memory consumption mainly). After each processing (with success or not) the...

2 answers  ·  posted 2y ago by Alexei‭  ·  edited 2y ago by Alexei‭

50%
+2 −2
Manipulate a web browser to hide a certain HTML element in a certain website by a single action

Before I publish a new webpage in my website (in the content management system itself), I zoom in from say 100% zooming to 500% zooming and then re-read it, as a nice way to check for typos. The p...

2 answers  ·  posted 2y ago by deleted user  ·  last activity 2y ago by bta‭

50%
+1 −1
Tracking what users are searching in a content management system

I have a website with a search box. Running search queries in that search box creates frontend/dynamic search result webpages in which search results based on a search query can appear. Let's ass...

2 answers  ·  posted 2y ago by deleted user  ·  edited 2y ago by Alexei‭

77%
+5 −0
How to manage CPU capabilities of Jenkins nodes?

We use Jenkins Pipeline to build and test some C++ software. The pipeline script runs the tests on 10 different nodes in a parallel way in order to save time. All of these nodes are real (not virtu...

1 answer  ·  posted 2y ago by anatolyg‭  ·  last activity 2y ago by bta‭

77%
+5 −0
How to dynamically change panel of ItemsControl?

Let's say I have some collection of data. My goal is to provide different kind of view of ItemsControl depending on user`s preference. For simplicity, we can assume that user can select only betwe...

1 answer  ·  posted 2y ago by FoggyFinder‭  ·  edited 2y ago by FoggyFinder‭

40%
+2 −4
How do I properly format a String for parsing with a com.google.gson.JsonParser

I am trying to check a JSON array for a certain element. However, when I try to instantiate a JsonElement to search the list for: JsonElement builderElement = JsonParser.parseString( "{\"disc...

0 answers  ·  posted 2y ago by cuzzo‭  ·  edited 2y ago by Stephen C‭

71%
+3 −0
Transferring files from a legacy project to an existing one as varbinary

Our team is currently transferring all functionality (+ some changes) from small and very old project A (almost code freeze) to project B (actively developed). As part of the data migration, there ...

1 answer  ·  posted 2y ago by Alexei‭  ·  last activity 2y ago by Derek Elkins‭

81%
+7 −0
Conditionally ignore files in git

I'm using git for LaTeX projects and am in a little dilemma about how to best ignore files. if I add *.pdf to my .gitignore file, I keep forgetting to force add included graphics if I don...

3 answers  ·  posted 2y ago by samcarter‭  ·  last activity 2y ago by Peter Taylor‭

86%
+11 −0
What is malloc's standard-defined behavior with respect to the amount of memory it allocates?

I recently told a friend that malloc(n) allocates and returns a pointer to a block of at least N bytes of memory, as opposed to exactly N; that it is allowed to allocate 'extra' memory to meet e.g....

2 answers  ·  posted 2y ago by ajv‭  ·  last activity 2y ago by bta‭

33%
+1 −4
How can I modify the code above to accept string as user input and use strcmp to compare with the contents of the text file & then delete that line?

I want to enter a string to compare with the text file, and if that word matches, then I want to delete that line containing that string. How can I modify the code below, since the code below take...

1 answer  ·  posted 2y ago by dumplings‭  ·  edited 2y ago by Alexei‭

84%
+9 −0
Open file in script's own folder

I have a Python script that needs to access some data (or configuration) file in its very own folder. For example, say script.py does something like this: with open('data.txt') as file: data ...

2 answers  ·  posted 2y ago by J-hen‭  ·  last activity 3mo ago by Karl Knechtel‭

50%
+1 −1
iframe tag is vertically scrollable although I would expect it to vertically stretch 100%

I have an iframe tag to which I didn't set height so it has a default height which is 150px (at least in Google Chrome). As a consequence, the iframe appears partially in such a way that constant ...

1 answer  ·  posted 2y ago by deleted user  ·  last activity 2y ago by deleted user