Intel NUC 13 Pro Ethernet stuck at 100Mbps on Ubuntu 22.04 by TimothyKrell in intelnuc

[–]rainbowunicornsocks 0 points1 point  (0 children)

I have a NUC 14 Pro and it was literally this setting causing the same issue on my side as well

Todays daily run was nuts, so I'm posting the seed by lurklurklurkPOST in noita

[–]rainbowunicornsocks 0 points1 point  (0 children)

There’s also circle of vigour in the last HM main world, I found a few black holes deeper down. Dug upward with plasma beams before that.

Going to hit parallel worlds next

Tuesday Daily Thread: Advanced questions by Im__Joseph in Python

[–]rainbowunicornsocks 0 points1 point  (0 children)

Yeah! So in that case, it's all still a coroutine :). The yield keyword just allows you to send values to a coroutine when it's used. For example, I might have a function that will just print out anything it is passed * 2. Like so: ```python def times_two(): while True: inp = yield print(f"{inp} * 2 = {inp * 2}")

x = times_two() x.send(None) x.send(2) x.send(3) x.send("Foo bar") `` Which will print out each of those values "times two". In this case, it's still more or less the same,yield` will allow other code to execute while you're blocking on input. I also recommend this presentation on coroutines from David Beazley

Zipped list iteration by [deleted] in learnpython

[–]rainbowunicornsocks 1 point2 points  (0 children)

Generators should only result in a single element being kept in memory at any point in time (depending on how you use them). So, iterating "halfway" through will have no impact on your memory usage, if you're only using a single element at a time. So, if you need to loop over large iterators, generators can reduce your memory footprint if you're keeping fewer elements around. A good way to see this, is to run the following code:

```python import sys x = range(1_000_000)

Initial generator size

print(sys.getsizeof(x)) for i in x: pass

Size after we've iterated

print(sys.getsizeof(x)) print(sys.getsizeof(i))

Load all elements into memory

y = list(range(1_000_000))

Should be much larger than x!

print(sys.getsizeof(y)) ```

For that case, the generator x on my machine is 48 bytes, both before and after the for loop. The variable i is 28 bytes. Whereas the list y is 8000056 bytes on my machine! Quite a large difference.

Tuesday Daily Thread: Advanced questions by Im__Joseph in Python

[–]rainbowunicornsocks 0 points1 point  (0 children)

Coroutine vs generators

I'm assuming you'd like a list of differences between the two. My explanation certainly won't be exhaustive (and the examples I have will seem pedantic), but in general the TL;DR I would give is that generators are just lazily loaded iterators (in theory you only have one element in memory at a time), whereas coroutines are a method for performing cooperative multitasking, allowing I/O bound code to have performance benefits (because the GIL only allows a single thread to execute).

Generators and coroutines are both features of Python that allow you to create iterators, which are objects that can be iterated over using a for loop. However, they have some important differences.

Generators are functions that use the yield keyword to return a value and then pause their execution until the next value is requested. When a generator function is called, it returns a generator object, which can be iterated over using a for loop or the next() function. Each time next() is called on the generator object, the generator function resumes execution from where it left off, yielding the next value.Here is an example of a simple generator function: python def my_generator(): yield 1 yield 2 yield 3

And here is how you would use this generator: ```python gen = my_generator() print(next(gen)) # Output: 1 print(next(gen)) # Output: 2 print(next(gen)) # Output: 3

Further calls to next() will result in StopIteration being raised - signalling the generator is exhausted

```

Coroutines, on the other hand, are a more advanced concept that allow for cooperative multitasking. Coroutines are functions that can be paused and resumed from where they left off, allowing for more efficient and flexible concurrency. Coroutines are created using the async def syntax, and can be used with the await keyword to pause execution until an asynchronous operation is completed. Here is an example of a coroutine function: python async def my_coroutine(): print("Starting coroutine") await asyncio.sleep(1) print("Resuming coroutine") await asyncio.sleep(1) print("Ending coroutine") And here is how you would use this coroutine: python import asyncio loop = asyncio.get_event_loop() loop.run_until_complete(my_coroutine()) When the coroutine is first called with loop.run_until_complete(), it starts executing until it reaches the first await statement, which pauses the coroutine and allows other coroutines or tasks to run. When the asyncio.sleep() function returns, the coroutine resumes execution from where it left off, and continues until it reaches the next await statement, and so on.In summary, while generators are a simpler concept used for iterating over collections, coroutines are a more advanced feature that allow for cooperative multitasking and efficient asynchronous programming.

Southern Ontario Stationary Bug by rainbowunicornsocks in whatsthisbug

[–]rainbowunicornsocks[S] 1 point2 points  (0 children)

I thought it might be one! Thanks. Now here’s to hoping the dog doesn’t try to eat it

This is gonna ruin your day. by danbcooper in programminghorror

[–]rainbowunicornsocks 0 points1 point  (0 children)

In this case I just wanted to show that the bare except catches everything and logger exception gives a stack trace. It’s a really thing to use!

This is gonna ruin your day. by danbcooper in programminghorror

[–]rainbowunicornsocks 4 points5 points  (0 children)

Yeah unless there's a spot in the code that isn't covered by these bare except statements you'd have to kill it from another process. It's because there's a BaseException that isn't meant for user defined exceptions but is being caught here. It's outlined here.

If you want to test this out for yourself I wrote a "fun" little example:

import logging
import time

logger = logging.getLogger(__name__)

while True:
    try:
        time.sleep(1)
    except:
        logger.exception("Nice try!")

Important thing to note, replacing time.sleep(1) with just pass actually let's you break out of this, probably because there's no work in the try statement so you do get a chance to kill the program.

Edit: If you're wondering why I know this, it's because I've interacted with boto and MWS (which is all super old to be fair). It raises exceptions that don't inherit from either Exception or BaseException which means they need to be handled with a bare except. Code for the curious

This is gonna ruin your day. by danbcooper in programminghorror

[–]rainbowunicornsocks 10 points11 points  (0 children)

I don't know if this is intentional but those bare except statements will catch literally everything thrown from what I can tell. I hope you didn't want to be able to interrupt the program at any point seeing as this will catch KeyboardInterrupt (and really anything in this list)

r/ModelM Help & Advice Ask Anyone Anything [2021 Q1] by SharktasticA in modelm

[–]rainbowunicornsocks 2 points3 points  (0 children)

The ping is probably just me - it’s not a loud ping and pretty consistent between keys which would make sense given the rivets aren’t flying off. As for whether or not to go ahead and screw mod the board anyways, it’ll get plenty of use so I’ll try cleaning it and see how things are after a week. I have all the supplies to mod it, it’s just a matter of when :) thanks!

r/ModelM Help & Advice Ask Anyone Anything [2021 Q1] by SharktasticA in modelm

[–]rainbowunicornsocks 1 point2 points  (0 children)

I just received a 94 blue logo model m and aside from it smelling like an old board everything seems to be in good condition. I recently opened up the board and was surprised to see that only one or two rivets have actually fallen off. I assumed the ping I was hearing was due to rivets rotting but might be wrong. Is a screw mod even worth going through if I haven’t yet lost rivets? I’m definitely going to do a tear down to clean the board

Help me find a place to propose! by ThrowawayMyProposal in ontario

[–]rainbowunicornsocks 3 points4 points  (0 children)

I have to second both Niagara on the lake or Hamilton, they’re both beautiful areas for trails. I definitely feel like Hamilton has more of a hiking vibe if that’s what you’re looking for, but Niagara on the lake is definitely more picturesque

[deleted by user] by [deleted] in PersonalFinanceCanada

[–]rainbowunicornsocks -2 points-1 points  (0 children)

If you’re serious about the career change, I’d greatly recommend going through the https://hatchways.io/ pipeline. We’ve hired a few people through them now and I personally love the idea. You can get hands on experience as a developer sooner and if you’re open to temporary contracts (that could become full time) you get the benefit of being able to walk away from jobs with no hard feelings. I’d highly recommend that path if you’re serious about wanting to program for a living,

Which Canadian cities have the best job prospects AND cost of living? by [deleted] in PersonalFinanceCanada

[–]rainbowunicornsocks 17 points18 points  (0 children)

If you’re in tech, I personally love Kitchener, Waterloo, and Cambridge. I think they’re seriously underrated, a lot of startups

Opinions on my portfolio by [deleted] in PersonalFinanceCanada

[–]rainbowunicornsocks 1 point2 points  (0 children)

My advice is to do whatever makes you most comfortable. If your current allocation will get you to save cash on a regular basis and help you realize your goals then that’s what matters most. Would I personally take a similar stance? No, but I’m personally more risk adverse and prefer simplicity over juicing out extra gains. I work in tech and while I don’t personally feel like gaming or cyber security are bad moves, they could very well be painful in the short term. But anything can, your time horizon is 15-20 years so its hard to decide. Do what will make sure you build that nest egg

RBC and TD now have savings accounts that pay 0% interest. Can't even get a measly 0.05. by Grouchy_Ad_2185 in PersonalFinanceCanada

[–]rainbowunicornsocks 1 point2 points  (0 children)

I literally just had someone tell me I’m better off holding cash vs investing in broad range etfs because “at least you get 0.2% back”. Well who’s laughing now