Same, but I’m feeling better today
- 4 Posts
- 40 Comments
Ogeon@programming.devto memes@lemmy.world•Even the ones that trick you by starting out cheap13·9 months agoA relatively cheap PC with Factorio and you are set. You won’t spend much on food either, so win-win.
Ogeon@programming.devto Programming@programming.dev•.dev It's time to return to the roots, to the C programming language.13·10 months agoReject C, return to assembly. Structured programming is the true oppression our generation never talks about.
Ogeon@programming.devto Programming@programming.dev•What's the dumbest reason you've learned a programming language?5·1 year agoThat’s silly. Luckily, I don’t think this was the same situation. This was at a university and they had classes with other languages. The beginner classes were split into two variants, where some students (mostly CS students) learned C, and other students (economy, etc.) learned Python. I suppose they figured it was more useful to them or something.
Ogeon@programming.devto Programming@programming.dev•What's the dumbest reason you've learned a programming language?19·1 year agoI was a teacher’s assistant in beginner’s programming at university for a bit. I expected them to learn C, which I knew enough of, but I got assigned to a group that learned Python instead. I had never used Python at the time. I ended up having to speed learn it while trying to teach it, to not be completely useless.
Ogeon@programming.devto Learning Rust and Lemmy@lemmy.ml•How to think about function trait bounds (specifically that for `thread::spawn()`)?English2·1 year agoA 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 themove
keyword, to hint that you want it to move by default, or to use scoped threads. But yeahSend
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.devto Learning Rust and Lemmy@lemmy.ml•How to think about function trait bounds (specifically that for `thread::spawn()`)?English2·1 year agoYour guess is correct, it should be understood as
F: ( FnOnce() -> T ) + Send + 'static T: Send + 'static
The
FnOnce() -> T
is syntax sugar forFnOnce<(), Output = T>
and the bounds after apply toF
. That’s also whyT
has separate bounds. They aren’t propagated or inherited. It’s just an ambiguous looking syntax, butT + Trait + 'lifetime
isn’t a valid syntax for applying bounds toT
(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, henceF
needsSend + 'static
. When the thread is done with its work, it returns a value of typeT
that gets passed back viaJoinHandle<T>
, soT
needsSend + 'static
too.I hope this cleared things up a bit.
Ogeon@programming.devto Programming@programming.dev•Open source Git repo owners with open licenses, how do you know your code is being used by a big corpo?11·1 year agoThat’s definitely part of “the deal” with MIT and Apache. The other end of it is that they shouldn’t really expect to get anything more than what the authors are willing to give.
Ogeon@programming.devto Rust@programming.dev•Allow argument in macro to be Option<T> or T1·1 year agoRight, there may be too many unknowns involved. 🤔
Ogeon@programming.devto Rust@programming.dev•Allow argument in macro to be Option<T> or T1·1 year agodeleted by creator
Ogeon@programming.devto Rust@programming.dev•Allow argument in macro to be Option<T> or T18·1 year agoOption<T>
has aFrom<T>
implementation that lets you writeOption::from($file_path).map(|path| path.to_string())
to accept both cases in the same expression.https://doc.rust-lang.org/std/option/enum.Option.html#impl-From<T>-for-Option<T>
Ogeon@programming.devto AnarchyChess@sopuli.xyz•if this post gets 256 upvotes, i will post again with twice as wide en passant12·1 year agoZooming in? In this economy?!
“Search prompt engineer”
How much is that in ™?
Ogeon@programming.devOPto Rust@programming.dev•Palette 0.7.6: CIE CAM16, color theory schemes, and some more1·1 year agoThe rabbit hole goes deep if you really feel like going spelunking. A basic understanding of RGB, HSV and HSL takes you very far and lets you do a lot of things already. It’s good enough as long as it looks good, after all. 🙂
You really don’t need to read all of it to get started!
Ogeon@programming.devOPto Rust@programming.dev•Palette 0.7.6: CIE CAM16, color theory schemes, and some more2·1 year agoThis 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.devto Rust@programming.dev•Pretty critical PR for rust-msi is getting held up because the maintainer understands the intent but not why this works16·1 year agoA “mantra” more programmers should have is to fix the cause of the issue, and not just the symptoms. You have to understand what the problem is to be able to fix it.
Ogeon@programming.devto Learning Rust and Lemmy@lemmy.ml•How common is `if let` syntax and is it "worth" it?English51·1 year agoI would say it’s very useful when you are looking for one specific pattern, which happens a lot with
Option<T>
. Plus, being able to chain it inif / else if / else
chains helps with organizing the code. It generally doesn’t grow as deep as withmatch
.That said,
match
is fantastic and it’s totally fine to prefer using it.if let
andlet else
are there for those cases when you tend to discard or not need to use the other values than the matched one. How often that happens depends on what you are doing.
💁♂️🦋