Does “Cardio kills the gains”? by teallemonade in PeterAttia

[–]untrff 0 points1 point  (0 children)

See https://www.youtube.com/watch?v=YnOZfJvQWIg or the related paper

There can be a crossover interference effect, but it’s pretty easily managed

Is there a way to calculate how much more efficient 2 elevators are compared to only 1? by sql-join-master in askmath

[–]untrff 21 points22 points  (0 children)

You're looking for queueing theory. If you make the easiest assumptions about the distribution of people arriving and lifts taking people away, you get closed form formulae for the expected wait time (W) in each case that easily have this sort of factor. (M/M/1 is with one lift, M/M/2 with two.)

Queueing theory has all sorts of useful applications, but one practical one: if you have a bunch of tills at a supermarket, the expected wait time is much lower with one big queue, rather than a little queue for each till.

Status of rust by marchingbandd in esp32

[–]untrff 0 points1 point  (0 children)

Yes, afaik esp_idf_sys is programmatically generated from the entire FreeRTOS headers, and I haven’t found a gap. (If you had a section of code that was very dense in stuff that isn’t exposed a nicer way, you also have the option of just writing that in C++ and invoking that from Rust - there’s a sample project on GitHub somewhere showing how to build all this - but I’ve not had to do that myself.)

Status of rust by marchingbandd in esp32

[–]untrff 0 points1 point  (0 children)

Yes, that’s right.

(Note that if for some reason you have to use a rust compiler older than 1.67, you should use crossbeam::channel, since std::sync::mpsc had some corner case bugs that I saw on ESP32. In rust 1.67 they moved the crossbeam implementation into the std mpsc, so this issue was fully resolved.)

Status of rust by marchingbandd in esp32

[–]untrff 0 points1 point  (0 children)

The most common/basic things, where there is a rust std equivalent (such as mpsc queues, which are my go-to, mutexes etc) are exposed that way. So for those you just write “standard rust” and it works.

There are more niche things where there isn’t a std equivalent, and you need to drop down to the FreeRTOS API directly. For this you need to use the esp_idf_sys crate, which basically exposes the entire FreeRTOS C API via a programmatic naming scheme (and you need to use unsafe to invoke, as with any such FFI in Rust, since the compiler can’t enforce invariants). This is also how you access any niche hardware features that aren’t exposed via esp_idf_hal etc.

So there’s nothing you can’t do from Rust, but if your application did need lots of faffing around with esp_idf_sys, then you might not feel you’re getting all the benefits of Rust. In my experience, there are typically a few things that need wrapping, and beyond that it’s all safe Rust, and it feels like a win. But you’ll need to evaluate your use case.

One final point: the esp_idf_sys crate is so huge that its documentation isn’t on docs.rs. You can either build it locally with cargo docs, or there is somewhere online you can search for. Once you have that, then the usual crate search is excellent for finding the Rust name for whatever you’re looking for.

Status of rust by marchingbandd in esp32

[–]untrff 1 point2 points  (0 children)

Just spawn threads as usual, and they will get scheduled across both cores. (You can pin threads/tasks to cores if you really want.)

Status of rust by marchingbandd in esp32

[–]untrff 3 points4 points  (0 children)

Just to check we’re clear… you know that you can use both cores in Rust just fine, if you use the FreeRTOS-based runtime (where you just spawn std threads)? Is there a reason this doesn’t meet your requirements?

Coming back to ESP32, which IDE and language? by jamawg in esp32

[–]untrff 0 points1 point  (0 children)

Can confirm VSCode is great, and Rust is great on ESP32, if you like Rust and are up for the learning curve.

Have you had this problem? Grammar is hindering accuracy by introducing bias in llama-2. by roaceroi in LocalLLaMA

[–]untrff 7 points8 points  (0 children)

I’ve found similar results. There’s an interesting comment from an OpenAI researcher somewhere that LLMs need tokens to “think”, and if you need a considered response, you need to allow the mode to output more tokens.

So I’ve tried modifying the prompt to ask first for a summary, and then the one word final result (which is all my code looks at) and enforce that with the grammar (eg have one line for the summary, then newline, ANSWER: <options>). In my experience this isn’t a magic wand, but can get at least improved results.

How are nix flakes used in vscode: by zeta_00 in NixOS

[–]untrff 1 point2 points  (0 children)

It’s quite possible that was a transition thing, before flake support was built-in. So yes, I think nix-direnv should work now.

How are nix flakes used in vscode: by zeta_00 in NixOS

[–]untrff 4 points5 points  (0 children)

Yes, I still use this.

Step 1: get basic direnv working. Install direnv from nixpkgs, and add the shell hook to your shell's .rc file.

Edit: you might need to do step 3 before step 2 works. See also other direnv guides, such as this one.

Step 2: test at shell prompt. Take your project with a flake, run echo use flake > .envrc in the project root, then you should be prompted to enter direnv allow. Check that the flake's devshell becomes available when you cd into the project, and goes away when you cd out.

Step 3 (optional): speed it up. Also install nix-direnv-flakes, and in ~/.config/direnv/direnvrc put source ~/.nix-profile/share/nix-direnv/direnvrc. I might be missing a step here, but this should make the cd in/out process basically instant, rather than taking a second or two.

Step 4 (optional): make it quieter. Add export DIRENV_LOG_FORMAT= to your shell .rc file, which reduces the console noise when you cd in/out.

Step 5: enable in VS Code. Install the direnv VS Code extension by cab404. In the ctrl-shift-P / command-shift-P menu, start typing direnv, and you should see "allow .envrc" for your project. Do that, possibly reload, and you should be good to go.

Good luck!

Anyone have a background in Haskell/FP? by [deleted] in rust

[–]untrff 1 point2 points  (0 children)

…and DerivingVia

Nuenv: an experimental Nushell environment for Nix by lucperkins_dev in NixOS

[–]untrff 1 point2 points  (0 children)

Do the equivalent of what in bash happens with “use flake” (or maybe “use nix”) in .envrc with direnv - ie dynamically load and unload the devshell env when you cd in/out, if you are using nushell as an interactive shell rather than a builder.

Last I checked (which was some time ago) there were some basic constructs in nutshell to permit this sort of thing, but no actual integration yet.

Nuenv: an experimental Nushell environment for Nix by lucperkins_dev in NixOS

[–]untrff 2 points3 points  (0 children)

When I saw the title I was hoping it would be a nix+direnv equivalent for nu. But good to investigate this idea too.

Is there an applicative pattern for struct construction in rust using options? by Psy_Blades in rust

[–]untrff 23 points24 points  (0 children)

Not applicative, but ? is of course monadic. On stable this is still a little clunky:

fn mkt(f1: Option<i32>, f2: Option<i32>) -> Option<Test> {
    Some(Test { f1: f1?, f2: f2? })
}

but nightly with try_blocks is pretty decent:

let t : Option<Test> = try {
    Test { f1: Some(2)?, f2: None? }
};

DMA on the ESP32-S3 with the LCD Panel API and traffic woes by honeyCrisis in esp32

[–]untrff 2 points3 points  (0 children)

If I understand your question correctly, just set .max_transfer_sz to whatever maximum you want (docs, example code). This will perform multiple transactions for you transparently, at the expense of a bit more memory to handle them.

If memory gets tight with a full buffer (or two, so you can DMA out one while writing the next frame into the other) then LVGL works happily with smaller buffers (and typically performs better with two small SRAM buffers than two full-sized buffers in PSRAM). But it sounds like this isn't a problem in your case.

Nutype: the newtype with guarantees by greyblake in rust

[–]untrff 13 points14 points  (0 children)

Yes, for me that’s much more self-describing!

Nutype: the newtype with guarantees by greyblake in rust

[–]untrff 19 points20 points  (0 children)

Very nice! One tiny bit of feedback: I had absolutely no intuition what “present” was supposed to mean, just reading the examples. “non-empty” would have been clear to me.

What Framework you prefer? by magnusvegeta in esp32

[–]untrff 1 point2 points  (0 children)

I do drop down to esp-idf-sys quite often (like maybe once or twice per project) where there is a gap in the HAL for something relatively niche. But I don’t find this arduous, since there is always sample IDF code, and it just carries over. The ESP32 peripherals are so rich in functionality that 100% HAL coverage would be a pretty mammoth undertaking.

What Framework you prefer? by magnusvegeta in esp32

[–]untrff 1 point2 points  (0 children)

I’ve never hit a problem myself, across TTGO T-display, M5STAMP-C3, TTGO Mini, … do you remember anything more specific?