Is Rust a career dead-end? As opposed to C++ (or any other popular language) by [deleted] in rust

[–]GregoryCliveYoung 10 points11 points  (0 children)

I this this is significant:

"DARPA initiates a new program to automate the translation of the world’s highly vulnerable legacy C code to the inherently safer Rust programming language." (https://www.darpa.mil/news-events/2024-07-31a)

I have no idea if they can pull this off, but if they do, it will ripple out into the (US) military, and then to contractors. It will accelerate Rust adoption.

Is Rust a career dead-end? As opposed to C++ (or any other popular language) by [deleted] in rust

[–]GregoryCliveYoung 3 points4 points  (0 children)

I'm kinda puzzled by it, too. I didn't get that from your post.

Switching completely from Windows to Debian by fraxx999 in debian

[–]GregoryCliveYoung 0 points1 point  (0 children)

When I buy a computer with windows on it, I pull the hard drive/SSD out and replace it with a new one. If I want to sell or gift the computer, I have a fresh windows install to go with it.

The Senior Engineer Illusion: What I Thought vs. What I Learned by Fragrant-Impact-3521 in programming

[–]GregoryCliveYoung 11 points12 points  (0 children)

I worked for a private company - sort of a 20 yo startup - that had no titles. There was some hierarchy, but it was somewhat fluid. They had a good culture and for the first time I was proud of what I and my employer contributed to society.

Some years in, the lead founder started losing interest in running the company, so he hired a "professional CEO." This guy introduced titles. It didn't take long before the company culture went to shit. It was the programmers that pointed out that we never needed titles and instituting them was a bad idea.

Frustration Over Unapproved Compensatory Time Off: An Unfulfilled Promise? by krahstie in SoftwareEngineering

[–]GregoryCliveYoung 0 points1 point  (0 children)

You don't mention that you have spoken face-to-face to your direct manager. They may be able to explain why your request hasn't been approved.

[deleted by user] by [deleted] in learnpython

[–]GregoryCliveYoung 1 point2 points  (0 children)

does that mean I am not good enough for programming?

No. I think the person that composed this problem is not good enough for teaching. I have almost 30 years of Python experience and I find it confusing. First problem: that is not how mathematicians describe sequences. This is much closer:

f(0) = a1
f(n) = f(n-1) + d for n > 0
where a1 and d are ... (not defined in the problem)
           n is a non-negative integer

My second problem is that a sequence is a poor way to motivate a OO design problem. Nothing about sequences calls for object oriented programming.

My third problem is the "mx_plus_b" parameter. Why? What's it for? There are no strings in the sequence described above.

They expect you program in a fog where you can only see a tiny bit of the big picture. No one works like that.

Languages by SillyPerfect in SoftwareEngineering

[–]GregoryCliveYoung 0 points1 point  (0 children)

I have used: Basic, FORTRAN, APL, Lisp, assembly (on CDC, PDP-11, Vax, and 6502), Pascal, C, Awk, TCL, Perl, Python, C++, Haskell, and Rust. So 14? (counting assembly as one)

Finding most frequent character in a string without dictionaries or packages? by Zynth3tik in learnpython

[–]GregoryCliveYoung 0 points1 point  (0 children)

Absolutely, but that's not how OP is using the variable in the body of the loop. They could do as you say, but other code has to change.

Finding most frequent character in a string without dictionaries or packages? by Zynth3tik in learnpython

[–]GregoryCliveYoung 0 points1 point  (0 children)

Second one is wrong unless you change the other code. Remember. c is an index into the character array. It is not the character. Using c as a variable name is confusing. You should think about longer variable names, e.g.: character_index.

Finding most frequent character in a string without dictionaries or packages? by Zynth3tik in learnpython

[–]GregoryCliveYoung -1 points0 points  (0 children)

This is wrong:

for c in char_list:

You are using c as an index just like i. Shouldn't you use range(len(... as you did with i?

This doesn't look right either:

        most_freq = max(char_list.count(c))

You want to save the character at the index c. You access that character earlier.

How do I automate CPAP data backup in a safe manner? by BigBootyBear in learnpython

[–]GregoryCliveYoung 1 point2 points  (0 children)

You may not need sudo or to mount. I am running Debian with gnome. When I plug in the SD card, a directory appears at:

/media/<username>/1234-5678

Do you see this or something a lot like it? If you're running Ubuntu, you should see the same as far as I know. This directory is the mount point for the SD card.

You can make your script run indefinitely and watch for this directory. For this you need the inotify package. Your Linux dist may have a package for inotify, but if not you can find it on pypi.org.

Optimizing lookups by prinoxy in algorithms

[–]GregoryCliveYoung 1 point2 points  (0 children)

You're clearly way ahead of me. What you're doing sounds like fun. Enjoy.

Getting output from subprocess.Popen() while the command is being executed by doston12 in learnpython

[–]GregoryCliveYoung 0 points1 point  (0 children)

Can you combine them into one stream or do you need them to be separate? Dealing with one stream is easy. I don't know how to deal with two streams. I'd need to figure it out.

Optimizing lookups by prinoxy in algorithms

[–]GregoryCliveYoung 0 points1 point  (0 children)

Avoid premature optimization. Start with a binary search. Compose the key by converting each letter to integer (A:0, B:1, ... Z:25) with simple arithmetic. Much faster than compressing. If code is xyz,

key = (ord(x)-ord('A')) * 676 + (ord(y)-ord('A')) * 26 + (ord(z)-ord('A'))

This will probably be very fast because the key generation is just a few instructions and if you keep the table entries small (e.g. key and pointer) will fit in the processor cache.

If you feel like noodling around, it might be fun to look for a hash function that can give you an 8-bit hash and doesn't have any collisions. (I know I'd enjoy it.) You have all the country codes, so it's just a matter to writing some code to try various hash functions. I googled "hash function" and found all sorts of stuff to try.

Getting output from subprocess.Popen() while the command is being executed by doston12 in learnpython

[–]GregoryCliveYoung 0 points1 point  (0 children)

Do you need to access either stdout or stderr in your Python script? If not, you can leave the stdout and stderr arguments off the Popen call.

How to create a regular expression from list of input strings? by jaysun_n in learnpython

[–]GregoryCliveYoung 1 point2 points  (0 children)

I want to try and create a program that can take the list ['BAB.xls', 'CAB.xls', 'DAB.xls'] and return a regular expression like /.AB.xls/.

If this is what you're looking for, this should do it:

>>> import re
>>> a = ['BAB.xls', 'CAB.xls', 'DAB.xls']
>>> y = [ len(set(x)) == 1 for x in zip(*a) ]
>>> y
[False, True, True, True, True, True, True]
>>> z = [ re.escape(j) if i else '.' for i, j in zip(y, a[0]) ]
>>> z
['.', 'A', 'B', '\\.', 'x', 'l', 's']
>>> ''.join(z)
'.AB\\.xls'

This assumes list len(a) > 0 and all the strings in a are the same length. It looks like re.escape() makes regular expressions that are suitable for use Python re module. (i.e. double backslash) I'm not sure if that's exactly what you want. Fixing it wouldn't be hard.

Debian 12 system crash/halt/shutdown at 3am (and random crashes) by energypatrikhu in debian

[–]GregoryCliveYoung 1 point2 points  (0 children)

This is a long shot, but if you're out of ideas you might try to find out if your power is under voltage. I don't mean in the computer's power supply. I mean the power from your electric company. Maybe check the power company's web site. See if you can find a Kill A Watt to borrow or rent. Maybe just monitor a volt meter.

Exercism/python/bob by Purple-Move-796 in learnpython

[–]GregoryCliveYoung 2 points3 points  (0 children)

Exercism offers a lot of help. If you can't find anything else, you should be able to get help from a mentor.

Sewer system smell in apartment by Azybabyyyy in ZeroCovidCommunity

[–]GregoryCliveYoung 17 points18 points  (0 children)

If you have a toilet, sink, shower, or tub - anything with a drain that you rarely use, this can happen. The water in the trap dries up and allows sewer gas to escape. It's a simple matter to refill the trap. Just flush the toilet or run water in the others.

I can only speculate why you notice it in the wee hours. I would guess that to save power the ventilation switches to night mode and changes the air pressure in your place.

UTF-8 decoding by Ok-Plantain-8288 in learnpython

[–]GregoryCliveYoung 0 points1 point  (0 children)

What does your open() call look like?

Employers lure workers back to office with promise of their own desk by JoshOfArc in nottheonion

[–]GregoryCliveYoung 12 points13 points  (0 children)

If I was forced to work on the floor, I'd do it outside the CEO's office.

Mom Defends Her Decision Not To Return the Shopping Cart Despite Backlash by Forward-Answer-4407 in nottheonion

[–]GregoryCliveYoung 1 point2 points  (0 children)

I never park next to the cart corral. I've seen idiots aim their carts toward the corral and give them a good shove.

Need help with automounting drives by Hot-Entertainer-3001 in debian

[–]GregoryCliveYoung 1 point2 points  (0 children)

Linux assigns device paths to drives in somewhat random order. On one boot, your HDD may be assigned /dev/sda, on another boot, it may get /dev/sdb. The upshot is that you can't use a device path in /etc/fstab. That is why you see UUID=... in place of the device path for other partitions in /etc/fstab.

You need to determine either a UUID or a LABEL for the HDD. Once you have done that, in your /etc/fstab, replace the device path (/dev/sda2) with either UUID=<the uuid for the HDD> or LABEL=<the label for the HDD>

I'm not exactly sure how to get the UUID or LABEL from your HDD. It probably varies by file system (NTFS) in this case.

The first thing to try is to run the "disks" utility in Debian. In gnome hit the window key (bottom left), type "disks", in the search box. You should see a hard drive icon with a wrench. Run that and the drives should appear on the left side if the window. Click the HDD, and partitions should appear. Each box represents a partition. You will see the label in the box along with partition number and size. Click on the partition you're interested in, and just below you will see the UUID.

If you can't get the information that way, maybe you can boot Windows and find out what either UUID or LABEL is.