[-] Ogeon@programming.dev 3 points 5 months ago

Maybe they are trying to manifest its death by arranging its funeral over and over. Programming as an art form isn't more dead than painting as an art form, as long as people want to do it. However, as the blog post hints at, what you produce for work wasn't perhaps ever meant to be a work of art. You aren't necessarily going to be able to write code in your favorite style for work anyway, unless you can influence it and decide the conventions. That has been true since forever in larger organisations.

Props to the blog author for seeking out new experiences in their free time but what they are mourning is either still there (just write your art code) or they have just had to adjust to their new trade-off. Don't be surprised when it doesn't feel artistic if you don't spend any effort on the process.

[-] Ogeon@programming.dev 3 points 2 years ago

Same, but I'm feeling better today

[-] Ogeon@programming.dev 2 points 2 years ago

A closure may/will try to capture by reference, so it may hold references to the calling function's scope. For example, this would want to hold a reference to x:

let x = 0;
std::thread::spawn(|| x += 1);

It's as if you had a struct like this:

struct MyClosure<'a> {
    x: &'a mut i32,
}

That makes the closure non-'static, since it holds non-'static references. The usual solution is to use the move keyword, to hint that you want it to move by default, or to use scoped threads. But yeah Send and 'static depend on the captures.

Am I correct in guessing that you handle is of Gontian origin?

Yes! 😁 I picked it when I used to play Tibia (15-20 years ago!), and it stuck with me since then. The correct spelling was already taken, so I modified it a bit. This name is usually available.

[-] Ogeon@programming.dev 2 points 2 years ago* (last edited 2 years ago)

Your guess is correct, it should be understood as

F: ( FnOnce() -> T ) + Send + 'static
T: Send + 'static

The FnOnce() -> T is syntax sugar for FnOnce<(), Output = T> and the bounds after apply to F. That's also why T has separate bounds. They aren't propagated or inherited. It's just an ambiguous looking syntax, but T + Trait + 'lifetime isn't a valid syntax for applying bounds to T (unless I missed something).

The type F may be a closure over values from the calling thread. It has to be possible to send these values to the spawned thread, hence F needs Send + 'static. When the thread is done with its work, it returns a value of type T that gets passed back via JoinHandle<T>, so T needs Send + 'static too.

I hope this cleared things up a bit.

[-] Ogeon@programming.dev 2 points 2 years ago

"Search prompt engineer"

[-] Ogeon@programming.dev 2 points 2 years ago

This depends a bit on what you are looking for. The library documentation is supposed to guide you to a practical starting point, but it's still quite light on the theoretical parts. I haven't really collected any specific beginner material, so this may still be a bit technical. There's a ton of info about the basics, with varying levels of detail.

Assuming you are starting from almost nothing, I would recommend getting familiar with what RGB is and how its components relate. This is the format most images are encoded in and most devices and software use. The Wikipedia page is quite thorough, so no need to read all of it: https://en.wikipedia.org/wiki/RGB_color_model

Next, it's good to know there are other models. HSV and HSL tend to be used in color pickers (a bit more intuitive than RGB), so you have probably interacted with them at some point. Again, the Wikipedia page may be a good source: https://en.wikipedia.org/wiki/HSL_and_HSV

That's often good enough for producing colors and reading or writing images. If you want to go more into editing, it's good to know that you will need to massage the values you get from the images. They usually don't represent the actual light intensities, so they have to be made linear. Palette offers functions for it and represents it in the type system. This video is a slightly simplified explanation of the problem (when it mentions the square root, it's an approximation): https://youtu.be/LKnqECcg6Gw

At some point, you will realize that neither linear nor non-linear RGB is the universal answer to good looking colors. They are used in different situations. There is another category of color models/spaces that are called "perceptually uniform", meaning that they try to simulate or predict how we actually experience the colors and relate it to the numbers in the computer. This page shows the problem and introduces one of those models: https://bottosson.github.io/posts/colorwrong

I can probably provide more sources if you have any specific things you want to read about, but this is a start.

[-] Ogeon@programming.dev 2 points 2 years ago

I assumed the handles are for chairs that are overly heavy and hard to grip.

[-] Ogeon@programming.dev 2 points 2 years ago* (last edited 2 years ago)

It may be possible to use the Any trait to "launder" the value by first casting it to &amp;Any and then downcasting it to the generic type.

let any_value = match tmp_value {
    serde_json::Value::Number(x) => x as &amp;Any,
    // ...
};

let maybe_value = any_value.downcast_ref::&lt; T >();

I haven't tested it, so I may have missed something.

Edit: to be clear, this will not actually let you return multiple types, but let the caller decide which type to expect. I assumed this was your goal.

[-] Ogeon@programming.dev 3 points 2 years ago

Also the Swedish classic "glida in på en räkmacka" ((to) slide in on a shrimp sandwich), which basically means to end up somewhere (location, career, situation) without any difficulties. The shrimp sandwich symbolizes a life without difficulties or in some luxury.

Then there's also "halka in på ett bananskal" ((to) slip in on a banana peel), which is similar to the above, but not always favorable and you don't have any plan or preparation. You just winged it or it just happened by accident.

[-] Ogeon@programming.dev 2 points 2 years ago

Absolutely, I didn't mean to suggest otherwise. :) I'm just giving a bit of context and perspective from someone who has used it for a while.

[-] Ogeon@programming.dev 3 points 2 years ago

They interviewed multiple eye witnesses.

[-] Ogeon@programming.dev 2 points 3 years ago

Do you want the background to have looped back to the start after one cycle? If so, you probably have to make it repeat N times more than the foreground, and move by a factor of 1/N in comparison to the foreground. Or put another way, have 1/N times the length. That means that after one cycle, the background has moved a distance of 1/N, but also repeated exactly once.

I hope this makes sense...

view more: ‹ prev next ›

Ogeon

0 post score
0 comment score
joined 3 years ago