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 »

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.

Activity for matthewsnyder‭

Type On... Excerpt Status Date
Answer A: How and where does Python code start running? How can I control that?
Files with `.py` extension are scripts. You run them with `python myscript.py`. Python is an imperative language, so executing a file will run each line one by one, starting from the top, and exit when the end of the file is reached. In your example, the script is saying: 1. Create a functio...
(more)
25 days ago
Question Privilege escalation from Python like from systemd
When you try to do a privileged systemd operation without the privilege, you get an escalation prompt: ``` $ systemctl stop docker ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ==== Authentication is required to stop 'docker.service'. Authenticating as: [MY USER NAME] Password: ...
(more)
about 1 month ago
Question VS code - stop reopening old tabs
When I open VS Code inside a project dir, it reopens all the tabs that were open last time, and re-expands all the folders that were unfolded last time. I find this annoying. Usually, when I close VS Code, it's because I'm done working with what I was doing. I don't want to manually "clean up" at ...
(more)
about 1 month ago
Answer A: GnuTLS config for my own root CA, for use on internal server
For future readers - based on input from Michael, and some research that was spurred by that improved version, this is the final config I arrived at: ``` https://gnutls.org/manual/htmlnode/certtool-Invocation.html#certtool-Invocation cn = "nosuchdomain.com" organization = FakeCompanyName cou...
(more)
about 2 months ago
Answer A: Why is global evil?
A global variable or object is in scope everywhere. That means it's possible to modify it from any part of your program. Imagine a mature program, made up of thousands of lines of code and dozens of files. A statement that does something with that global variable could be found anywhere in those. ...
(more)
about 2 months ago
Answer A: PHP - Why using "global" considered bad?
Nothing in particular will go wrong. `global` is a valid and supported keyword, the code will work. There is no problem for the computer. The problem is for you. When something is `global`, it could be getting changed by anything else. You have to read through the whole codebase, to understand wha...
(more)
about 2 months ago
Question Why is global evil?
Many languages discourage global variables. Why is this?
(more)
about 2 months ago
Answer A: What is a reasonable minimum for making a FOSS project inviting to contributors?
I don't actually know the answer to this, but I'll post a provisional one while we wait for someone wiser than me to chime in. I think this is a small subset of the real answer. 1. Don't forget the license. Make sure it's clear that it's FOSS. Code without a license on a public repo is, by default...
(more)
about 2 months ago
Question What makes people able but unwilling to contribute to FOSS projects?
Suppose someone has the requisite knowledge and skillset to contribute to a FOSS project, they have the free time to do so and they are aware of the project. Yet, they decide not to contribute. This appears to be quite common, the proportion of people who choose to contribute is a tiny minority of th...
(more)
about 2 months ago
Question What is a reasonable minimum for making a FOSS project inviting to contributors?
A lot of people who maintain FOSS projects would like to get more contributions. What can the maintainer do to ensure that potential contributors are converted into actual contributors? There are many things you can do to encourage people to contribute to your project, up to and including payin...
(more)
about 2 months ago
Answer A: How to group a flat list of attributes into a nested lists?
The obvious way would be to simply start with an empty list of lists, loop through the input, and for each item decide which sublist to put it in. It's not super dev-friendly to remember which list was which. So instead, I think it's better to construct each sublist separately, and then combine th...
(more)
2 months ago
Question Is software system design on topic here?
Is software system design on topic for the software development site? For what I mean by system design, consider the "system design interview" commonly held these days when recruiting software engineers. I assume a software site would primarily deal with software systems, rather than things like a...
(more)
2 months ago
Question Don't close questions for lack of detail/confusion
tl;dr: When a question is unclear, don't close right away, especially if it's possible to discern what they are trying to ask. Instead, use comments and edit suggestions to work with the asker and help them improve the question. Only close if it is absolutely hopeless (if the asker disappears for wee...
(more)
2 months ago
Question GnuTLS config for my own root CA, for use on internal server
I am trying to generate my own root CA certificate. Context My goal is to sign an intermediate CA with this certificate, and then install the intermediate CA on my own client machines. The intermediate CA will be used to sign a server on my private LAN. The server has no inbound route and cannot ...
(more)
3 months ago
Answer A: How to hide files from the VS Code sidebar without pattern matching?
You could just move the files to a new folder and open that :) Alright alright here's a serious answer: I noticed that VSC automatically dereferences symlinks. So if you create a temporary new folder and symlink only the files you want, this will effectively accomplish what you are asking. To m...
(more)
3 months ago
Answer A: What is the difference between hashing and encryption?
Hashing is lossy compression. You can't recover the input of a hash from the result. This would obviously not work as an encryption. How would you decrypt it, if half the message is destroyed :) Consider the SHA hash. You can hash a 1 GB file into a 0.1 kB string. Wow! Why don't we just sen...
(more)
3 months ago
Answer A: Building a language model completely from scratch
This is not feasible as described. To learn LLMs, you can look at models like 3B WizardLM. These are open source and should be possible to just train and run as is. The build may be very complex, and consumer hardware may be insufficient (but the easy solution is to run it on the cloud). You ca...
(more)
3 months ago
Answer A: How to troubleshoot ModuleNotFoundError?
`ModuleNotFoundError` means that in running your program, Python attempted to import some module `xyz` but it was not present on your system. It could be that you forgot to install the module (forgot to `pip install -r requirements.txt`), misspelled the module name, or tried to import a module tha...
(more)
4 months ago
Question How to troubleshoot ModuleNotFoundError?
I ran some Python code and it crashed with `ModuleNotFoundError`. What is the general approach for dealing with these situations?
(more)
4 months ago
Answer A: Are "strong passwords" at all meaningful?
The assumption of 1k attempts/s is wishful thinking, as is the idea that a hacker will go on mail.google.com and try to guess your login (they would get a captcha after like 5 failed attempts). Password security comes into play when someone steals the whole table of all accounts and password hashe...
(more)
4 months ago
Answer A: Does Python have a "ternary operator" (conditional evaluation operator like "?:" in other languages)?
The Python ternary "operator" is `if` and `else`: ``` x = 1 if somecondition else 0 ``` In Python, this is called a "conditional expression" rather than an operator, and the documentation explains it: https://docs.python.org/3.12/reference/expressions.html?highlight=ternary#conditional-expressi...
(more)
6 months ago
Answer A: Understanding mutable default arguments in Python
Everything you put on the line with `def` is global (global to the file, not as in the `global` keyword), so the (initially empty) list you create with `param=[]` persists and gets reused between calls to `example()`. You probably want to create a local list for each invocation instead. For that, you...
(more)
6 months ago
Question PEP20 on namespaces: What exactly is it saying to do?
PEP20 aka the Zen of Python has a statement: >Namespaces are one honking great idea -- let's do more of those! What exactly are we supposed to "do" according to this? Is it saying we should have more "honking great ideas" like namespaces and add them to the language as PEPs? Is it saying ...
(more)
6 months ago
Answer A: What is the point of triggering CI/CD with an empty git commit?
The reason this practice exists is because CIs suck. The frameworks/services themselves suck, and the way people write the configs also suck, and the two combine to create a mega-suck. A CI is supposed to trigger as you make changes so you automatically have an up-to-date indicator on whether the ...
(more)
6 months ago
Question Get list of all variables from Jinja template
Suppose you have a jinja template like this: ```lang-none I am going to {{ foo }} to get some {{ bar }}. I hope I can find: {% for i in baz %} - {{i}} {% endfor %} ``` This template will require you to pass variables `foo`, `bar` and `baz` when rendering it. If any are missing, it will ret...
(more)
7 months ago
Answer A: What software architecture are available for developing an application with multiple business domains that only share some common aspects?
If I ignore the example and answer the title generally: You would put the common logic into a third piece of software that becomes the dependency of both domains. For example, let's say you are writing software for a company that has two domains of business: They sell construction tools and materi...
(more)
7 months ago
Question Suggested special feature: Clinic/case study
We have special features/sections on Codidact, so maybe this is a nice use for them. What if we had a section named something like "clinic" or "case study" or "debugging"? (name suggestions welcome) The point of this section would be specific debugging or troubleshooting help questions. The for...
(more)
7 months ago
Question Can you run Python code on text in VS Code?
In VS Code, is it possible to run Python code on the text being edited? I realize that I can save my text, create a `.py` file, switch to a terminal (including VS Code's own terminal) and run the `.py` file. However, some other editors like Gedit support running ad-hoc Python scripts to process th...
(more)
8 months ago
Question Advanced Regex extension for VS Code
VS Code supports regex search, but the search/replace is UI is just a tiny dialog box. It's okay if you know regex well and the expression is not complex, but when trying to apply complicated expressions the usability is not good. I often end up having to "develop" the regex in regexr.com, which mean...
(more)
8 months ago
Question How to overwrite lines of STDOUT in Python?
`print()` normally adds text to STDOUT, it does not erase existing text. https://linux.codidact.com/posts/289869 describes various ways of doing the overwrite in shell scripts. How can you do this in Python?
(more)
8 months ago
Question How to open VS code with a particular path expanded?
When you do: ```sh cd /some/path code . ``` VS Code opens with that location shown in the "Explorer" sidebar. However, the state of the file tree and the currently open files will be the same as what was remembered from the last session. Let's say that last time I was editing `/some/path/fo...
(more)
8 months ago
Question How to provide meaningful names for emails in Maildir?
I am writing some scripts that operate on emails in Maildir format. A lot of things are easy in this format, but the filenames are absolutely incomprehensible. For example, one script moves mails between folders based on some rules. It has a dry run mode which simply says which mails would be move...
(more)
8 months ago
Question Regex for simplifying Amazon product URLs
Amazon product URLs are often very long, but on experimentation it is revealed that the following pattern is sufficient: ``` https://www.amazon.com/{dp|gp}/$ID ``` `ID` is a 10-char string, which I'm guessing is the ASIN. I want to parse out the long URLs into the minimal form. What exactly is ...
(more)
8 months ago
Question Determine which script is slowing the page down in Firefox
A page is very slow and laggy in Firefox. I am certain it's one of the many Javascripts slowing it down. Out of curiosity, I'd like to figure out which script is creating the heaviest load. Note that I also have some blocked with uBlock origin, and I don't want to unblock those - I want to see whi...
(more)
8 months ago
Answer A: Shortcut for inserting today's date in VS Code
You can use snippets for this. In the example below, when you type `today` and trigger completion (usually Ctrl+Space) you will see an option to insert the date by pressing Enter. Snippet code: ```json "today ISO": { // applies everywhere "scope": "", "prefix": "today", "body": [ "$CU...
(more)
8 months ago
Question Shortcut for inserting today's date in VS Code
Is there a way to easily insert today's date when editing a file in VS Code?
(more)
8 months ago
Answer A: VS Code: How to open a file and folder in a new window?
Best I could do was: ```shell cd /foo/bar && code --new-window . && code baz.txt ``` The `cd` is not necessary but makes the command cleaner. I would still like to know if there's a cleaner way.
(more)
8 months ago
Question VS Code: How to open a file and folder in a new window?
I've figured out that `code --new-window /foo/bar/baz.txt` will open `baz.txt` in a new window. But when I do this, it says "no folder opened" in the file explorer pane. That makes it hard to work with other files in the same directory. How can I also set the folder when opening a file like this? ...
(more)
8 months ago
Answer A: What is the meaning of "short circuit" operators?
It means the program can give up early if checking the rest of a boolean expression is pointless. For example, naively to evaluate `p and q` you must check the value of both `p` and `q`, and then do the `and` operation. However, if you are a bit more clever, you'll see that when `p` is `False`,...
(more)
8 months ago
Answer A: How should open source forks, with a mix of upstreamable and non-upstreamable commits, be maintained?
The ideal way is to separate the upstreamable and non-upstreamable changes. For example you could maintain two branches: `public` and `private`. All upstreamable changes are cherry picked to public and this is what you send back to the upstream. All your non-upstreamable changes would be in privat...
(more)
8 months ago
Answer A: Alternatives to `EXPLAIN ANALYZE` for queries that won't complete
You can try to break up the query into CTEs, and then see if any of the individual CTEs are unusually slow. I am guessing the query is not just one select, but probably has subqueries, window functions, aggregations, joins and so on. All of these can be split into CTEs pretty easily (if you have q...
(more)
8 months ago
Question Is there a text version of pickle?
Is there a Python serialization format that has capabilities similar to Pickle, but is text based? The problem I always have with pickle is that it's binary, so I can't manually view or edit the data. The standard library includes `json`, but that requires a tedious converting of types at read ...
(more)
8 months ago
Question Listen for key events in a CLI app
I have a Python program like this: ```python done = False while u and not done: i = u.pop() print(f"Processing {i}") dobigtask(i) finishup() ``` Since this takes a long time, the user might get tired of waiting. I want the program to also continually listen for a keystroke, s...
(more)
9 months ago
Answer A: What is the point of pipx?
Dependency conflicts are the problem pipx aims to solve, in the context of installing CLI programs. When you install a Python package, by default pip will also install their dependent packages so that you don't get `ImportError`s when trying to use the package. These dependencies are explicitly co...
(more)
9 months ago
Answer A: How should I organize material about text encoding in Python into questions?
Much of this is already covered in various sources like https://docs.python.org/3/howto/unicode.html. Although there are issues with relying on links, I figure official documentation is probably fair game. I would start with two types of question: "Where can I find detailed information about t...
(more)
9 months ago
Question How can a Python program send itself to the background?
Is it possible for a Python program to send itself in the background? For example, on Linux you can do `nohup somecmd &` and any program will run in the background. Some programs also support switches like `-d` (daemonize) to run in the background without `nohup`/`&`. How can a Python program do t...
(more)
9 months ago
Question How can I schedule a later task in Python?
I want my CLI Python program to schedule a task, and then exit. After some times has passed (say 10 minutes) the task should execute. The task can be a Python method or a shell command, whatever is easier. I can convert my use case to accommodate it. This would be on Linux only. How can I sc...
(more)
9 months ago
Answer A: Clone .git repo into current dir, without touching files
One way to do it is to simply clone the repo elsewhere and move the .git file to the current one.
(more)
9 months ago
Question Clone .git repo into current dir, without touching files
I have git repo where the .git is deleted. I didn't realize it until after I made some changes to the code. I want to re-create the `.git` by cloning. However I don't want it to touch the files that I already have. When the `.git` is cloned, I will run git checkout and it will detect my changes as...
(more)
9 months ago
Answer A: Git: How to clone only a few recent commits?
This is called a shallow clone and it's supported by a git-clone argument: ``` git clone --depth 5 ```
(more)
9 months ago