Debugging is like being the detective in a crime movie where you are also the murderer. - Filipe Fortes

26
49
submitted 1 day ago by W3dd1e to c/programming

How do you handle design when working a project that doesn’t have explicit design guidelines?

I’ve been working on some personal projects, but I am continually getting held up on design. I hate looking at a blank page, not knowing where to start. I’m not a particularly creative person in art and design and I really struggle to come up with new ideas on my own. I don’t enjoy it.

I’m the kind of person who buy 10 plain black t-shirts and 5 pairs of plain jeans so I never have to think about style.

I’m sure there are a lot of us out there; you can make the thing but, not design it. How do you work that part of the process?

I don’t want my projects to get skipped over because they’re ugly and I don’t want to copy other designs pixel for pixel.

27
6
submitted 7 hours ago by [email protected] to c/security
28
6
submitted 8 hours ago by [email protected] to c/linux
29
3
submitted 8 hours ago by LadyLeeLoosh to c/java
30
32
submitted 2 days ago by ChubakPDP11 to c/programming

Automatic garbage collection in C is possible with libraries like libgc, but with allocppx.pl, you can just preprocess your file into generating heaps, and these heaps can be used for memory allocation. The type of GC is used, mark and sweep + reference counting. Every memory allocation MAY have a trace, and this trace can be used to 'refget' and 'refunget'. Heap items that are NULL or have 0 refs are collected via mark and sweep.

The generated code is very readable, you can just look at it to get a clue. However, this Perl document is annotated with POD so you can view it in man pages etc. I have submitted an ASCII render of the manpage in Gist.

I hope you enjoy this.

31
20
submitted 14 hours ago by christos to c/commandline

https://gitlab.com/christosangel/tui-battleship

This is a tui implementation of the popular classic naval battle game, written in Bash.

The objective of the game is to destroy the computer's fleet, before the computer achieves the same against you.

You take turns with the computer, hitting squares in each other's grids.

You have to guess the position of the enemy ships on the computer's 10x10 grid, in order to win.

win

You lose if the computer achieves sinking your ships first.

lose

32
31
submitted 1 day ago by [email protected] to c/programming
33
3
submitted 14 hours ago by [email protected] to c/demoscene
34
145
submitted 1 day ago by [email protected] to c/programmer_humor
35
37
submitted 1 day ago by [email protected] to c/programming
36
12
submitted 1 day ago by [email protected] to c/programming
37
34
submitted 2 days ago by [email protected] to c/git
38
13
PuTTY vulnerability vuln-p521-bias (www.chiark.greenend.org.uk)
submitted 1 day ago by [email protected] to c/security
39
26
submitted 1 day ago by [email protected] to c/gamedev
40
5
Day 13 - Users and Groups (linuxupskillchallenge.org)
submitted 22 hours ago by livialima to c/linuxupskillchallenge
41
12
submitted 1 day ago by [email protected] to c/javascript
42
23
submitted 1 day ago by [email protected] to c/programmer_humor
43
9
submitted 1 day ago* (last edited 1 day ago) by [email protected] to c/python

Hello! I'm attempting to follow some tutorials on unit testing with Python. One of them is a video tutorial Unit Tests in Python on the Socratica channel. Everyone in the comments seems to be making out just fine, and I’m following the instructor’s directions to the letter, yet I get a different result. It’s driving me mad lol.

In the video, the instructor creates two text files, one called circles.py in which she defines a function circle_area(r), and another called test_circles.py in which she writes some unit tests. In my attempt to follow along, I've ended up with two files structured like so:

/home/yo_scottie_oh/Projects/PythonTutorials/Socratica/Circles
├── circles.py
└── test_circles.py

circles.py:

from math import pi

def circle_area(r):
   return pi*(r**2)

# Test function
radii = [2, 0, -3, 2 + 5j, True, "radius"]
message = "Area of circles with r = {radius} is {area}."

for r in radii:
   A = circle_area(r)
   print(message.format(radius=r,area=A))

test_circles.py:

import unittest
from circles import circle_area
from math import pi

class TestCircleArea(unittest.TestCase):
   def test_area(self):
      # Test areas when radius >=0
      self.assertAlmostEqual(circle_area(1),pi)
      self.assertAlmostEqual(circle_area(0),0)
      self.assertAlmostEqual(circle_area(2.1),pi*2.1**2)

Where I'm getting tripped up is at 4:32 in the video, the instructor says to run the unit tests by opening a shell, going to the directory that contains both the circles and test_circles modules, and issuing the following command: python -m unittest test_circles.

Instructor's result (it runs the unit test):

Ran 1 test in 0.000s

OK

My result (it seems to execute circles.py itself):

[yo_scottie_oh@nobara Circles]$ python -m unittest test_circles
Area of circles with r = 2 is 12.566370614359172.
Area of circles with r = 0 is 0.0.
Area of circles with r = -3 is 28.274333882308138.
Area of circles with r = (2+5j) is (-65.97344572538566+62.83185307179586j).
Area of circles with r = True is 3.141592653589793.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib64/python3.11/unittest/__main__.py", line 18, in <module>
    main(module=None)
  File "/usr/lib64/python3.11/unittest/main.py", line 101, in __init__
    self.parseArgs(argv)
  File "/usr/lib64/python3.11/unittest/main.py", line 150, in parseArgs
    self.createTests()
  File "/usr/lib64/python3.11/unittest/main.py", line 161, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 232, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 232, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 162, in loadTestsFromName
    module = __import__(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yo_scottie_oh/Projects/PythonTutorials/Socratica/Circles/test_circles.py", line 4, in <module>
    from circles import circle_area
  File "/home/yo_scottie_oh/Projects/PythonTutorials/Socratica/Circles/circles.py", line 14, in <module>
    A = circle_area(r)
        ^^^^^^^^^^^^^^
  File "/home/yo_scottie_oh/Projects/PythonTutorials/Socratica/Circles/circles.py", line 6, in circle_area
    return pi*(r**2)
               ~^^~
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'
[yo_scottie_oh@nobara Circles]$

I've been banging my head against the wall for hours now trying to figure out why when I execute the same command as the instructor, it appears to execute my Python scripts themselves instead of running the unit tests.

Other things I've tried:

I've read the Python documentation on unit testing. I tried adding this to the end of the test_circles.py document, but that did not change anything.

if __name__ == '__main__':
    unittest.main()

I've tried following this other written tutorial. After I create the text documents and organize them in the separate shapes and tests folders and run the command python -m unittest discover -v, again I get a different result from the author.

Author's result:

test_area (test_circle.TestCircle) ... ok
test_circle_instance_of_shape (test_circle.TestCircle) ... ok
test_create_circle_negative_radius (test_circle.TestCircle) ... ok
test_area (test_square.TestSquare) ... ok
test_create_square_negative_length (test_square.TestSquare) ... ok
test_square_instance_of_shape (test_square.TestSquare) ... ok

----------------------------------------------------------------------
Ran 6 tests in 0.002s

OK

My result:

[yo_scottie_oh@nobara test]$ python -m unittest discover -v
test_circle (unittest.loader._FailedTest.test_circle) ... ERROR
test_square (unittest.loader._FailedTest.test_square) ... ERROR

======================================================================
ERROR: test_circle (unittest.loader._FailedTest.test_circle)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_circle
Traceback (most recent call last):
  File "/usr/lib64/python3.11/unittest/loader.py", line 419, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 362, in _get_module_from_name
    __import__(name)
  File "/home/yo_scottie_oh/Projects/PythonTutorials/PythonUnitTesting/test/test_circle.py", line 4, in <module>
    from shapes.circle import Circle
ModuleNotFoundError: No module named 'shapes'


======================================================================
ERROR: test_square (unittest.loader._FailedTest.test_square)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_square
Traceback (most recent call last):
  File "/usr/lib64/python3.11/unittest/loader.py", line 419, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/unittest/loader.py", line 362, in _get_module_from_name
    __import__(name)
  File "/home/yo_scottie_oh/Projects/PythonTutorials/PythonUnitTesting/test/test_square.py", line 3, in <module>
    from shapes.square import Square
ModuleNotFoundError: No module named 'shapes'


----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (errors=2)

So yeah… this brings me to my question: What’s the obvious thing that everybody else gets that I'm missing? Is the tutorial outdated? Is it because the instructor is on Windows and I’m on Linux? Why won’t my unit tests run?

44
810
submitted 3 days ago by [email protected] to c/programmer_humor

cross-posted from: https://jlai.lu/post/6002282

He revealed the secrets !

45
5
HeliBoard Questions (lemmy.world)
submitted 1 day ago by [email protected] to c/foss_keyboards

Noob here (and I posted some of this already as a reply o an older post: https://lemmy.world/comment/8190997 )

I actually just installed HeliBoard through Obtainium, and have a bunch of questions.

First of all, I’m confused – I installed HeliBoard_1.2-release.apk . I didn’t really know how HeliBoard_1.2-debug.apk and HeliBoard_1.2-nouserlib.apk were different.

Also, I just installed that and nothing else. It’s giving me suggestions, but no corrections. Is that because I didn’t install any dictionaries? If so, how do I install one – do I just click on the download icon here https://codeberg.org/Helium314/aosp-dictionaries/src/branch/main/dictionaries/main_en_us.dict ? And what do I do then? Sorry, noob here.

On the other languages and autocorrect issues discussed here: https://lemmy.world/post/12769494 – it sounds like it used to have the equivalent of GBoard’s globe icon you could click on to switch languages but not anymore? You have to go to settings and uncheck English and check whatever other language you want to use?

And, it seems like I can do the equivalent of Shift + key on a standalone keyboard (for example, to get 1 instead of Q), but I don’t know how to, or what that’s even called.

Thank you!

46
11
submitted 1 day ago* (last edited 1 day ago) by [email protected] to c/rust

I’m personally very excited about this because Rauthy provides a robust foundation of OIDC-based identity for the fedi-connected platform we’re building with Weird netizens.

The addition of “social logins” such as GitHub means indie platforms like Weird can let people easily sign in with the mainstream identity provider they’ve already got, but once they’ve signed up they’ll have the option of using our open source identity provider for other services going forward, thus reducing their dependency on the Big Corp.

47
20
Iced Tutorial 0.12 (leafheap.com)
submitted 1 day ago by autokludge to c/rust

Original submission text (Bruce Hopkins):

Iced is an amazing library. I chose it for building a simple Code Editor. But Iced severely lacks documentation. I wrote this article as a good entry point into using Iced that can be easy to understand as long as you know Rust. I explain the parts that confused me when I began using the library, so I hope that my mistakes can be useful for someone else.
I might write articles into the more advanced topics in Iced, so if this article is something that you like, let me know.

48
16
submitted 3 days ago by [email protected] to c/security
49
19
submitted 3 days ago by secana to c/rust

Hi rustaceans! What are you working on this week? Did you discover something new, you want to share?

50
195
submitted 3 days ago by [email protected] to c/programming
view more: ‹ prev next ›

programming.dev

8,074 readers
401 users here now

Welcome Programmers!

programming.dev is a collection of programming communities and other topics relevant to software engineers, hackers, roboticists, hardware and software enthusiasts, and more.

The site is primarily english with some communities in other languages. We are connected to many other sites using the activitypub protocol that you can view posts from in the "all" tab while the "local" tab shows posts on our site.


🔗 Site with links to all relevant programming.dev sites

🟩 Not a fan of the default UI? We have alternate frontends we host that you can view the same content from

ℹ️ We have a wiki site that communities can host documents on


⚖️ All users are expected to follow our Code of Conduct and the other various documents on our legal site

❤️ The site is run by a team of volunteers. If youre interested in donating to help fund things such as server costs you can do so here

💬 We have a microblog site aimed towards programmers available at https://bytes.programming.dev

🛠️ We have a forgejo instance for hosting git repositories relating to our site and the fediverse. If you have a project that relates and follows our Code of Conduct feel free to host it there and if you have ideas for things to improve our sites feel free to create issues in the relevant repositories. To go along with the instance we also have a site for sharing small code snippets that might be too small for their own repository.

🌲 We have a discord server and a matrix space for chatting with other members of the community. These are bridged to each other (so you can interact with people using matrix from discord and vice versa.

founded 10 months ago
ADMINS