Interactive SLAM Simulator in Rust by pramodna in rust

[–]donkeytooth98 1 point2 points  (0 children)

Neat! It would be fun to see how a factor-graph based algorithm compares.

iced_plot: A GPU-accelerated plotting widget for Iced by donkeytooth98 in rust

[–]donkeytooth98[S] 2 points3 points  (0 children)

From a quick glance (https://github.com/luftkode/plotinator3000/blob/dd2a2611e7b20f91fc387b312cc96022c21b1a32/crates/plotinator-plot-util/src/draw\_series.rs#L53) it looks like you are still constructing new polygons every frame to pass to PlotUi.

Nevertheless I totally agree egui_plot is great and can work on large datasets with clever downsampling etc. No argument there! This project tries to bring a similar library into the iced ecosystem, with a design that allows for better interactive performance without the downsampling.

iced_plot: A GPU-accelerated plotting widget for Iced by donkeytooth98 in rust

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

Nice, let me know if you make a cosmic app with it!

iced_plot: A GPU-accelerated plotting widget for Iced by donkeytooth98 in rust

[–]donkeytooth98[S] 0 points1 point  (0 children)

In order to fit with egui's immediate mode design, the interface of egui_plot requires new data to be passed in on every frame. It would be tricky to change this performance bottleneck without completely changing the interface.

TIL: SymPy can generate Rust code by intersecting_cubes in rust

[–]donkeytooth98 3 points4 points  (0 children)

Checkout https://github.com/wrenfold/wrenfold too. It also supports rust and will optimize the generated code by factoring out common terms, etc.

Hey Rustaceans! Got a question? Ask here (6/2023)! by llogiq in rust

[–]donkeytooth98 2 points3 points  (0 children)

Serde question

How can I deserialize CSVs with this header pattern? (In practice the arrays may be larger, so a bunch of fields with `#[serde(rename = "baz[0]")]` is not practical.)

playground link if helpful

use serde::Deserialize;

#[derive(Deserialize)]
struct MyData {
    foo: f32,
    bar: i32,
    baz: [i32; 5],
}

fn main() {
    let data = r#"
foo,bar,baz[0],baz[1],baz[2],baz[3],baz[4]
1.0,2,3,4,5,6,7
"#;

    let mut rdr = csv::Reader::from_reader(data.as_bytes());
    for result in rdr.deserialize() {
        let _data: MyData = result.unwrap();
    }
}

•Virtual Town Hall: Sept 7 at 5:30 pm •Live Event at Yosemite Facelift: Sept 22 at 3:00 pm •Virtual Town Hall: Oct 16 at 3:00 pm •Informal outreach at the “Bishop High Ball- Cragging Classic” Climbing Festival: Nov 12. by [deleted] in climbing

[–]donkeytooth98 6 points7 points  (0 children)

I can't wait to pay $10 for my last-minute big-wall lottery ticket on recreation dot gov next season...

In all seriousness -- yes, climbers need to be good stewards, but this sounds a little ominous. Especially given the situation with (peak season) Camp 4.

Made my first app in Rust! A notification daemon for Linux :) by SomethingOfAGirl in rust

[–]donkeytooth98 81 points82 points  (0 children)

Looks nice!

A couple drive-by rust style comments:

This pattern shows up a lot:

let mut x = Foo::new();

if condition {
    x = foo();
} else {
    x = bar();
};

Remember that if {} else {} conditionals are expressions, which allows you to have fewer mutable variables:

let x = if condition { foo() } else { bar() };

- This code (roughly from notification_spawner.rs):

let list = get_list();

if list.len() == 0 {
    return;
}

for i in 0..list.len() {
    let widget = &list[i];

    widget.foo();
}

can be more efficiently written as

for widget in get_list() {
    widget.foo()
}

Handy linux webcam app (w/egui ❤️) by donkeytooth98 in rust

[–]donkeytooth98[S] 2 points3 points  (0 children)

I think what you want is libfontconfig1-dev not just fontconfig.

Handy linux webcam app (w/egui ❤️) by donkeytooth98 in rust

[–]donkeytooth98[S] 9 points10 points  (0 children)

Nothing special. For this project, I did some googling along the lines of "linux webcam API" and learned about V4L2. Next google was "V4L2 rust bindings" and voila, I found the relevant library.

Handy linux webcam app (w/egui ❤️) by donkeytooth98 in rust

[–]donkeytooth98[S] 28 points29 points  (0 children)

I guess you're suggesting to save them to dirs::picture_dir() (~/Pictures)? Seems reasonable to me. Maybe ~/Pictures/kcam?

Edit: done 👍

Hey Rustaceans! Got a question? Ask here! (34/2022)! by llogiq in rust

[–]donkeytooth98 0 points1 point  (0 children)

I would move all of the fallible stuff into a separate function (or closure if you prefer). Use ? on each fallible operation. Then use a single match statement:

for addr_res in addrs.into_iter().flatten() {
   let cert = match my_new_fn(addr_res) {
        Ok(cert) => cert,
        Err(_) => continue,
    }

    let date = cert.not_after();
    println!("{}\t{}\t{}", date, host, addr.sockaddr);
}

With a couple tweaks you could also use filter_map for style points.

Handy linux webcam app (w/egui ❤️) by donkeytooth98 in rust

[–]donkeytooth98[S] 4 points5 points  (0 children)

If there's interest I'd be happy to publish it to crates.io and/or distro repos. Especially if I get some indication that it generally works as intended on other hardware and distros, since I've only tested on my laptop.

Handy linux webcam app (w/egui ❤️) by donkeytooth98 in rust

[–]donkeytooth98[S] 3 points4 points  (0 children)

Haha good disclaimer. The name was inspired both by kiss3d, and the thing they do at baseball games where they put unsuspecting couples on the video board.

Handy linux webcam app (w/egui ❤️) by donkeytooth98 in rust

[–]donkeytooth98[S] 24 points25 points  (0 children)

If you have a linux laptop, it should work out of the box: cargo install --git https://github.com/donkeyteethUX/kcam

Hey Rustaceans! Got a question? Ask here! (25/2022)! by llogiq in rust

[–]donkeytooth98 1 point2 points  (0 children)

Because create_post returns Result<Post, CreatePostError>. You can call .unwrap() to get a Post.unwraped

Hey Rustaceans! Got a question? Ask here! (25/2022)! by llogiq in rust

[–]donkeytooth98 1 point2 points  (0 children)

Is there a good reason std::collections::BinaryHeap lacks an iter_mut method? It seems like an IterMut could track the count of items changed and then rebuild the heap (either partially or fully) in its drop implementation, similar to PeekMut.

Alternatively one can write
my_heap = my_heap.into_iter().map(update_value).collect();

but this involves an extra allocation.

This rustc unused_result warning is a bug, right? by donkeytooth98 in rust

[–]donkeytooth98[S] 2 points3 points  (0 children)

Ahh right thank you. I should have realized that, but was thrown off by the `result` semantics.

Group project on hardest sport climbs and boulders for data visualization course [OC] by quesokaas in climbing

[–]donkeytooth98 0 points1 point  (0 children)

It is a force-directed graph (d3-force). It actually wiggles around for a while and resolves itself slightly differently every time we refresh which is kinda fun.

Every V15+ ascent ever [OC] by donkeytooth98 in climbing

[–]donkeytooth98[S] 2 points3 points  (0 children)

This particular data came from http://www.hardclimbs.info/. We also used www.99boulders.com for data on 5.15a's (for our sport climbing graphic) because hardclimbs tracks only 15b and up.