Rubber Duck Club
Nobody has said anything yet. Be the first.
Rubber duck debugging: talk through your programming problem
Explain your problem out loud here. Half of you will solve it in the third paragraph and post anyway. That is allowed.
Answer your own thread
If you work it out while typing, post the answer. Someone will search for it.
Bring the detail
Versions, error text, what you already tried. "It does not work" is not a question anyone can answer.
No drive-by self promotion
Share your own work when it answers the thread. A link with no context is a advert, and it gets removed.
Nobody has said anything yet. Be the first.
Stuck on a bug? Paste the error, share the code, describe what you expected. Real devs will help you think through it.
Showing 4 posts.
making the pong game for @tomasz_k (long story) and im stuck on the borrow checker. i have a game struct with a list of entities and i want to update each one, but update needs to call a method on self struct Game { items: Vec<Entity>, score: u32, } impl Game { fn tick(&mut self) { for item in self.items.iter() { self.update(item); } } fn update(&mut self, item: &Entity) { // moves the item, maybe changes score } }…
Assalam o Alaikum all. I am a 2nd year CS student. I am having a confusion in recursion. Here is my code: #include <stdio.h> void print(int n) { if (n == 0) return; print(n - 1); printf("%d ", n); } int main() { print(5); return 0; } I expected 5 4 3 2 1 but it prints 1 2 3 4 5 . When I move the printf above the recursive call, it prints 5 4 3 2 1 . Why is the position of one line changing the whole order? Our…
Accepted answer
Quick one. Practicing Linux for the transition (ETS in 7 months, SkillBridge after that if it gets approved). Wrote a Python script that pings a list of hosts and writes the results to a CSV. Works fine when I run it from my home directory. Put it in crontab -e to run every 5 minutes. Nothing. No CSV, no error, nothing. */5 * * * * python3 pinger.py What I checked: cron is running ( systemctl status cron says…
Accepted answer
Hi, I am intern at a fintech, writing internal API in Django REST Framework. Endpoint /api/transfers/ returns 50 transfers and django-debug-toolbar shows 312 queries xD Models: Transfer has two ForeignKeys to Account (sender, receiver), Account has ForeignKey to Customer , and Transfer has ManyToMany tags . class TransferViewSet(viewsets.ReadOnlyModelViewSet): queryset = Transfer.objects.select_related("sender",…
Accepted answer